0

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])

NewRCoder
  • 23
  • 2

1 Answers1

0

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.

ac24
  • 5,325
  • 1
  • 16
  • 31
  • Thanks! That works well. I just overlayed a scatter chart and pointed the tooltip to the x and y from the scatter chart and everything works as expected. I appreciate the help. – NewRCoder Dec 24 '19 at 18:05