我可以在初始选项对象中设置这些值,一切正常。如果我稍后使用chart.options.yAxis.tickInterval更改选项,则在重绘yAxis时似乎会忽略它们。
// Global variables
var markInterval = undefined;
var minInterval = 0;
var maxInterval = undefined;
chart = new Highcharts.Chart({
// ...
yAxis: {
title: {
text: 'Mark'
},
labels: {
formatter: function() {
// html formatting
},
useHTML: true
},
tickInterval: markInterval,
min: minInterval,
max: maxInterval
},
plotOptions: {
series: {
events: {
legendItemClick: function(event) {
// setTickIntervals(); Change the global values markInterval, minInterval and maxInterval
chart.options.yAxis.tickInterval = markInterval;
chart.options.yAxis.min = minInterval;
chart.options.yAxis.max = maxInterval;
chart.redraw();
}
}
}
}
});
答案 0 :(得分:10)
我错误地设置了新值,例如:
chart.options.yAxis.tickInterval = markInterval;
应该是
chart.yAxis[0].options.tickInterval = markInterval;
然后一切都按预期工作。