PDA

View Full Version : Problem modifying existing series and axes in charts



texinio
3 Feb 2012, 5:20 AM
Hi everyone,

I have the following problem :

I am using one column series like this :



var chartCA = new Ext.chart.Chart({
store : storeListCA,
//height: 300,
autosize : true,
legend: {
position: {
portrait: 'left',
landscape: 'left'
}
},
axes: [{
type: 'Category',
position: 'bottom',
fields: ['TEXT']
},{
type: 'Numeric',
minimum: 0,
position: 'left',
fields: ['TOTAL','MONTANT01'],
minorTickSteps: 1
}],
series: [{
type: 'column',
highlight: {
size: 7,
radius: 7
},
smooth: true,
axis: 'left',
xField: 'TEXT',
title: ['Total1','Montant 1'],
yField: ['TOTAL','MONTANT01']
}
]
});

var chartPanel = new Ext.Panel ({
layout:'fit',
height: 300,
items: [
chartCAGlobal
]
});

var vue2Container = new Ext.Panel ({
id :'vue2Container',
items: [
chartPanel
]
});


I am trying to add Fields to my current serie and axe, like this way :



var yFields = new Array();
var titles = new Array();

yFields.push('MONTANT02');
titles.push('montant 2');

yFields.push('MONTANT03');
titles.push('montant 3');

yFields.push('MONTANT05');
titles.push('montant 5');

chartCA.axes.items[1].fields = yFields;
chartCA.axes.items[1].title = titles;
chartCA.series.items[0].yField = yFields;
chartCA.redraw();


But it doesn't work, and there isn't any javascript errors...

Anyone have an idea ?

mitchellsimoens
3 Feb 2012, 6:38 AM
If you need to change the series or axes, you should probably remove the chart and recreate it.

texinio
6 Feb 2012, 9:41 AM
I also tries this way, but I have the following error, when I try the call redraw() function on the chart :

Uncaught TypeError: Cannot call method 'getGroup' of undefined

I try with this portion of code :



chartPanel.add(
new Ext.chart.Chart({
store : storeListCAGlobalChart,
autosize: true,
width: 400,
height: 300,
legend: {
position: {
portrait: 'left',
landscape: 'left'
}
},
axes: [{
type: 'Category',
position: 'bottom',
fields: ['TEXT']
},{
type: 'Numeric',
minimum: 0,
position: 'left',
fields: yFields,
title: 'CA',
minorTickSteps: 1
}],
series: [{
id: 'chartSeries',
type: 'column',
smooth: true,
axis: 'left',
title: titles,
xField: 'TEXT',
yField: yFields
}
],
})
);

chartPanel.items.items[0].redraw();


For chartPanel, I created it with this code :



var chartPanel = new Ext.Panel ({
layout:'fit',
height: 300,
items: [ ]
});


I don't see where this error is coming from...

Thanks

texinio
15 Feb 2012, 9:29 AM
just to say that I finally did it :



chartCA.bindStore(storeListCA);
chartCA.axes.items[1].fields = yFields;
chartCA.axes.items[1].title = 'CA';
chartCA.series.items[0].yField = yFields;
chartCA.series.items[0].title = titles;
chartCA.refresh();
chartCA.reset();
chartCA.reset(); //It seems that sometimes i need 2 reset() to make it draw... strange :(