javascript - Add new series to the top of a highcharts stacked column chart -
i'm trying control order in new (after first render) series added stacked column chart in highcharts. right now, if use addseries, newly added series added bottom of stack. here's simplified version of i'm doing
var chart = new highcharts.chart({ chart: { type: 'column', renderto: 'container' }, xaxis: { categories: ['jan', 'feb', 'mar'] }, plotoptions: { series: { stacking: 'normal' } }, series: [{ name: 'base', data: [10, 20, 30] }, { name: 'sec', data: [30, 20, 10] }] }); var = 0; $('#add').on('click', function (e) { chart.addseries({ data: [32, 43, 42], name: ++i, index: 0 //?????? }); }); here's fiddle of this: http://jsfiddle.net/6bcbf/
any 1 can think of way reverse/control highcharts inserts new series?
i've tried setting index of new series 0, nothing. setting -1 adds new series bottom of array, 'stacking' not work properly
you can set index , zindex keep order between layers, add serie appropriate parameters.
example: http://jsfiddle.net/6bcbf/5/
var chart = new highcharts.chart({ chart: { type: 'column', renderto: 'container' }, xaxis: { categories: ['jan', 'feb', 'mar'] }, plotoptions: { series: { stacking: 'normal' } }, series: [ { name: 'base', data: [10, 20, 30], index:2, zindex:10 }, { name: 'sec', data: [30, 20, 10], index:1, zindex:9 } ] },function(chart){ $('#add').on('click', function (e) { chart.addseries({ data: [32, 43, 42], index: 0, zindex:1 }); }); });
Comments
Post a Comment