Pass function to a store config option
I'm returning a store in a function in this view file. I want to pass that store to the chart I'm defining as its store. Is this possible? Is there a workaround in MVC?
Here is my attempt:
Code:
Ext.define('C.view.chart.Chart' , {
extend: 'Ext.chart.Chart',
alias: 'widget.chartchart',
width: 500,
height: 600,
animate: true,
store: this.createStore(),
shadow: true,
legend: {
position: 'right'
},
insetPadding: 25,
series: [{
type: 'pie',
field: 'number',
showInLegend: true,
tips: {
trackMouse: true,
width: 140,
height: 28,
renderer: function(storeItem, item) {
//calculate percentage.
var total = 0;
chart.each(function(rec) {
total += rec.get('number');
});
this.setTitle(storeItem.get('level') + ': ' + Math.round(stor$
}
},
highlight: {
segment: {
margin: 20
}
},
label: {
field: 'level',
display: 'rotate',
contrast: true,
font: '18px Arial'
}
}],
createStore:function(){
var store = Ext.data.StoreManager.lookup('Chart');
store.group('grade');
var groups = store.getGroups();
// create new store basing on groups array
var groupStore = Ext.create('Ext.data.Store', {
fields: [{
name:'grade', mapping: 'name'
}, {
name: 'total', convert: function(value, record){
return record.raw.children.length;
}
}],
data: groups
});
return groupStore;
}
});
I have a store "Chart.js" with fields name and grade. My new store has the fields name (of the grade) and total (total students in that grade)