我正在使用JQuery Sparkline (http://omnipotent.net/jquery.sparkline)显示一个折线图,其中图形中的每个刻度对应于当天的一个小时间隔。我将工具提示的格式设置为:
<span style=\"color: {{color}}\">●</span> {{offset:names}} - {{y}}{{suffix}}</span>其中offset:names对应于一天中的小时(0 = 00:00,1= 01:00),依此类推。
图表使用实时数据进行更新。问题是,如果一个点在未来,我不想在工具提示中显示{{y}}值-只显示一天中的时间。有可能做到这一点吗?如果没有,有没有其他方法可以达到同样的效果?
发布于 2013-05-03 09:07:33
找到了!使用tooltipFormatter,我做了这样的事情:
sparkOpts.CurrentTimeGroup = currentTimeGroup;
sparkOpts.tooltipFormatter = function(sparklines, options, point)
{
if(point.x <= options.mergedOptions.CurrentTimeGroup)
return "<div class=\"jqsfield\"><span style=\"color: " + point.color + "\">●</span>" + options.get("tooltipValueLookups").names[point.x] + " - " + point.y + options.get("tooltipSuffix") + "</div>";
else
return "<div class=\"jqsfield\"><span style=\"color: " + point.color + "\">●</span>" + options.get("tooltipValueLookups").names[point.x] + "</div>";
};https://stackoverflow.com/questions/16348958
复制相似问题