我发现了许多关于如何强制min
的主题,但在我的案例中它仍然无效。这是我的最后一次机会。我使用最新的Highcharts 4.0.1版本。
这是我的小提琴:http://jsfiddle.net/gu8Bs/。我想避免使用0
和强制1
,因为我的图表是排名演变。无论价值观是什么。
$('#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
显示0
。
答案 0 :(得分:2)
另一种解决方案就是设置tickPositions
,如下所示:http://jsfiddle.net/gu8Bs/5/
yAxis: {
type: 'linear',
allowDecimals: false,
reversed: true,
tickPositions: [1, 50, 100, 150, 200, 250, 300]
},
答案 1 :(得分:1)
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;
}
},
<强> DEMO 强>
修改强>
您可以在这些行中更改
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;
}
<强> DEMO 2 强>