Search code examples
actionscript-3apache-flexflex4flex3flex4.5

how trigger when data provider of the flex chart changes?


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.


Solution

  • 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.