Question

I've gotten examples of this working in highcharts, but I am having trouble getting this to work in highstocks. I am trying to get my tooltip to show some extra information about the point provided in the series but it seems like the values I put in my series data hash aren't being saved properly. The X and Y fields are being set ok since I can see the graph coming out correctly, but my other "fruit" and "name" fields are reporting null in the tooltip.

Here is an example of my series data:

{
    name: 'food1',
    fruit: 'apple',
    x: Date.UTC(2010, 0, 1),
    y: 216.4                
},
{
    name: 'food2',
    fruit: 'banana',
    x: Date.UTC(2010, 0, 4),
    y: 116.4                
}

And here is my loop inside my tooltip formatter:

$.each(this.points, function(i, point) {
    s += '<br/>Name is = '+ point.name;
    s += '<br/>y is = '+point.y;
    s += '<br/>Fruit is = ' +point.fruit;
});

The tooltip will show: Name is: undefined y is: 216.4 Fruit is: undefined

And I want it to show: Name is: food1 y is: 216.4 Fruit is: apple

Here is the jsfiddle link: http://jsfiddle.net/hYtUj/5/

Was it helpful?

Solution

you are accessing the attributes in a wrong way

it dhould be like this

$.each(this.points, function(i, point) { s += '<br/>Name is = '+ point.point.name; s += '<br/>y is = '+point.y; s += '<br/>Fruit is = ' +point.point.fruit; });

updated your fiddle here

I hope this will help you

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top