Hiero
Hiero

Reputation: 2205

Highcharts stock chart Unix date format

I'm using highchart to build some stock charts.

My data looks like this with UNIX timestamp:

    [[1122768000, 1.90717919001724],
    [1125446400, 1.98378222785977],
    [1128038400, 1.95762674363227],
    [1130716800, 2.00998209874657],
    /* alot of data here ... */
    [1133308800, 1.95492806759836]]

And my tooltip code is look like:

   tooltip: {
                    pointFormat: '<span>{series.name}</span>: <b>{point.y}</b><br/>',
                    valueDecimals: 2,
                    shadow: false,
                    color: '#000',
                    borderColor: 'transparent',                        
                    style: {
                        color: '#fff'
                    }
                }

But when I hover the tooltip the dates are looking weird, I want to keep just the day, month and year.

Can someone explain me how to achive this?

enter image description here

Upvotes: 0

Views: 1210

Answers (2)

Sebastian Bochan
Sebastian Bochan

Reputation: 37588

In the highcharts you need to use javascript timestamps, instead of UNIX. So multiply your timestamps by 1000.

Upvotes: 1

jlbriggs
jlbriggs

Reputation: 17800

1) you need to send the time stamp in milliseconds instead of seconds

2) You can control its format with a few different methods:

Overall date label format option:

Tooltip headerFormat option:

Or the less user friendly but more powerful formatter function:

Upvotes: 0

Related Questions