A user reported an odd problem today. She was using Soundings, my ColdFusion survey application, and noticed something odd. She would do a report and the chart would be missing data! Here is an example:

This chart should have 9 items, even though some are blank, but we only see 5 labels. I did a quick google check and found out this was a known bug:
http://cfchart.blogspot.com/2005/06/charting-technote-addendum.html
Turns out that in earlier versions of CF, the labels were rotated, but a designer (darn designers!) decided that horizontal labels made more sense. I agree - but it would be nice if CF would automatically rotate them instead of just dropped them.
So I decided to make a quick XML file. From the URL above I saw that I needed to use this XML:
<xAxis>
<labelStyle isHideOverlapped="true" orientation="Horizontal"/>
<titleStyle font="Arial-12-bold" isMultiline="false"/>
</xAxis>
I didn't want to modify the core style files since that wouldn't be a solution for Soundings. According to the docs, you can use either an XML file or a string to specify style information. However, now matter what I did I couldn't get it to work. So I switched to an XML file using just the code above. This still didn't work. However, now I figured it was because I wasn't specifying a "full" style.
Now I was worried. I really did not want to specify 100 styles just to tweak one small little thing. I loaded up the WebCharts style editor. (Everyone knows about that, right? More info can be found here.) First - while this is a cool tool, I had trouble finding a "simple" bar chart. I made my best guess and took a look the XML. Turns out - the file was very simple. Even better, I was able to figure out why my XML above was missing. I changed it to this:
<?xml version="1.0" encoding="UTF-8"?>
<frameChart>
<xAxis>
<labelStyle isHideOverlapped="false" orientation="Vertical"/>
<titleStyle font="Arial-12-bold" isMultiline="false"/>
</xAxis>
</frameChart>
And that alone was enough to fix the problem. Here is the chart as it appears now:

As you can see, I lost the black borders and text, but to be honest it doesn't really bug me much.
Archived Comments
Ray,
If you use the Chart utility tool that is buried in CF you can do tons of things with charts.
Open CFusionMX7\lib\wc50.jar and create the chart you want. This utility lets you take "full" advantage of the Web Charts license. Unfortunately some of the chart types are not available. The utility will even write the xml code for you.
I did my own chart at http://www.clinfrastructure...
Hey Steve, I thought it was obvious - I _did_ use the tool. :) That's how I fixed my xml.
I got an error, it says Cannot locate gallery files in C:\CFusionMX7\lib\gallery ... I checked and I don't have that folder in either of my installations. Do you guys? Can I get it from somewhere?
This all just goes to show you how handy Moderate to Advanced information on creating Charts and Reports would be. I'm still trying to claw my way out of a wet paper bag. Such wonderful and powerful features, so little info.
True ...
Just out of curiosity, have you gotten webcharts to work? I created a blank direcotry called gallery and it got rid of the error, but now I go in and I can't load any charts ... hmmm ... help?
Okay, I figured it out ... I ran the .bat from \CFusionMX7\charting\webcharts.bat ... 1 word: WOW
Ray,
Sorry I missed the obvious, but most people don't even know the utility exists much less where to find it. What other poorly documented features are buried in CF7? Maybe the cookbook could have a category called EasterEggs...:)
Yeah Ray, I just found the charting utility recently, and tried it out, but I dont have a clue how to use it... It generates the xml, but how do you use that in your cf apps... Could you do a blog entry or cookbook article?
It may be the kind of thing that is a bit too detailed for the cookbook, but I'll consider it. As for using it - you just save the file (foo.xml), and in your cfchart, do style="foo.xml" (assuming it is in the same folder). If you download Soundings, you can see this in action. If you save the XML file with the built-in chart styles, you can use style="foo", but I wouldn't recommend that.
ahh, I see...
Thanks!
Is there a way I can give a developer access to the charting stuff without giving them access to the server? Or installing CF on their workstation?
I'm thinking you could install a developer edition. If you wanted to make sure they don't actually run CFM pages, you could disable the cf services.
Thanks Ray.
I went on a test run. Grabbed wc50.jar and the gallery folder, put them together in a folder on a workstation and just did java -jar wc50.jar and it seems to work just fine (even with Java 1.5!).
hi Raymond, i am kind of stuck in this chart xml,and need your help please,, my chart contains 4 lines one of them is the main line and the others are like baseline ,average..,the line width for all of this lines is the same ,but i want to have the main line thicker or the other lines thinner ,, is it doable ? thank you in advance..
In the chart editor, go to
Elements
Then go to Series.
In the upper left hand box, enter 0 for your first line, or whatever you want. Basically it's a 0 index system for your data. I entered 0 and hit add.
Then with 0 selected on the left, you can modify lineWidth and lineStroke. I noticed it was a bit slow to update when I clicked apply, so you may want to clicky-clicky to see it apply. But it does work.
thank you so much ,that helps.
I did get the chart styles to work as a string.
Take the XML for your chart style and save it as a variable using cfsavecontent. Then set the cfchart style to be that value.