Is it possible to trigger when data provider of the flex chart changes ? Any ideas guys ? i used oncreation complete but it is not working when change data source of the chart dynamically.
how trigger when data provider of the flex chart changes?
205 Views Asked by Eranga Perera At
2
There are 2 best solutions below
1

If the dataProvider
is an ArrayCollection
you can add a listener to the dataProvider object collection itself:
dataProvider.addEventListener(CollectionEvent.COLLECTION_CHANGE,listernerFunction);
Notice that if you replace the entire dataProvider
object for example with the code
dataProvider = null;
dataProvider = new ArrayCollection();
You will not trigger the event and you have to add a new listener to the new object.
Otherwise you can add listener to the chart itself that will be trigger every time the data provider object is replaced but it will not be trigger when the the collection itself changes.
chart.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE,funct);
[..]
protected function funct( event:PropertyChangeEvent):void{
if(event.property=="dataProvider"){
//Your code
}
}
Try Changewatcher class.
Otherwise try this, Add collection change listener to chart itself like below.
Hope it helps.