Search code examples
tooltiplinechartbqplot

Tooltip data shows up NaN in bqplot Lines chart


I am having trouble getting my tooltip data to show up in my line chart. Here is some very simple code that reproduces the error. When I hover over the line all that shows up is NaN. Can someone please help me? Thank you!

from bqplot import (Axis, LinearScale, Lines, Figure, Tooltip)

x = [1,2,3,4,5]

y = [1,2,3,4,5]

x_sc = LinearScale()

y_sc = LinearScale()

def_tt = Tooltip(fields=['x', 'y'], formats=['.1f', '.1f'])

line_chart = Lines(x=x, y=y, scales= {'x': x_sc, 'y': y_sc}, line_style='solid',default_colors=['dodgerblue'], tooltip=def_tt)

ax_x = Axis(scale=x_sc)

ax_y = Axis(scale=y_sc, orientation='vertical', tick_format='0.2f')

Figure(marks=[line_chart], axes=[ax_x, ax_y])


Solution

  • Looks like this is an open issue with bqplot (https://github.com/bloomberg/bqplot/issues/702)

    One workaround I found around this was to create a scatter chart (for which the tooltip works in the expected way), and plot this with invisible, fully transparent markers. Then plot your visible line on top.