Update Chart data as DataGrid being updated : DataGrid Data « Grid « Flex






Update Chart data as DataGrid being updated

Update Chart data as DataGrid being updated
       

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="initApp()">
  <mx:TraceTarget/>  
  <mx:Script>
    
      import mx.events.CollectionEvent;
      import mx.messaging.messages.AsyncMessage;
      import mx.messaging.events.MessageEvent;
      import mx.collections.ArrayCollection;
      [Bindable]
      private var myData:ArrayCollection = new ArrayCollection(
        [{name:"A", sales:5.00},
         {name:"B", sales:8.00},
         {name:"C", sales:2.00}]);
         
      private function initApp():void
      {
        myData.addEventListener(CollectionEvent.COLLECTION_CHANGE, syncClients);
      }
      private function syncClients(event:Event):void
      {
        myData.removeEventListener(CollectionEvent.COLLECTION_CHANGE, syncClients);

        myData.addEventListener(CollectionEvent.COLLECTION_CHANGE, syncClients);
      }
  
  </mx:Script>

  <mx:PieChart id="chart" dataProvider="{myData}">
    <mx:series>
      <mx:PieSeries field="sales"/>
    </mx:series>
  </mx:PieChart>
  
  <mx:DataGrid dataProvider="{myData}" editable="true" rowCount="{myData.length}">
    <mx:columns>
      <mx:DataGridColumn dataField="name" headerText="Product Name" editable="false"/>
      <mx:DataGridColumn dataField="sales" headerText="Sales"/>
    </mx:columns>
  </mx:DataGrid>
  
</mx:Application>

   
    
    
    
    
    
    
  








Related examples in the same category

1.Get data from DataGrid in drag enter eventGet data from DataGrid in drag enter event
2.Fill data from DataGrid to Form fieldsFill data from DataGrid to Form fields
3.Update data in DataGrid from Form fieldsUpdate data in DataGrid from Form fields
4.ArrayCollection used as the data source for DataGridArrayCollection used as the data source for DataGrid
5.Inline data provider for DataGridInline data provider for DataGrid
6.Passing data to a DataGrid controlPassing data to a DataGrid control
7.Get data from selected row in DataGridGet data from selected row in DataGrid
8.Get DataGrid data providerGet DataGrid data provider
9.Remove data from DataGridRemove data from DataGrid
10.Get the returning data from Php and feed it into DataGridGet the returning data from Php and feed it into DataGrid
11.Modifying data in a DataGrid controlThe following example lets you add, remove, or modify data in a DataGrid controlModifying data in a DataGrid controlThe following example lets you add, remove, or modify data in a DataGrid control
12.DataGrid data with Simple AttributesDataGrid data with Simple Attributes
13.DataGrid and DataGrid and <mx:ArrayCollection>
14.DataGrid with object array collectionDataGrid with object array collection
15.Define array with Array collection in ActionScript and use it for DataGridDefine array with Array collection in ActionScript and use it for DataGrid