Hi,
I have a quad graph with label layout ontop of the quad, which I would like to hide/show based on the zoom level of the plot (if the quads gets too small, the labels will just be rendered ontop of each other).
Here is an example of the graph (taken from the Bokeh site):
import numpy as np
N = 9
x = np.linspace(-2, 2, N)
y = x**2
source = ColumnDataSource(dict(
left=x,
top=y,
right=x-x**3/10 + 0.3,
bottom=y-x**2/10 + 0.5,
names=['a','b','c','a','b','c','a','b','c']
)
)
plot = figure(plot_width=400, plot_height=400,
sizing_mode="fixed",
tools=['xpan', 'xwheel_zoom'],
active_scroll='xwheel_zoom')
glyph = Quad(left="left", right="right", top="top", bottom="bottom", fill_color="#b3de69")
plot.add_glyph(source, glyph)
labels = LabelSet(x='left', y='top', text='names',
x_offset=0, y_offset=0, source=source, render_mode='canvas')
plot.add_layout(labels)
show(plot)
I thought that a custom JS would be the solution. I would appreciate help on how to write it:
plot.x_range.js_on_change('end', CustomJS(?))
Any other solution would be great as well.
Thanks,
Shay