2010-01-06 98 views
0

在Flex中,我如何從數據提供者創建一個摘要(比如說各種域的總和)並在圖表中顯示?使用數據提供者的摘要數據填充圖表

說這是我的dataProvider ..我想在餅圖顯示每個領土總估算爲切片

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

<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> 
+0

是的,它使用匯總數據填充advanceddatagrid ..但我可以使用相同的摘要來填充餅圖嗎?或者餅圖中是否有任何功能來創建類似於您提供的advanceddatagrid示例的摘要? – arunp 2010-01-07 11:49:28

+0

看看這個鏈接,你需要用datagrid總結來填充餅圖: http://livedocs.adobe.com/flex/3/html/help.html?content=advdatagrid_10.html – Franky 2010-01-07 13:43:09