question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

GraphRenderer breaks custom Hover callbacks

See original GitHub issue

Hi, 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:open
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bryevdvcommented, Oct 19, 2018

@felixpatzelt Yes, that’s why I suggested we might just decide to remove GraphRenderer instances automatically. Specifically I think Bokeh should:

  • silently exclude them from being added on the JS side when no renderers are given
  • issue a valuation error if they explicitly added on the Python side

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.

0reactions
bryevdvcommented, Oct 6, 2019

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found