PDA

View Full Version : add sum of record in graph title



jvidail
10 Feb 2010, 7:03 AM
Dear all,
I'm using the graph component and i want to display in the title graph the cum of record.
Can you help me


var RepCatStore = new Ext.data.JsonStore({
url: '../php/Affresults.php',
autoLoad: true,
baseParams:{act: "RepCat"},
root: 'data',
fields:[
{name: 'categorie', type: 'string'},
{name: 'nb_judokas', type: 'int'}]
});
new Ext.Panel({
title: 'Nb de judokas sur la compétition',
renderTo: 'RepCat',
width:500,
height:300,
layout:'fit',
items: {
xtype: 'columnchart',
store: RepCatStore,
xField: 'categorie',
yField: 'nb_judokas',
xAxis: new Ext.chart.CategoryAxis({
title: 'catégories'
}),
yAxis: new Ext.chart.NumericAxis({
title: 'nombre de judokas',
labelRenderer: Ext.util.Format.numberRenderer('0,0')
})
}
});

Thanks.

dlbjr
10 Feb 2010, 7:20 AM
function getFieldSum(store, fieldname){
var sum = 0;
store.each(function(r) {
try{
sum = sum + parseFloat(r.get(fieldname).toString());
}
catch (err) {

}
});
return sum
}


var sum = getFieldSum(ds,'fieldname');