I have a map built in the Esri Javascript API.
This map has one layer within it, showing petrol stations.
As the extent of the map changes, I am running 4 separate queries against this layer to find out a count of the total petrol stations within the current extent, a query for each petrol station vendor.
e.g. (Somehat simplified)
//Shell
shellQuery.where = "brand = 'Shell"
//Execute Query, and report result to console
shellQueryTask.executeForCount(shellQuery , function(count){
console.log(count);}
//BP
same again. Repeats for 4 queries.
The results of each query are dojo.deferred.
However, as they are separate queries (needs to be this way for other reasons), they all return there results at slightly different times.
Final Goal - include a Dojo bar chart, that gets updated by these queries, to show a breakdown of the petrol stations in the current extent, based on vendor.
Being new to Javascript, let alone Dojo, I am scratching my head on the best way to update a dojo chart. Most the Esri samples I see are around displaying the results of one query, and do so by creating a new chart everytime.
I am looking for an answer that is the most elegant way of doing this.
Im currently thinking that I need to write the results of the 4 queries to a global data array and then call a separate function to update the dojo chart. Just a little concerned on ensuring that I dont call the function until all four queries have returned their results.