如何覆盖 Bokeh 上的方法?如何检查页面上是否已呈现所有元素?

How to override methods on Bokeh? How to check if all the elements are already rendered on the page?

我运行将bokeh作为Bokeh服务器应用程序。

我想在页面上呈现所有项目时执行一些操作。所以我发现在this file中打印了一条消息。我怎么能 运行 消息后的一些代码?有没有我可以看到的标志来检查服务器是否已加载以及所有元素是否已呈现?可以覆盖散景的方法吗?

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

更新

由于这仍然不可能,我同时找到了一个解决方法:

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:

上添加对 运行 代码的用户挂钩支持

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

这有望成为0.12.6

我的猜测是 一些 方法可以使用 hacky JS 来做到这一点,也许其他人同时会有一个解决方法。