简体   繁体   中英

Extjs 4: pie chart display groupField from store

I'm looking to create a pie chart that displays a group field from a store. For example, if each student in my store has a 'grade' field, I want the pie chart to show the relative amount of students in each grade. Is this possible? Or does the pie chart have to display a field My 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'}
    ],
    groupField: 'Grade',
 });

My attempt at a chart:

Ext.define('AM.view.user.Chart' , {
    extend: 'Ext.chart.Chart',
    alias: 'widget.userchart',
    width: 500,
    height: 600,
    animate: true,
    store: 'Users',
    shadow: true,
    legend: { position: 'right'},
    insetPadding: 25,
    series: [{
            type: 'pie',
            angleField: 'PreReq',
            showInLegend: true,
            highlight: {
                    segment: {
                            margin: 20
                    }
            }
            animate: true
    }]
});

thanks for any tips!

in your store you can use filtering, sorting and grouping which then reflects in your chart dyamically. you need to group your result into a series of data to present in a chart.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM