0

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.

Ajay
  • 4,773
  • 3
  • 23
  • 36
  • 1
    It's not very clear what you want to do. Is it anything like as in this question? https://stackoverflow.com/questions/60614866/how-to-delete-add-rows-in-bokeh-heatmap-and-maintain-row-height – kmt Nov 13 '20 at 11:37
  • @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 Nov 13 '20 at 11:52

2 Answers2

0

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.

Ajay
  • 4,773
  • 3
  • 23
  • 36
0

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();
"""
)