2

I am running bokeh as a Bokeh Server Application.

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)
  )

Update

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);
};
ChesuCR
  • 9,352
  • 5
  • 51
  • 114

1 Answers1

2

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

This will hopefully be able to make it into 0.12.6.

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.

bigreddot
  • 33,642
  • 5
  • 69
  • 122
  • 1
    Yes, in fact I found one. I updated my answer with what I have done. Thanks for devoting your time writing the answer – ChesuCR May 16 '17 at 15:27