View Full Version : function to analyze store data then feed it to pie chart

4 Sep 2012, 3:10 PM
Hi everyone, so I have a store:

Ext.define('AM.store.Users', {
extend: 'Ext.data.Store',
model: 'AM.model.User',
data: [
{Name: 'derp', Grade: 'FR'},
{Name: 'herp', Grade: 'SR'},
{Name: 'beavis', Grade: 'SR'}

And a chart:

Ext.define('AM.view.user.Chart' , {
extend: 'Ext.chart.Chart',
alias: 'widget.userchart',
...(basic config stuff)...
series: [{
type: 'pie',
//categoryField: 'Level',
angleField: 'Level',
showInLegend: true,
//put functions here to analyze store?

I want the pie chart to show the grade-level distribution in my store. Do I have to write functions that analyze the store and pass new values to the pi chart? If so, where would I stick those functions in MVC architecture? Sorry if this question is too broad, I'm a beginner in extjs

5 Sep 2012, 11:05 AM
I am not sure I understand your request ...

Are you asking how to create calculated fields?

If you need to create functions, you can create an 'class' and include it in your app as needed.

7 Sep 2012, 1:12 PM
Thanks for the response scott, sorry my question was so unclear.

Basically I have a store with a groupField and I would like to display those groups in a pie chart. So the group field would be the grade level and the chart would show the relative amounts of students in each grade. I don't know if there is an easy way to display fieldGroups in pie charts or if I have to calculate new fields that count up the number of entries with FR as their grade and so forth