Lets say that we want to create a circular color ramp, as used in How to create a heatmap doughnut chart, as in the example shown on the right
This is actually 2 steps, using this data
Here is the snippet for that
' and the target colors based on the values For j = LBound(aColors, 2) To UBound(aColors, 2) For i = 1 To ds.rows.count aColors(i + 1, j) = _ rampLibraryRGB(colorRampName, mn, mx, ds.value(i, j), brighten) Next i ' for cycling - add the last color at beginning and first color at end aColors(1, j) = aColors(1 + ds.rows.count, j) aColors(2 + ds.rows.count, j) = aColors(2, j) Next j
Since each slice of the doughnut is now of equal size, (remember we are using color instead of size to show intensity), the color of each slice is calculated by its relative position along this circular scale, as per the snippet below
' dealing with this point o = (i - 1) * granularity + j + 1 ' note we are already half a granularity along with 1st point props = makeColorProps(colorRamp _ (1, (granularity * (ds.rows.count + 1)), o + granularity / 2, _ extractArrayItem(aColors, k)))
Here’s the complete code for the module that creates the chart.
For help and more information join our forum, follow the blog or follow me on twitter .
bruce mcpherson is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License. Based on a work at http://www.mcpher.com. Permissions beyond the scope of this license may be available at code use guidelines