Imi
Imi

Reputation: 549

Highcharts xAxis labels do not auto rotate

My chart has some custom x-axis labels using tick positions the labels are displayed as they should but the problem is that upon window resize they do not rotate I would like to rotate them on screen size less then 399 px jsfiddle

$(function () {
    $('#container').highcharts({
        title: {
            text: 'Monthly Average Temperature',
            x: -20 //center
        },
        subtitle: {
            text: 'Source: WorldClimate.com',
            x: -20
        },
        xAxis: {
            type: 'datetime',
                tickPositions: [1454329239000, 1465906839000, 1468844439000, 1469708439000, 1474892439000, 1476879639000, 1478607639000],
                labels: {

                  style: {
                    fontSize: '0.75em'
                  },
                  formatter: function() {
                    return Highcharts.dateFormat('%b %e', this.value);
                  }
                }

        },
        yAxis: {
            title: {
                text: 'Temperature (°C)'
            },
            plotLines: [{
                value: 0,
                width: 1,
                color: '#808080'
            }]
        },
        tooltip: {
            valueSuffix: '°C'
        },
        legend: {
            layout: 'vertical',
            align: 'right',
            verticalAlign: 'middle',
            borderWidth: 0
        },
        series: [{
            name: 'Tokyo',
            data: [[1454329239000, 09], [1465906839000, 08], [1468844439000, 07], [1469708439000, 10], [1474892439000, 17], [1476879639000, 8], [1478607639000, 20]]
        }]
    });
});

Upvotes: 1

Views: 2615

Answers (1)

LinusR
LinusR

Reputation: 1209

My experience dealing with a similar issue is that the autoRotation setting only works on category charts, whereas in your case, the x-axis labels are being rendered dynamically based on how much space is available.

However, I can't find any documentation or conversation on the interwebs to confirm my theory. Does anyone else know?

Upvotes: 3

Related Questions