Jquery sparklines: is it possible to have different hints?

I use JQuery Sparklines ( http://omnipotent.net/jquery.sparkline ) to display a line graph where each tick on the graph corresponds to the hour interval of the current day. I formatted the tooltip as such:

<span style=\"color: {{color}}\">&#9679;</span> {{offset:names}} - {{y}}{{suffix}}</span> 

where offset:names corresponds to the hour of the day (0 = 00:00, 1 = 01:00), etc.

The graph is updated using live data. The problem is that if the point is in the future, I do not want to display the value {{y}} in the tooltip - only the time of day. Is it possible to do this? If there is no other way to get the same effect?

+4
source share
1 answer

Found! Using tooltipFormatter, I did something like this:

 sparkOpts.CurrentTimeGroup = currentTimeGroup; sparkOpts.tooltipFormatter = function(sparklines, options, point) { if(point.x <= options.mergedOptions.CurrentTimeGroup) return "<div class=\"jqsfield\"><span style=\"color: " + point.color + "\">&#9679;</span>" + options.get("tooltipValueLookups").names[point.x] + " - " + point.y + options.get("tooltipSuffix") + "</div>"; else return "<div class=\"jqsfield\"><span style=\"color: " + point.color + "\">&#9679;</span>" + options.get("tooltipValueLookups").names[point.x] + "</div>"; }; 
+6
source

Source: https://habr.com/ru/post/1478882/


All Articles