bokeh
bokeh copied to clipboard
Add `size` to Scatter
This PR fixes the explicit selection glyph example by adding size parameter to the Scatter model, which is by default 4.
- [ ] issues: fixes #13957
Here the result with the fix using bokeh 3.4.2 in a jupyter notebook after a click.
I think the best solution here is for the scatter sub-glyphs to inherit size by default if the user does not override it explicitly. I.e. it should be possible but not required to override the main glyph value, for sub-glyphs. That's how other properties work for sub-glyphs.
I tried to solve the problem and updated the javascript code to inherit from the base glyph.
For the example the visual output meets my expectations.
from bokeh.models import Scatter, Circle, ColumnDataSource
from bokeh.resources import Resources
from bokeh.plotting import figure, show, output_notebook
source = ColumnDataSource(dict(xx=[1, 2, 3, 4, 5],yy=[2, 5, 8, 2, 7]))
plot = figure(width=400, height=400, tools="tap", title="Select a circle")
renderer = plot.scatter('xx', 'yy', size=50, source=source)
selected_scatter = Circle(fill_alpha=1, fill_color="firebrick", radius=0.1)
nonselected_scatter = Scatter(fill_alpha=0.2, fill_color="blue", line_color="firebrick")
renderer.selection_glyph = selected_scatter
renderer.nonselection_glyph = nonselected_scatter
show(plot)
The problem is, that the models on the Python side are not updated and I don't know how I can solve this.
@bryevdv and @mattpap Help is needed. Any suggestions on the code and how to solve this for python are welcome. I will try finish this PR afterwards.
@mosc9575 thanks for your patience, please take a look at https://github.com/bokeh/bokeh/issues/13957#issuecomment-2308634367 for what I think is a better short-term "python only" solution that does not burden the user with manually keeping properties in sync, and does not burden us with technical lifts.
To fully implement this, we'll want to search and update all examples that set sub-glyphs using the bokeh.models API to follow that pattern with clone. Please let me know whether you have the bandwidth continue with these updates here. I understand, if not, but then I will close this PR.
@bryevdv I will try to do this task in the next few days.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.