PDA

View Full Version : Adding series dynamically



sandeepmnit35
25 Feb 2013, 4:28 AM
I am creating a chart and then adding the series through for loop as number of series will be different for each time.



RA.app.chart = new Ext.chart.Chart({
id: 'chart'+RA.app.currentActivePanelIndex,
store: store,
renderTo: Ext.getBody(),
flex: 1,
shadow: true,
autoShow: true,
animate: { duration: RA.app.animateSpeed, delay: 0, easing: 'ease' },
maxGutter: [10, 10],
legend: {
position: 'right',
},
axes: [
{
type: 'Numeric',
position: 'left',
fields:[RA.app.groupByValueBar[0],RA.app.groupByValueBar[1],RA.app.groupByValueBar[2],RA.app.groupByValueBar[3],"others"],
label: {
renderer: Ext.util.Format.numberRenderer('0,0'),
},
title: RA.app.ys[RA.app.currentActivePanelIndex],
minimum: 0,
maximum: RA.app.Ymax[RA.app.currentActivePanelIndex]
},
{
type: 'Category',
position: 'bottom',
fields: RA.app.xs[RA.app.currentActivePanelIndex],
title: RA.app.xs[RA.app.currentActivePanelIndex]
}
],

});


I am adding the series through add method like this:


for(i=0; i<4;i++)
{
var series = {
type: 'line',
axis: 'left',
//gutter: 80,
highlight: true,
xField: RA.app.xs[RA.app.currentActivePanelIndex],
yField: RA.app.groupByValueBar[i],
title: RA.app.groupByBarLabels[i]
};

RA.app.chart.add(series);
//RA.app.newChart[RA.app.currentActivePanelIndex].add(series);
}


It is giving me error that "
Uncaught TypeError: Object [object Object] has no method 'add"

Please let me know how can I add series dynamically.
Thanks

mitchellsimoens
26 Feb 2013, 4:48 PM
This currently is not supported but we do have a feature request for this. If you want to do this, you would have to remove the chart and add in a new chart with the new series.