gwatts / jquery.sparkline

A plugin for the jQuery javascript library to generate small sparkline charts directly in the browser
http://omnipotent.net/jquery.sparkline/
1.24k stars 278 forks source link

Tooltip is shown for the last value in series, for same values in the series #58

Closed saadgit closed 11 years ago

saadgit commented 11 years ago

Is it a bug that:

Tooltip is shown for the last value in series, for same values in the series

e.g ...

enableTagOptions: true, type: 'line', tooltipFormat: '{{y}} [ {{y:val}} ]', tooltipValueLookups: { 'val' : {1:"A", 2:"B", 3:"C", 2:"D" }

...

The sparkline for it will show tooltip on mouseover as

A, D, C, D, where as it should be A, B, C, D

How can it be fixed?

gwatts commented 11 years ago

It's not a bug - It's because you're looking up by value, and two entries have the same value.

Instead you can implement a tooltipFormatter which can return whatever you want for each x value.

Take a look at this example for a hint: http://jsfiddle.net/gwatts/RsbHC/