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.

Hover tool question.

See original GitHub issue

Hi. It is not clear why the hover tool does not work in the following example. Could you say, what’s wrong with it?

output_notebook()
TOOLS="pan,wheel_zoom,box_zoom,reset,previewsave,hover"
source = ColumnDataSource(
    data=dict(
        x=np.array(AAPL['date'], 'M64'),
        y=AAPL['adj_close']
    )
)
line(np.array(AAPL['date'], 'M64'), AAPL['adj_close'], color='#A6CEE3', legend='AAPL', source=source,tools=TOOLS)
hover = [t for t in curplot().tools if isinstance(t, HoverTool)][0]
hover.tooltips = OrderedDict([
    ("(x,y)", "($x, $y)")
])
show()

Is it a good place for such questions, or I may ask somewhere else? Thank you.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
chdoigcommented, Aug 10, 2014

Hi! In the documentation you can find the following information on the HoverTool: http://bokeh.pydata.org/docs/user_guide.html#hovertool

Hover tool currently does not work with lines, images, or patch type glyphs.

My suggestion would be to use scatter() + line() (remember to include hold()), since scatter does support hover:

output_notebook()
hold()
TOOLS="pan,wheel_zoom,box_zoom,reset,previewsave,hover"
source = ColumnDataSource(
    data=dict(
        x= np.array(AAPL['date'], 'M64'),
        y=AAPL['adj_close'],
        date = AAPL['date']
    )
)
scatter('x', 'y', color='#A6CEE3', source=source, tools=TOOLS, x_axis_type = "datetime")
line('x', 'y', color='#A6CEE3', legend='AAPL', source=source)
hover = [t for t in curplot().tools if isinstance(t, HoverTool)][0]
hover.tooltips = OrderedDict([
    ("date", "@date"),
    ("price", "$y" )
])
show()

I’ve added some other suggestions:

  • If you are passing the source, you don’t need to write again np.array(AAPL['date'], 'M64'), just the name of the column in your ColumnDataSource that you want to use (e.g. 'x').
  • If you want to display the date with a nice date format and not the timestamp, you can do date = AAPL[‘date’] and display that in the hover box.
  • You can also add a x_axis_type = "datetime".

Hope this helps! Please, let me know if the above code doesn’t work for you.

0reactions
hackermdcommented, Oct 27, 2015

Thank you for your feedback! My images are pretty big so that I anticipate problems with the number of points. Since the image data is simply stored as an array I thought it should be straight forward to read out the values from the plot object!? For now I will try to do this on the client side via the generated canvas element.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hover Tooltips Question Mark for @ function - Bokeh Discourse
I am trying to show the text of excel using hovertool, but it shows question mark when I use @ function I used...
Read more >
Data tooltips in Bokeh don't show data, showing '???' instead
Bokeh hover tooltip not displaying all data - Ipython notebook. The question might be related, but frankly I didn't quite understand the answer....
Read more >
Standard style for text that opens hover tool tip?
Most applications/websites either have an icon (often a question mark) to indicate you can hover over it (but then the hover only works...
Read more >
Adding hover over / mouse over descriptions for response ...
Hi, I'm trying to add descriptions to response options when you hover over them. From what I've seen on the board, the code...
Read more >
Add Hover Over Tooltips - Alchemer Help
This basic tooltip can be added to question text and Text/Instructions ONLY. ... We do not have a built-in feature for hover-over tool...
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