0
votes

Resize bokeh plot from CustomJS.

window.setXYDimension = function (width, height) {
  fig.plot_width  = width;
  fig.plot_height = height;
  console.log({fig});
  fig.reset(); //reset doesn't exist
  fig.resize(); //resize doesn't exist
  fig.layout(); //layout doesn't exist
};

Any help is appreciated.

2
It's not very clear what you want to do. Is it anything like as in this question? stackoverflow.com/questions/60614866/… - kmt
@smiley Thank You for the comment. Would like to update the bokeh plot, width & height from js dynamically? Will check the shared sol. Right now, using plot.model.attributes.width = width to update the plot width at Frontend. - Ajay

2 Answers

0
votes

This worked.

window.setXYDimension = function (width, height) {
  fig.frame_width  = width;
  fig.frame_height = height;
  fig.properties.width.change.emit();
  fig.properties.height.change.emit();
};

Thank You to Smiley for the solution.

0
votes

You can use the following CustomJS as well to resize figures on an event

CustomJS(args=dict(plot1=p1), code="""
plot1.width=1500;
plot1.height=1500;
plot1.document.resize();
"""
)