Highcharts - specifying order of stacked time series

柔情痞子 提交于 2019-12-12 11:14:37

问题


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});
  });
});


来源:https://stackoverflow.com/questions/11725570/highcharts-specifying-order-of-stacked-time-series

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!