在Flex中,如何从数据提供者创建摘要(比如各种域的总数)并在图表中显示?
说这是我的数据提供者..我想在饼图中显示每个区域的总估计值
private var dpFlat:ArrayCollection = new ArrayCollection([
{Region:"Southwest", Territory:"Arizona",
Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000},
{Region:"Southwest", Territory:"Arizona",
Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000},
{Region:"Southwest", Territory:"Central California",
Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},
{Region:"Southwest", Territory:"Nevada",
Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},
{Region:"Southwest", Territory:"Northern California",
Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000},
{Region:"Southwest", Territory:"Northern California",
Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000},
{Region:"Southwest", Territory:"Southern California",
Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000},
{Region:"Southwest", Territory:"Southern California",
Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000}
]);
答案 0 :(得分:0)
之后
<mx:Script...
试试这段代码:
<mx:AdvancedDataGrid id="dataGrid" initialize="gc.refresh();"
borderColor="#000000"
selectionMode="singleRow"
rowCount="8"
editable="false"
right="10" left="10" top="10" bottom="71"
itemClick="adg_itemClick(event);">
<mx:dataProvider>
<mx:GroupingCollection id="gc" source="{dpFlat}">
<mx:grouping>
<mx:Grouping>
<mx:GroupingField name="Region">
<mx:summaries>
<mx:SummaryRow summaryPlacement="group">
<mx:fields>
<mx:SummaryField dataField="Actual"
operation="SUM"/>
<mx:SummaryField dataField="Estimate"
operation="SUM"/>
</mx:fields>
</mx:SummaryRow>
</mx:summaries>
</mx:GroupingField>
<mx:GroupingField name="Territory">
<mx:SummaryRow summaryPlacement="group">
<mx:fields>
<mx:SummaryField dataField="Actual"
operation="SUM" />
<mx:SummaryField dataField="Estimate"
operation="SUM"/>
</mx:fields>
</mx:SummaryRow>
</mx:GroupingField>
</mx:Grouping>
</mx:grouping>
</mx:GroupingCollection>
</mx:dataProvider>
<mx:columns>
<mx:AdvancedDataGridColumn headerText="Region" dataField="Region" />
<mx:AdvancedDataGridColumn headerText="Territory" dataField="Territory" />
<mx:AdvancedDataGridColumn headerText="Territory_Rep" dataField="Territory_Rep" />
<mx:AdvancedDataGridColumn headerText="Actual" dataField="Actual" />
<mx:AdvancedDataGridColumn headerText="Estimate" dataField="Estimate" />
</mx:columns>
</mx:AdvancedDataGrid>