如何在Bokeh上覆盖方法?如何检查所有元素是否已经在页面上呈现? [英] How to override methods on Bokeh? How to check if all the elements are already rendered on the page?

查看:58
本文介绍了如何在Bokeh上覆盖方法?如何检查所有元素是否已经在页面上呈现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将bokeh作为Bokeh服务器应用程序运行.

I am running bokeh as a Bokeh Server Application.

当所有项目都已经呈现在页面上时,我想执行一些操作.因此,我发现在此文件.消息后如何运行一些代码?我是否可以查看任何标志来检查服务器是否已加载以及是否渲染了所有元素?可以覆盖bokeh上的方法吗?

I would like to do some actions when all the items are already rendered on the page. So I found that a message is printed in this file. How could I run some code after the message? Is there any flag that I could see to check if the server is loaded and all the elements rendered? Is possible to override methods on bokeh?

if promise != null
  promise.then(
    (value) ->
      console.log("Bokeh items were rendered successfully")
    (error) ->
      console.log("Error rendering Bokeh items ", error)
  )

更新

由于仍然无法实现,因此我在此期间找到了一种解决方法:

As this is still not possible, I found a workaround in the mean time:

oldLog = console.log;
console.log = function (message) {
    if(message.localeCompare('Bokeh items were rendered successfully') == 0){
        window.top.postMessage('show-bokeh-iframe', '*')
        console.log = oldLog;
    }
    oldLog.apply(console, arguments);
};

推荐答案

Bokeh目前没有为此内置任何功能.有一个开放功能可以添加对用户挂钩的支持,以在Bokeh文档init上运行代码:

Currently there is nothing built into Bokeh for this. There is an open feature to add support for a user-hook to run code on a Bokeh document init:

https://github.com/bokeh/bokeh/issues/4272

希望它将能够放入0.12.6.

我的猜测是,有一种 方法可以用于骇客的JS,也许其他人会在此同时找到解决方法.

My guess is that there is some way to do this with hacky JS, maybe someone else will have a workaround in the mean time.

这篇关于如何在Bokeh上覆盖方法?如何检查所有元素是否已经在页面上呈现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆