« Pie chart spacing problem for small values in CFCHART | Main | Switching your Subversion working directories to another server »

Solution for label collisions in ColdFusion pie charts

Hareni Venkatramanan of Adobe commented on my previous posting about an issue with how ColdFusion 7 and 8 display labels for small values in pie charts, saying that there was a solution posted for this issue in the 7.0.1 Updater. Indeed there is-- but the solution isn't applied automatically via the updater. Instead, you have to edit the XML files that define your chart styles. Read on to see what the new chart looks like and to find out how to edit the XML file.

The problem with pie charts happens when two adjacent wedges are really small-- so small that their value labels overlay one another instead of staying separated. For instance, here's a real instance of one of the charts that appears on one of our calculators at work:

cfchart-collision.gif

The fix for this issue, described in the Release Notes for the ColdFusion MX 7 Updater mentioned above, involves opening up the XML-formatted styles that the ColdFusion server uses to format these charts. Here's what you do:

  1. Open /charting/styles/ in your ColdFusion install directory (often C:\CFusionMX7 on Windows, or /opt/coldfusion_7 on *nix)
  2. In your preferred text editor, open the default_pie.xml file (or whichever files you use for pie charts, as specified by the style attribute of the cfchart tag)
  3. Change <dataLabels style="Value" placement="Outside" /> to <dataLabels style="Value" autocontrol="true" placement="outside" />

This should change the manner in the pie charts with small values are rendered. Now, when the wedges are too small, which the ColdFusion server moves the labels off some distance and connects them to the corresponding wedge with a line:

cfchart-nocollision.gif

This is definitely an improvement, although I have to admit that I like Google's connector lines juuust a little bit better, since they go horizontal at each end of the line. But at least Adobe did find a fix for this problem. I wonder why they didn't include the solution by default in CF8, though? They must have had some reason, but I don't know what it would be.

Post a comment