GraphRenderer breaks custom Hover callbacks
See original GitHub issueHi, using CustomJS callbacks in the HoverTool appears to be broken with the GraphRenderer. The callback is never executed and TypeError: undefined is not an object (evaluating 'n.data_source.inspected')
is printed to the browser’s console. I didn’t see this issue with other renderers.
I’m using bokeh 0.13.0 and networkx 2.1 with Python 3.6.6 (installed by Anaconda) and Jupyter 4.4.0 on macOS 10.13.5 in Safari 11.1.1
Minimal example
from bokeh.io import show, output_notebook
from bokeh.models import Range1d, Plot, CustomJS, Circle, HoverTool
from bokeh.models.graphs import from_networkx
import networkx as nx
output_notebook()
# create the graph renderer
G = nx.Graph()
G.add_weighted_edges_from([(1, 2, 0.125), (1, 3, 0.75), (2, 4, 1.2), (3, 4, 0.375)])
graph = from_networkx(G, nx.layout.circular_layout, scale=1.8, center=(0,0))
# create a circle just to also test another renderer
c = Circle()
c.x = 0
c.y = 0
c.radius = .1
# build plot
plot = Plot(x_range=Range1d(-3, 3), y_range=Range1d(-3, 3))
plot.renderers.append(graph)
plot.add_glyph(c)
# this just prints an error to the console:
# "TypeError: undefined is not an object (evaluating 'n.data_source.inspected')"
hover_tool = HoverTool(
tooltips="index: @index",
callback=CustomJS(code='console.log("foo");'),
renderers=[plot.renderers[0]]
)
# this prints "foo" and no error to the console,
# but it also doesn't allow us to interact with the graph
#hover_tool = HoverTool(
# tooltips="index: @index",
# callback=CustomJS(code='console.log("foo");'),
# renderers=[plot.renderers[1]]
#)
plot.add_tools(hover_tool)
show(plot)
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Unable to use CustomJS callback on HoverTool with ...
I am attempting to use a CustomJS callback on a HoverTool that is connected to a plot containing a GraphRenderer.
Read more >How to add line breaks to plotly hover labels - Stack Overflow
Is there a way to get plotly to display the hover text on multiple lines/get it to recognize special characters line '\n' in...
Read more >Bokeh - freshcode.club
#10481 component: bokehjs Unable to use CustomJS callback on HoverTool with GraphRenderer. - #10484 component: docs Typo in ...
Read more >Rickshaw: A JavaScript toolkit for creating interactive time ...
Customize all you like with techniques you already know. ... Show the series value and formatted date and time on hover: var hoverDetail...
Read more >bokeh custom tooltips stacking on top of each other
getElementsByClassName('bk-tooltip')[0].style.display = 'none'; } '' ' p.hover.callback = CustomJS(code = code) show(p) from bokeh.plotting import figure, ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@felixpatzelt Yes, that’s why I suggested we might just decide to remove
GraphRenderer
instances automatically. Specifically I think Bokeh should:Alternatively to the second bullet, we could potentially refine the type system to prevent
GraphRenderer
from being added explicitly on the python side at all.@meenurajapandian please provide actual code and relevant version information. It is not valuable for us to speculate about the details of what you are doing.