Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
114
rated 0 times [  120] [ 6]  / answers: 1 / hits: 100623  / 13 Years ago, thu, december 15, 2011, 12:00:00

is there any way to pass some additional data to the series object that will use to show in the chart 'tooltip'?



for example



 tooltip: {
formatter: function() {
return '<b>'+ this.series.name +'</b><br/>'+
Highcharts.dateFormat('%b %e', this.x) +': '+ this.y;
}


here we can only use series.name , this.x & this.y to the series. lets say i need to pass another dynamic value alone with the data set and can access via series object. is this possible?



Thank you all in advance.


More From » jquery

 Answers
32

Yes, if you set up the series object like the following, where each data point is a hash, then you can pass extra values:



new Highcharts.Chart( {
...,
series: [ {
name: 'Foo',
data: [
{
y : 3,
myData : 'firstPoint'
},
{
y : 7,
myData : 'secondPoint'
},
{
y : 1,
myData : 'thirdPoint'
}
]
} ]
} );


In your tooltip you can access it via the point attribute of the object passed in:



tooltip: {
formatter: function() {
return 'Extra data: <b>' + this.point.myData + '</b>';
}
}


Full example here: https://jsfiddle.net/burwelldesigns/jeoL5y7s/


[#88553] Tuesday, December 13, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
alonso

Total Points: 747
Total Questions: 108
Total Answers: 105

Location: Mauritania
Member since Sun, Sep 25, 2022
2 Years ago
;