Andrew C
Andrew C

Reputation: 699

Highcharts - specifying order of stacked time series

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

Upvotes: 5

Views: 2704

Answers (2)

arjary
arjary

Reputation: 169

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

Upvotes: 0

wergeld
wergeld

Reputation: 14462

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.

Upvotes: 7

Related Questions