I’ve worked up a toy example that reproduces a problem I’m seeing in a larger app I’m building (on Bokeh 0.12.2):
I have a plot that uses a FactorRage. When I first render that plot, it has about 42 factors in it. I want to give the user the ability to filter the plot to only show subsets of those factors. In the toy example linked above, I’ve recreated that condition with a simple drop-down menu that specifies how many factors I want in the plot.
As you can see by running the example, changing the number of factors changes the data that are rendered, but the plot width and heigh (defined by 25 * the number of factors) doesn’t change in the browser. I’ve include a PreText field that shows that the width does change on the python side. Now I read recently (I think in this forum) that plot_width and plot_height don’t get updated in JS when changed in Python, so I changed the app to just replace the entire plot. The ref_id in the PreText field shows that this does, in fact, happen, but the plot size still doesn’t change.
The only way I could get it to work was to add line 62 (currently commented out in the example) that re-adds all of the children to the overall app layout. This successfully resizes the plot, but throws an ‘Uncaught Error: unknown edit variable’ in the console. That error seems to to not mess anything up too badly in the toy example, but in my much more complicated app (where the plot is in a Column, which is the child of a Panel, which is a Row, which is in a Column), trying to replace all children up the tree ends up destroying the entire layout of the app (plots just disappear, all Panels are shown at one time, etc.)
Is there a way for me to trigger a re-render of a plot with new plot_height and plot_width? If the answer involves a JS callback, please help me understand how I can trigger that callback from the Python side, since I already need to run a Python callback to do other things at the same time that the plot is resized.
Thanks in advance for any help you can offer!