Sajeetharan Sajeetharan - 1 month ago 10
AngularJS Question

Highcharts showing timestamp as wrong date

I need to show correct date on highcharts based on timestamp,

Config as follows,

series: [{
"name": "avg_sales",
"color": "#3b6982",
"data": [{
"name": 1230768000,
"y": 526.4200000000001
}, {
"name": 1230854400,
"y": 1850.3116666666667
}, {
"name": 1230940800,
"y": 3199.786
}]
}],
tooltip: {
dateTimeLabelFormats: {
hour: '%A, %b %e, %l %p'
},
},
xAxis: {
dateTimeLabelFormats: {
hour: '%A, %b %e, %l %p'
},
type: 'datetime'
}


EXPECTED OUTPUT:
it shows correct values in tooltip but not in the x axis values. how to sort this issue?

DEMO

Answer

If you use timestamp or number, use x property instead of name (name can be still used though but x takes precedence)

"data": [{
        "name": "point's name",
      "x": 1230768000,
      "y": 526.4200000000001
    }, {
      "x": 1230854400,
      "y": 1850.3116666666667
    }, {
      "x": 1230940800,
      "y": 3199.786
    }]

example: http://jsfiddle.net/95LX7/71/

Comments