8.5 Census Map: Allowing for multiple charts

We now want to allow for the creation of multiple pie charts, rather than just one. In order to accomplish this, we will have the function dynamically create a new container DIV for every chart requested. We will then require two new parameters in the function: one for the name of the DIV container, and another for a title display.

Let’s get started and add a few more charts to our display. In this example, we are creating 3 pie charts:

  • Age: ['AGE_UNDER5', 'AGE_5_17', 'AGE_18_21', 'AGE_22_29', 'AGE_30_39', 'AGE_40_49', 'AGE_50_64', 'AGE_65_UP']
  • Housing: ['RENTER_OCC', 'OWNER_OCC', 'VACANT']

Inside the getAGSData function, modify the call to the drawChart function by creating arrays for each pie chart, and providing a name for each container DIV and a title for each chart (lines 29-34):

You should now see 3 charts in your display panel:

3 charts!

3 charts!

(sample code)

One thought on “8.5 Census Map: Allowing for multiple charts

  1. It would be helpful to change the instructions for the drawChart function modifications to also include note of the changes required in line 1 (adding div_id and title to the parameters), and in line 27 (replacing ‘chart’ with ‘div_id’).

Leave a Reply