Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] TapTool inspection doesn't find indices when used on CDSView #13388

Open
Kadek opened this issue Sep 20, 2023 · 2 comments · May be fixed by #13439
Open

[BUG] TapTool inspection doesn't find indices when used on CDSView #13388

Kadek opened this issue Sep 20, 2023 · 2 comments · May be fixed by #13439

Comments

@Kadek
Copy link
Contributor

Kadek commented Sep 20, 2023

Software versions

Python version : 3.10.5 (tags/v3.10.5:f377153, Jun 6 2022, 16:14:13) [MSC v.1929 64 bit (AMD64)]
IPython version : (not installed)
Tornado version : 6.2
Bokeh version : 3.2.2
BokehJS static path : C:\Users\kadek\Desktop\kod\bokeh_playground\venv\lib\site-packages\bokeh\server\static
node.js version : (not installed)
npm version : (not installed)
Operating system : Windows-10-10.0.19045-SP0

Browser name and version

No response

Jupyter notebook / Jupyter Lab version

No response

Expected behavior

When using TapTool on a glyph that uses CDSView with GroupFilter, the callback object's inspected.indices should be populated with index of the tapped point.

Observed behavior

The inspected.indices are populated only when taping points falling into the last filter category.

Example code

from bokeh.layouts import column
from bokeh.plotting import figure, curdoc
from bokeh.models import ColumnDataSource, TapTool, CustomJS, CDSView, GroupFilter

categories = ["a", "b"]
data = {
	"x": [1, 2],
	"y": [1, 2],
	"z": categories
}
source = ColumnDataSource(data=data)

p = figure(width=300, height=300, tools="pan,reset,save")
p.add_tools(TapTool(
    description="Tap",
    behavior="inspect",
    callback=CustomJS(
        code="""
        	console.log(cb_data.source.inspected.indices);
        """,
    ),
))
for category in categories:
	view = CDSView(filter=GroupFilter("z", category))
	p.scatter(source=source, view=view)

doc = curdoc()
doc.add_root(column(p))

I run this with bokeh serve .\modifiers.py --show

When in browser, tap on the top right point and you will see [1] in browser console.
Tap on the bottom left point and you will see [] in browser console.

Stack traceback or browser console output

No response

Screenshots

image

@Kadek Kadek added the TRIAGE label Sep 20, 2023
@mattpap
Copy link
Contributor

mattpap commented Oct 10, 2023

The problem here is with behavior="inspection" and sharing a data source between multiple renderers. This results in inspection indices being overridden by the last glyph renderer. The behavior for behavior="select" is different and it depends on the selection policy of a data source (typically computes a union of all selections). I'm not sure if there's a rationale for a different behavior, but I would unify this. @bokeh/dev, any thoughts on this?

@bryevdv
Copy link
Member

bryevdv commented Oct 10, 2023

Good catch I missed the behavior setting in the OP.

I'm not sure if there's a rationale for a different behavior

AFAIK it is just the original behavior implemented before CDSViews and selection policies, and it was not updated whenever the those new features were added.

@mattpap mattpap added this to the 3.4 milestone Oct 13, 2023
@mattpap mattpap modified the milestones: 3.4, 3.x Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants