【问题标题】:How do I hide a Highcharts series from the chart, but always show it in the tooltip?如何从图表中隐藏 Highcharts 系列,但始终在工具提示中显示?
【发布时间】:2014-03-09 19:20:22
【问题描述】:

我正在使用Highcharts 来渲染带有两个 y 轴的图表。一个轴测量计数,而另一个轴测量速率。为了说明,请参考以下内容:http://jsfiddle.net/NH5R3

我想通过隐藏汇率系列(并最终移除汇率轴)来简化此图表,但仍让共​​享工具提示显示相应的汇率系列。我试图通过plotOptions.series.visibleplotOptions.column.visible 隐藏系列,但这会隐藏图表和工具提示中的数据。

我想我可能需要修改工具提示格式化程序以始终呈现隐藏系列,但我想知道是否有办法阻止客户端将系列状态切换为可见。

有没有更好的方法来解决这个问题?

【问题讨论】:

    标签: javascript highcharts dotnethighcharts


    【解决方案1】:

    此时,如果rates 只是一个系列以使其进入工具提示,我只需将系列全部废弃并通过格式化程序包含数据。比如:

    var rates = {'Category1':20,
                 'Category2':25,
                 'Category3':75};
    
    ...
    
    tooltip: { shared: true,
         formatter: function() {
              var s = '<b>'+ this.x +'</b><br/>';                
              $.each(this.points, function(i, point) {
                  s += '<span style="color:'+point.series.color+'">'+point.series.name+'</span>: <b>'+point.y+'</b><br/>'
                });
                s+='Rate: ' + rates[this.x] + '%';
                return s;
            },
     ...
    

    更新小提琴here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      相关资源
      最近更新 更多