Bokeh multi_line and HoverTool

The following is the same question that I asked at http://stackoverflow.com/questions/32975709/bokeh-multi-line-and-hovertool.

In Bokeh 0.10.0 we can use HoverTool for lines. But can we use it for multi_line? For example, when running the following code,

from bokeh.models import ColumnDataSource
from bokeh.models import HoverTool
from bokeh.plotting import figure, output_file, show

x = [1, 2, 3, 4, 5]
ys = [[6, 7, 2, 4, 5], [5, 4, 2, 7, 6]]

hover = HoverTool(
tooltips=[
("(x,y)", “($x, $y)”),
(“label”, “@label”),
]
)

output_file(“test_bokeh.html”, title=“bokeh feature test”)

p = figure(title=‘figure’, x_axis_label=‘x’, y_axis_label=‘y’, tools=[hover])
line_source = ColumnDataSource({
‘x’: x,
‘y’: x,
‘label’: [‘single line’] * 5,
})
p.line(‘x’, ‘x’, source=line_source)
multi_line_source = ColumnDataSource({
‘xs’: [x, x],
‘ys’: ys,
‘label’: [‘line 0’, ‘line_1’],
‘color’: [‘red’, ‘blue’],
})
p.multi_line(‘xs’, ‘ys’, color=‘color’, source=multi_line_source)

show§

``

It correctly displays a tooltip for the line plot but nothing for the
multi_line plot. Am I doing something wrong, or is HoverTool not implemented for multi_line?

Not yet, that is still an open feature requests. To support hovering there would need to be a _hit point method implemented for this file:

  https://github.com/bokeh/bokeh/blob/master/bokehjs/src/coffee/renderer/glyph/multi_line.coffee

That would return the right sort of index information about which line was hit by the mouse cursor. Would be happy to help any new contributors get started if they were interested in looking into a PR for this.

Bryan

···

On Oct 6, 2015, at 12:13 PM, [email protected] wrote:

The following is the same question that I asked at http://stackoverflow.com/questions/32975709/bokeh-multi-line-and-hovertool.

In Bokeh 0.10.0 we can use HoverTool for lines. But can we use it for multi_line? For example, when running the following code,

from bokeh.models import ColumnDataSource
from bokeh.models import HoverTool
from bokeh.plotting import figure, output_file, show

x = [1, 2, 3, 4, 5]
ys = [[6, 7, 2, 4, 5], [5, 4, 2, 7, 6]]

hover = HoverTool(
tooltips=[
("(x,y)", "($x, $y)"),
("label", "@label"),
]
)

output_file("test_bokeh.html", title="bokeh feature test")

p = figure(title='figure', x_axis_label='x', y_axis_label='y', tools=[hover])
line_source = ColumnDataSource({
'x': x,
'y': x,
'label': ['single line'] * 5,
})
p.line('x', 'x', source=line_source)
multi_line_source = ColumnDataSource({
'xs': [x, x],
'ys': ys,
'label': ['line 0', 'line_1'],
'color': ['red', 'blue'],
})
p.multi_line('xs', 'ys', color='color', source=multi_line_source)

show(p)

It correctly displays a tooltip for the line plot but nothing for the multi_line plot. Am I doing something wrong, or is HoverTool not implemented for multi_line?

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/8ad4e0c4-baa0-4faf-9839-02740b72276a%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.