문제

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.

도움이 되었습니까?

해결책

Try Changewatcher class.

import mx.binding.utils.ChangeWatcher;
import mx.events.PropertyChangeEvent;

ChangeWatcher.watch(this, "dataProvider", watchHandler);

private function watchHandler(e:PropertyChangeEvent):void
 {
                    // Do Something
 }

Otherwise try this, Add collection change listener to chart itself like below.

chart.addEventListener(CollectionEvent.COLLECTION_CHANGE, onChartDataProviderChange);

private function onChartDataProviderChange(e:CollectionEvent):void
     {
                        // Do Something
     }

if(condition1){
chart.dataprovider=provider1;
} 
if(condition2){
chart.dataprovider=provider2;
}

Hope it helps.

다른 팁

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
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top