I have a really large dataset (about 500,000 records ...) about CO2 emissions in London that I want to display using maps and charts using crossfilter. For performance reasons, I want to make requests in advance in city blocks, so I made an ajax function that does this dynamically when I click on a city (just imagine a map of London with city boundaries where we can click on them). Ajax code works fine:
function load_data(str){ var londonData = null; $.ajax({ url: "php/london-data.php", data: "name='"+str+"'", type: 'get', async: false, success: function(data) { londonData = data; } }); alert(JSON.stringify(londonData)); return londonData;}
It returns a json file. When I click on a city, the warning function shows me that the data is updated. But to use crossfilter, I wanted to have a global variable that is updated when you click on the area, thanks to the load_data function, but it does not work - the variable retains the same value as during initialization.
I donβt know if I am enough, but do you think there is a solution to update this global variable and, as a result, update the cross-filter data? Sort of:
layer.on("click", function (e) { londonData = load_data() }); dataset = crossfilter(londonData);
In the end, I would like my charts to be updated when I click on a city, so the 'dataset' variable should change when I click on it. I do not know if this is possible, or if I am completely mistaken ... In any case, thanks for your help.
source share