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