user3040345
user3040345

Reputation: 619

Highcharts-tooltip doesnt display date

Iam newbie in using highcharts.

I have datepicker from and to, and getting data from json file.

The graph is shown on weekly basis.

My x-axis is weeks,so my tooltip shows week number.

I also wanted to display date in the tooltip of graph like suppose, in 1st week the date range is 31-03-2013 to 06-04-2013,when the point is on 1st week, I need to display this date in tooltip without changing the x-axis.

can anyone help through this.

Here is my code,

$(function () {

        $('#container').highcharts({

            title: {
                text: typeSelected + ' - Graph',
                x: -20 //center
            },
            xAxis: {
                allowDecimals : false,
                title: {
                    text: "WEEK"
                }
            },
            tooltip: {
                formatter: function() {
                    var s = '<b> WEEK: '+ this.x +'</b><br/><b> '+ typeSelected +': '+ this.y +'</b>';              
                    return s;
                },
                shared: true
            },
            yAxis: {
                title: {
                    text: typeSelected
                },
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'middle',
                borderWidth: 0
            },
            series: [{
                name: typeSelected,
                data: xyAxisArr,
            }]
        });

    });
    }

Upvotes: 0

Views: 153

Answers (1)

Paweł Fus
Paweł Fus

Reputation: 45079

In tooltip, you are returning this.x, which is timestamp. If you want date, then use for example Highcharts.dateFormat() to get returned date string.

Reference: http://api.highcharts.com/highcharts#Highcharts.dateFormat

Upvotes: 1

Related Questions