PDA

View Full Version : chart !is it abug?



yanasdf789
6 Jul 2010, 3:30 AM
when i make a chart ..
why is failed like this :
series:new Ext.chart.ColumnSeries({
type: 'column',
displayName: 'total',
yField: 'total',
style: {
//image:'bar.gif',
// mode: 'stretch',
color:0x3366CC
}})

but is successful like this
series:[
{
type: 'line',
displayName: '????',
yField: 'total',
style: {
// image:'bar.gif',
// mode: 'stretch',
color:0x3366CC
}
}

whis the differrent?
how do i use the Ext.chart.ColumnSeries?

BitPoet
6 Jul 2010, 4:32 AM
In the first case you are assigning a single object to the series property, while in the second one you are assigning an array of objects. Thus the following should work too:


series: [
new Ext.chart.ColumnSeries({
type: 'column',
displayName: 'total',
yField: 'total',
style: {
//image:'bar.gif',
// mode: 'stretch',
color:0x3366CC
}
});
]
P.S.: Please wrap your code snippets in code tags in the future to retain the formatting, otherwise it becomes very hard to read.

Condor
6 Jul 2010, 4:33 AM
'series' needs to be an array, but in the first example it's only a single element.

yanasdf789
6 Jul 2010, 5:12 PM
thank you for reply!!
i would like to know how to Customise the series of chart?
my code like this :
var chartseries2=new Array();
for (var i=0;i<depart.length;i++)
{
chartseries2[i]={type:'column',displayName: depart[i]['name],
yField: depart[i]['name']}
}

var ser=new Ext.chart.Series(chartseries2);
Ext.getCmp('chart_success').series=ser; //'chart_success' is my chart
Ext.getCmp('chart_success').bindStore(shiyanstore2); //shiyanstore2 is my store of chart

what's wrong with code ?

Condor
6 Jul 2010, 10:42 PM
That should be:

var chartseries2 = [];
for (var i=0; i < depart.length; i++) {
chartseries2.push(new Ext.chart.Series({
type: 'column',
displayName: depart[i].name,
yField: depart[i].name
}));
}
Ext.getCmp('chart_success').series = chartseries2;
Ext.getCmp('chart_success').bindStore(shiyanstore2);
(I'm not sure if you can actually change the series of an existing chart this way)