我将 bokeh 作为 Bokeh 服务器应用程序运行。
当所有项目都已呈现在页面上时,我想执行一些操作。所以我发现 this file 中打印了一条消息。我怎样才能在消息后运行一些代码?我是否可以看到任何标志来检查服务器是否已加载以及所有元素是否已呈现?是否可以重写 Bokeh 方法?
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 中还没有为此构建任何内容。有一个开放功能可以添加对用户 Hook 的支持,以便在 Bokeh 文档初始化上运行代码:
https://github.com/bokeh/bokeh/issues/4272
这将有望成为0.12.6
。
我的猜测是,有一些方法可以用 hacky JS 来做到这一点,也许其他人同时会有解决方法。
关于coffeescript - 如何重写 Bokeh 上的方法?如何检查页面上是否已经渲染了所有元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43915626/