Ask a Jedi: CFCHART and Scaling to Decimal Points

This post is more than 2 years old.

A reader wrote in with an interesting problem. He needed to use CFCHART to plot data points that ranged in value from 0.9 to 1.0. He wanted to use the scaleFrom and scaleTo attributes to limit the chart to this range, but no matter what he did, the chart would range from 0 to 1.

Looking at the docs for cfchart, it does say that both scaleTo and scaleFrom are integers, so I guess it isn't too surprising that it would fail to recognize 0.9 and 1 as a scale. You can try to use 0.9 but it is simply ignored. Here is a chart showing how this data plots out.

Not very nice, is it? As always, I turned to the chart designer. I quickly found the scaling options and tried 0.9 and 1.0 there. I was surprised to see that it worked right away. While there, I tweaked the xAxis labels to be vertical and turned off the legend. Here is the XML I ended up with:

<?xml version="1.0" encoding="UTF-8"?> <frameChart is3D="false"> <yAxis scaleMin="0.9" scaleMax="1.0"> <labelFormat pattern="#,##0.###"/> <parseFormat pattern="#,##0.###"/> <groupStyle> <format pattern="#,##0.###"/> </groupStyle> </yAxis> <xAxis> <labelFormat pattern="#,##0.###"/> <parseFormat pattern="#,##0.###"/> <labelStyle orientation="Vertical"/> </xAxis> <legend allowSpan="true" equalCols="false" isVisible="false" halign="Right" isMultiline="true"> <decoration style="None"/> </legend> </frameChart>

The result?

Much better, right? Not quite sure why cfchart doesn't like the numeric scale values. The charting engine works wonderfully with it. Anyway, I've attached a test file you can download and run to see it yourself.

Download attached file.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Neil Bailey posted on 3/30/2009 at 9:41 PM


CFChart is nice for an native CF charting package, but we made the move to BD.Net (precursor to moving to an entirely .NET platform), and the BD CFChart tag doesn't support the style attribute.

We looked at the Dundas charting package, and I have to tell you, I was both impressed beyond belief and amazed at exactly how lacking the CFChart tag is (but we never knew it).

I don't know how compatible some of the 3rd party charting packages are w/ an Adobe CF install, but it might be worth looking into for someone who needs high quality charts, and has some requirements that aren't easily supported in the CF package.

Comment 2 by Raymond Camden posted on 3/30/2009 at 9:45 PM

Keep in mind that CFCHART's main limitations are simply due to the tag based nature of it's implementation. There is a HECK of a lot you can do if you switch to the XML style. I can't blame Adobe for having to limit what the tags by themselves can do.

As it stands, I'm doing a CF Charting preso for CFUNITED this year. I plan on reviewing different options out there that work well with CF.

Comment 3 by Sean posted on 4/20/2009 at 5:30 AM

Hi Ray, question. What if I wanted to limit the scale from .85 to .89 the Min/Max doesn't work then. I have a chart with 10 bars ranging from 1,000 to 200,000. If I change the scaleMin to 100,000 and scaleMax to 200,000 the chart utility ignores the request and the scale is automatically adjusted to display the bar with 1,000 value. Thanks.

Comment 4 by Raymond Camden posted on 4/20/2009 at 5:32 AM

Isn't that expected though? Your data is outside your scaleMin.

Comment 5 by Matt posted on 9/30/2009 at 1:48 AM

Hi Ray,

Your post was a great deal of help. Thanks for the style to get this detailed decimal scale (I've changed to scaleMin="0.95" scaleMax="1.05"). I have ran into another problem however. All the values of the data I'm charting = "1" in one of the particular case I'm charting and ignores the new scale. I've tried setting the autoAdjust="no" in the frameChart tag but still no dice. Have you ever seen this before? To recreate... You can get the same effect if you take the example you provide and change all the values of the query you are building (column YValue) equal to 1. The scale you set gets ignored.

Comment 6 by Raymond Camden posted on 10/1/2009 at 5:31 AM

I modified the XML to

<yAxis scaleMin="0.9" scaleMax="1.6">

and it worked fine. Did you try that? Or another number?

Comment 7 by Matt posted on 10/1/2009 at 7:46 AM

Hi Ray, I probably didn't explain my problem well enough. Right now your example file has these values set for the YValue "0.974325, 0.9533125, 0.95923728814, 0.971375, 0.96545098039, 0.96577966102, 0.9803, 0.96824074074, 0.95381818182, 0.97077777778, 0.95945454545, 0.94502631579" if you happened to change these values for YValue to "1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1" (excuse the list representation of the change but I'm trying to be brief). After changing the YValues all to "1" the yAxis scaleMin="0.9" is ignored. :( What gives? Have you ever seen this before and might know how to get around this. This is my last effort, I've played around with the WebCharts3d designer too long. Thanks again for your help.

Comment 8 by Raymond Camden posted on 10/1/2009 at 3:41 PM

I did change my values to 1, but I didn't bother trying to fix the _first_ chart, only the second chart, and it worked fine. Did you try that?

Comment 9 by Matt posted on 10/1/2009 at 6:34 PM

Is there a possibility that with our installs of CF that the webcharts3d charting engine is different? When I change all the values to “1” the yAxis scaleMin attribute is completely ignored and is 0 instead. However the yAxis scaleMax attribute stays correct. I have had some other people test this as well and none of us have been able to get any thing to work. Hmm? Thanks for your help again. I think I might just throw the towel in and go with just displaying the values in a table.

Comment 10 by Raymond Camden posted on 10/2/2009 at 3:26 AM

Well heck - you are right. I didn't notice the _bottom_ one had reset to 0. I had just tweaked the _top_ one, which did work.

Ugh. :) Well, there are definitely other charting options out there if this is a deal breaker for you. :)

Comment 11 by Matt posted on 10/5/2009 at 8:23 PM

Hi Ray, Do you have recommendations on other charting packages (if you are able to comment on it). I have a love hate relationship with the webcharts3d. Its so simple, but then you try to get it to do what you want and it just won't let me at times. Thanks!

Comment 12 by Raymond Camden posted on 10/6/2009 at 9:27 AM

Check my preso on charting in CF - I mention a few other packages.