PDA

View Full Version : Chart with grouped Store



siggi
9 Jan 2013, 6:32 AM
Hi,

is there a possibility to reflect a grouped store in a chart, e.g. have a series for each store group?

alex9311
9 Jan 2013, 3:27 PM
I went through this a while ago. I ended up making a new store out of my original store which had the group name and number in that group as field. I had a store called 'Chart' and grouped it by its 'level' field. Here is the code I used to create the store.


createStore:function(){
var store = Ext.data.StoreManager.lookup('Chart');
store.group('level');
var groups = store.getGroups();
// create new store basing on groups array
var groupStore = Ext.create('Ext.data.Store', {
model: 'C.model.GroupChart',
fields: [{
name:'level', mapping: 'name'
}, {
name: 'total', convert: function(value, record){
return record.raw.children.length;
}
}],
data: groups
});
return groupStore;
},