Adding Percentages To A Chart Created With ColdFusion
My boss wanted me to add percentages to a chart I built using ColdFusion. I researched the CF cfchart and cfchartseries tags in the CF documentation online to see if there was some way to get CF to do this for me. I didn't find any attributes that did that. So I spent a couple of hours adding code to do the math for me and display the percentages as part of each bars label. Later I learned I wasted my time!
Then my boss wanted me to create a pie chart that was using gray scales with patterns instead of colors. Again, I researched the CF chart tags to see how to do that. I found an attribute for the cfchartseries tag called "datalabelstyle" which has a description that reads "Specifies the way in which the color is applied to the item in the series:" Thinking this might be the attribute I need, I keep reading the description and find out that this inappropriately named and described attribute is actually the one I needed to get percentages to appear next to each bar (or pie slice) on my chart. One of the values for this attribute is pattern. Pattern will cause the chart to display "combination of column label, value, and aggregate information, such as columnLabel value for the percentage of total graph; for example, Sales 55,000 20% of 277,000" for each bar or pie slice.
Sure enough, after I added datalabelstyle = "pattern" to my cfchartseries tags the percentages appeared. I initially passed this attribute by when looking for the solution to getting percentages to appear because of the first part of the attribute's description: "Specifies the way in which the color is applied to the item in the series:" If the documentation had been better written, I could have saved myself a couple of hours of work.
Yes, I've posted a comment to the documentation.
Reference: CFMX 7 CFML Reference, cfchartseries

I have been looking for this solution for such a long time and I couldn't believe it wasn't easy to implement.
This is great info. This will make my charts much easier to read.
Keep up the good work!
Any help is greatly appreciated.
-Alfio