Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Highcharts - with datetime axis labels overlap

I'm using Highcharts and I have a chart with a datetime axis. Most times the labels are correctly distributed along the axis with no overlap.

But sometimes it happens that labels overlap. Here you can see an example: http://jsfiddle.net/4ghhf/ Using tickInterval and tickPixelInterval doesn't solve the problem.

What should I do to avoid the problem?

like image 533
sabrina Avatar asked Apr 23 '12 14:04

sabrina


1 Answers

I see two ways of fixing your problem :

  • Change the tick interval
  • Change the label display

I applied both in the following code (xAxis section) :

$(function () {
 var chart = new Highcharts.Chart({

    chart: {
        renderTo: 'container',
        type: 'column'
    },

    xAxis: {
        type: 'datetime',
        tickInterval : 7*24 * 3600 * 1000,
        labels : { y : 20, rotation: -45, align: 'right' }
    },
    series: [{
        data: [
            [Date.UTC(2010, 3, 11), 29.9],
            [Date.UTC(2010, 4, 8), 71.5]
         ]
    }]
});
like image 191
Kirualex Avatar answered Sep 29 '22 00:09

Kirualex