Highcharts - Display only year in x axis and stop auto formatting

highcharts

Solution

@Pawel's answer did not fully work for me. I could see repeated year values which is not what I want.

The following code worked for me.

xAxis: {
            type: 'datetime',
            dateTimeLabelFormats: { 
            year: '%Y'
            },
            tickInterval: Date.UTC(2010, 0, 1) - Date.UTC(2009, 0, 1)

        }

Problem

This is how the chart looks like at the moment: http://jsfiddle.net/YWLpr/2/ If you see the x axis, you can see Month as well as Year while I want to display just the year. Surprisingly if you add one more data entry in the series ``` [Date.UTC(2011,2,31), 11.30] ``` The x axis auto formats itself and display only the year e.g. - http://jsfiddle.net/YWLpr/3/ So if there are 7 data points I can see year in the x axis but if there are less than 7 data points I can see month and year which is not what I want. How can I stop this auto formatting and display only the year in x axis for less than 7 data points.

Original source