Reputation: 2232
I found many topics about how to force min
but it still doesn't work in my case. This is my last chance. I use the latest Highcharts 4.0.1 version.
Here is my fiddle: http://jsfiddle.net/gu8Bs/. I want to avoid the 0
and force 1
instead because my chart is a ranking evolution. No matter the values are.
$('#chart').highcharts({
xAxis: {
labels: {
rotation: 300,
y: 20
},
categories: ["2014-03-24", "2014-03-25", "2014-03-26", "2014-03-27", "2014-03-28", "2014-03-29", "2014-03-30", "2014-03-31", "2014-04-01", "2014-04-02", "2014-04-03"]
},
yAxis: {
type: 'linear',
allowDecimals: false,
reversed: true,
min: 1,
max: 300
},
series: [{
"data": [270, 251, 246, 2, 3, 6, 13, 19, 30, 42, 57]
}, {
"data": [69, 64, 64, 1, 2, 4, 8, 11, 15, 16, 25]
}],
credits: {
enabled: false
},
exporting: {
enabled: false
}
});
min: 1
shows 0
.
Upvotes: 1
Views: 504
Reputation: 45079
Another solution is just to set tickPositions
, like this: http://jsfiddle.net/gu8Bs/5/
yAxis: {
type: 'linear',
allowDecimals: false,
reversed: true,
tickPositions: [1, 50, 100, 150, 200, 250, 300]
},
Upvotes: 2
Reputation: 15866
Add tickPositioner
yAxis: {
type: 'linear',
allowDecimals: false,
reversed: true,
min: 1,
max: 300,
tickPositioner: function () {
var positions = [],
tick = Math.floor(this.dataMin),
increment = Math.ceil((this.dataMax - this.dataMin) / 6);
for (; tick - increment <= this.dataMax; tick += increment) {
positions.push(tick);
}
return positions;
}
},
EDIT
You can change it in these lines
tickPositioner: function () {
var positions = [],
// set starting position
tick = 1; //Math.floor(this.dataMin),
// set step size
increment = 50; //Math.ceil((this.dataMax - this.dataMin) / 6);
for (; tick - increment <= this.dataMax; tick += increment) {
if(tick == 1)
tick
positions.push(tick);
if(tick == 1)
tick = 0;
}
return positions;
}
Upvotes: 1