GrantMStevens / amCharts-Angular

Angular directive for amCharts library
Apache License 2.0
63 stars 39 forks source link

Reload data with ajax #80

Closed obidano closed 7 years ago

obidano commented 7 years ago

is there any option that can help us reload data like AmCharts.loadFile(....) in jquery ?

GrantMStevens commented 7 years ago

You're using Angular, why do you need jquery?

If you want to utilize AmCharts.loadFIle, you'll need to create your own async function that returns the data using a promise. Pseudo code:

this.parseCSVData = function(){
    var deferred = $q.defer();

    AmCharts.loadFile( "https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-160/22300.csv", {}, function( response ) {
      var data = AmCharts.parseCSV( response, {
          "useColumnNames": true
        });

      deferred.resolve(data);
    })

    return deferred.promise;
}

you can assign the execution of that function to options for the chart, which will delay its render till the promise resolves.