Sumedh
Sumedh

Reputation: 648

Highcharts - Wrong date in tooltip

fiddle - http://jsfiddle.net/z8fw7/

When I hover over the column I can see this weird big number, where is it coming from.

If I add one more date entry. e.g

    [Date.UTC(2010,2,31), 28.84], 
    [Date.UTC(2011,2,31), 28.84], 
    [Date.UTC(2012,2,31), 32.65]

The tooltip then displays the proper year value as expected. It works flawlessly with 3 data values while it does not work with 2 data values. How can I make sure that it works with even 2 data values.

Upvotes: 2

Views: 2920

Answers (2)

Amy
Amy

Reputation: 7466

Looks like a bug in Highcharts with 2 data points when using the pointFormat. I suggest using the more customizable formatter function.

So in your option for configuring the tooltip, use this:

tooltip: {
    formatter: function() {
        var date = new Date(this.x);
        var year = date.getFullYear();
        return year + '<br/>' + '<span style="color:'+this.series.color+'">'+ this.series.name +'</span>: '+ this.y + '%';
     },
}

Works fine with the 2 data points or 3, etc. See: http://jsfiddle.net/UqbKQ/

Upvotes: 3

jlbriggs
jlbriggs

Reputation: 17791

the value you are seeing is the timestamp of the data point from the x axis.

This formatting (or lack thereof) seems like a bug to me...

I don't see an obvious answer except to use the formatter function to fully customize the tooltip display.

Upvotes: 0

Related Questions