Highcharts - specifying order of stacked time seri

2019-06-22 13:55发布

Is there a way to specify the stacking order of time series in Highcharts?

2条回答
ら.Afraid
2楼-- · 2019-06-22 14:34

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});
  });
});
查看更多
做自己的国王
3楼-- · 2019-06-22 14:44

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.

查看更多
登录 后发表回答