For this, i am using some data from various sources such as the US census, wikipedia and so on, to create a visualization of where presidents are born by population size, by median income by state. The data is not that important since, the object here is to show how to generate a visualization from some Excel data. The full sized example can be found here.
Hierarchical data is created from the 2 dimensional Excel data - it looks like this
The structure of the data is much like that used in Creating d3.js Tree diagrams, and will look like this.
This is used to scale the partitions. It is only necessary in the final child data, since each parent partition is scaled to be the sum of its childrens' sizes. Final child data looks like this. In this case the size represents the population of the given state.
The default colors for child and parent partitions are set through style options in the chart parameters, but in this case I wanted to use a color ramp to visualize the median income of each state. I used the Color ramp library to calculate appropriate coloring for each state, using various shades of green as defined by the "greendollar" entry. Here's an example formula for calculating the color.
Much of this is using code and parameters already covered in Color ramp library, Creating d3.js Tree diagrams, Developer information for d3.js force diagrams etc on this site. Specifically for this capability, here is the code required
You can download the example in the cdataset.xlsm workbook from the excel liberation site. The test data is in the d3zoompart worksheet and the options can be set in the d3treeparameters worksheet. Why not join our forum,follow the blog or follow me on twitter to ensure you get updates when they are available.
You want to learn Google Apps Script?
Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, available All formats are available now from O'Reilly,Amazon and all good bookshops. You can also read a preview on O'Reilly.
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > d3.js >