Highcharts how to change x axis options
In Highcharts I want to change the default starting point from 0 to 1 is where can i find the option to change I have only data points so that are plotted on y axis and the x axis simply contain the default numbers ie 0,1,2, et开发者_运维技巧c.. i want to change the starting point from 0 to 1
thanks in advance
It's been a while since you've posted so I hope you've found your answer by now but I wanted to give you a response anyway.
You need to use the min option inside the X-Axis category. Read more about this here: http://api.highcharts.com/highcharts#xAxis
xAxis: {
min: 1,
categories: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11']
},
These options include the '0' as a category but the chart is drawn starting at the '1' position.
I put together a simple jsfiddle showing what you wanted to accomplish here: http://jsfiddle.net/L35DP/
I'll do you one better. We can simply use the xAxis label formatter as a mapping function to map our index values from 0,1,...,n
to 1,2,...,n+1
by defining the formatter as:
xAxis: {
labels: {
formatter: function() {
return this.value + 1;
}
},
}
Indeed you could define this mapping function to be anything at all. For example:
formatter: function() {
return this.value * this.value;
}
精彩评论