2013-10-11 60 views
18

我想在每列如何在工具提示高圖中獲取多個系列數據?

tooltip: { 
    formatter: function() { 
     return '<span style="color:#D31B22;font-weight:bold;">' +this.series.name +': '+ this.y +'<br/>'+ 
       '<b style="color:#D31B22;font-weight:bold;">'+this.x +'</b><span>'; 
    } 
}, 

和數據

series: [{ 
    showInLegend: false, 
    name: 'Total Click', 
    data: [3000,200,50,4000], 
    color: '#9D9D9D' 
}, { 
    showInLegend: false, 
    name: 'Total View', 
    data: [100,2000,3000,4000], 
    color: '#D8D8D8' 
}] 

我使用這樣但是在刀尖僅一個序列數據在時間表示顯示工具提示的多個序列數據。 我想這樣的顯示數據(總瀏覽:100總點擊:3000)

+0

添加你的代碼,所以我可以幫你:) –

+0

哎,莫希特請檢查我的代碼,我認爲這是你所需要的http://jsfiddle.net/pintu31/AcNUM/2/ –

+0

不錯的工作............... Pragnesh –

回答

29

請嘗試使用此代碼

updated DEMO

tooltip: { 
     formatter: function() { 
      var s = []; 

      $.each(this.points, function(i, point) { 
       s.push('<span style="color:#D31B22;font-weight:bold;">'+ point.series.name +' : '+ 
        point.y +'<span>'); 
      }); 

      return s.join(' and '); 
     }, 
     shared: true 
    }, 
+0

's.push(''' – grantiago

1

如果有人找散點圖,這裏是solution顯示共享工具提示。

formatter: function(args) { 
    var this_point_index = this.series.data.indexOf(this.point); 
    var this_series_index = this.series.index; 
    var that_series_index = this.series.index == 0 ? 1 : 0; // assuming 2 series 
    var that_series = args.chart.series[that_series_index]; 
    var that_point = that_series.data[this_point_index]; 
    return 'Client: ' + this.point.name + 
      '<br/>Client Health: ' + this.x + 
      '<br/>' + this.series.name + ' Bandwidth: ' + this.y + 'Kbps' + 
      '<br/>' + that_series.name + ' Bandwidth: ' + that_point.y + 'Kbps'; 
} 

Jsfiddle link to Solution

+0

有沒有像這樣的解決方案的列sharts? – es3735746

相關問題