Is there a way to specify the stacking order of time series in Highcharts?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The only way I have found is by ordering the series as they come in.
So, if I have series A, B, and C and I want it to be ordered by B, C, A
then I add the series in B, C, A
order such that series[0] = B, series[1] = C, and series[2] = A.
This is definitely a kludge because it would be nice to just sign a stacking index instead of resorting the series import order.
回答2:
You could assign an index to your series and then do series.update() to update the indexes. See below -
$(function() {
var chart = Highcharts.chart('container', {
chart: {
type: 'column'
},
plotOptions: {
series: {
stacking: 'normal'
}
},
series: [{
data: [1, 2, 3, 4, 5, 4],
index: 1
}, {
data: [6, 4, 5, 6, 7, 4],
index: 2,
id: 's2'
}]
});
$('#button').click(function() {
chart.get('s2').update({index: 0});
});
});