开发者

Adobe Flex - Doing group by at Client end ( DataGrid to Pie chart )

I am in a situation where user gets the cars data from the database based on the selection and displays it in datagrid like below ( for example)

Company      Model         Year        No

GM              Chevy         2010       10
GM              Chevy         2009       5
GM             Pontiac       2010       12
Honda          Civic         2009       12

and there will be a link next to datagrid to get Pie chart based on the data displays in the data grid . The pie graph should display grouping by company and the count . I mean for the above example that should give with two pie items , one for GM showing the number of vehicles ( in this case 3 ) and Honda showing the number of vehicles ( in this case 1 ).

I thought of getting it from the database by querying and grouping it .But here the problem is after getting the data above in the datagrid user can able to filter at client end ( By year or model ) and can say get graph . This time that should only display the graph for the data visible in Datagrid .Grouping on database for every operation is b开发者_开发问答ecoming expensive. Since we have already data available at client end , is there any way to group it at client ..?

Could some body please advise me how to implement this?


You can use this for example : your datagrid id is dgCars. And Piechart id is chartCars.

Than you can use : chartCars.dataprovider = dgCars.dataProvider

what the above solution will do is. It will make data of the piechart bindable with that of datagrid.

Regards,

Ian


You could pass your a copy of your datasource to your charting component and the settings for which to filter your datasource copy.

The grid would build the settings that the charting component should use and feed it with the copy of the datasource and the grid would filter the datasource according to the settings.

Ex:

{year: 2010
make: 'Honda'}

would make your datasource filtered on cars for which their year property is 2010 and their make is 'Honda'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜