javascript - can you call a function while loading data in D3 js -
i trying figure out if there way can call function while loading data in d3.js. code below, not sure if on right track, seems simple cant work
d3.json("country_data.json", mac.call(country_data)); function mac(e) { //i function perform operations. //the data in file country_data passed function }
if had ideas on how can implement appreciate it, thanks.
your code passing result of calling mac()
should passing reference mac
so...
d3.json("country_data.json", mac); function mac(error, countrydata) { if (error) { // deal error } else { // perform operations on countrydata } }
or declare callback anonymous function inline call d3.json:
d3.json("country_data.json", function (error, countrydata) { if (error) { // deal error } else { // perform operations on countrydata } });
Comments
Post a Comment