score:0

Accepted answer

There seemed to be no documentation or other examples on the net on how to do this. So I experimented and found out that the index is set naturally by the order in which you add to the series array. So I could change my seed series to this:

            series: [
                {
                    name: 'Total', // The series you add first will get stacked on the top
                    data: randomRange(12, 233, 240),
                    stack: 'ProductType'
                }, {
                    name: 'My Products',
                    data: randomRange(12, 7, 61),
                    stack: 'ProductType'
                }
            ]

Then when I refresh the chart data with different options, I do this:

        $('#productType').on('change', function() {
            var chart1 = $('#quantityPerMonthChart1').highcharts();
            // These series already have an index (which affects stack order).  
            // Here it is unchanged.
            chart1.series[0].setData(randomRange(12, 233, 240), false);
            chart1.series[1].setData(randomRange(12, 7, 61), false);
            chart1.redraw();
        });

score:3

index is option of a series that can be update using Series.update() - it can be also used to update data of the series as data is another option.

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

Example: http://jsfiddle.net/ae7Ljmc7/


Related Query

More Query from same tag