【问题标题】:Jquery sparklines: Possible to have different tooltips?Jquery 迷你图:可能有不同的工具提示?
【发布时间】:2013-05-02 22:43:26
【问题描述】:

我正在使用 JQuery Sparklines (http://omnipotent.net/jquery.sparkline) 来显示折线图,其中图表中的每个刻度对应于当天的一个小时间隔。我已将工具提示格式化为:

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

其中offset:names 对应于一天中的小时(0 = 00:00、1 = 01:00)等。

图表使用实时数据进行更新。问题是,如果某个点在未来,我不想在工具提示中显示 {{y}} 值 - 只是一天中的时间。是否有可能做到这一点?如果没有,还有其他方法可以达到同样的效果吗?

【问题讨论】:

    标签: sparklines


    【解决方案1】:

    找到了!使用 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 + "\">&#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>";
      };
    

    【讨论】:

      猜你喜欢
      • 2017-04-13
      • 2013-06-23
      • 1970-01-01
      • 2018-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-03
      • 1970-01-01
      相关资源
      最近更新 更多