2013-05-12 61 views
1

了工作,我已經張貼在後同樣的問題:highcharts pass multiple values to tooltip「this.point.config」不highcharts提示

我想將數據傳遞給工具提示,但this.point.config[2]不工作。 我還發現了this的例子。它不是在那裏工作過

formatter: function() { 
    return 'param1: '+this.point.config[2] + 'param2: '+this.point.config[3]; 

可以請你幫我

+0

你能與我們分享,你的代碼的jsfiddle或jsBin? – 2013-05-13 05:53:30

回答

3

如果你想在額外的價值傳遞到刀尖,數據系列需要將對象的列表,而不是值的列表:

data: [ 
    { 
     x: 7, 
     y: 10, 
     config1: 'test',  // our custom data 
     config2: 'test2'  // our custom data 
    }, 
    { 
     x:10, 
     y:20, 
     config1: 'test3', // our custom data 
     config2: 'test4'  // our custom data 
    } 
] 

所以在你的Highcharts formatter功能,你可以引用自定義參數,例如。 config1config2(你可以使用任何名字,你要真的):

tooltip: { 
    formatter: function() { 
     return 'param1: '+this.point.config1 + '<br/>param2: '+this.point.config2; 
    } 
} 

見琴:http://jsfiddle.net/FuyTC/8/