ejain
ejain

Reputation: 3604

Override tick interval calculation in Highcharts?

Highcharts does a great job figuring out appropriate tick intervals.

However, I have a "duration" series (in ms), which I format e.g. like "3y 6M" or "1d 3h" or "3h 30min" for display. Because Highcharts is optimizing the tick intervals for the ms value (e.g. 10,000,000ms), I end up with awkward values such as [ 2h 46min 40s, 5h 33min 20s, 8h 20min ] rather than [ 3h, 6h, 9h ].

Can I get Highcharts to prefer multiples of certain values (e.g. 1000, 60 * 1000, 60 * 60 * 1000 etc)? I'd rather not have to calculate the exact tick interval myself (depends on chart size etc).

unformated y-axis values formatted y-axis values

Upvotes: 1

Views: 955

Answers (2)

Paweł Fus
Paweł Fus

Reputation: 45079

I think you should consider using datetime axis for yAxis. For example: http://jsfiddle.net/jRGvs/

    yAxis: {
        type: 'datetime'
    },

    series: [{
        type: 'column',
        name: 'Column',
        data: [Date.UTC(1970, 0, 1, 2, 30), 
               Date.UTC(1970, 0, 1, 1, 45), 
               Date.UTC(1970, 0, 1, 4, 10), 
               Date.UTC(1970, 0, 1, 3, 30)]
    }]

Upvotes: 1

Strikers
Strikers

Reputation: 4776

you can go with label > formatter for yAxis,

here you can write a routine which will handle the text/value to be displayed beside the grid line. but the thing is you cannot override the tick interval from here.

Upvotes: 0

Related Questions