CFCHART - How do I get the Y-Axis to start at 1 instead of 0

956 views Asked by At

Here is the example style I am using:

<?xml version="1.0" encoding="UTF-8"?>
<frameChart is3D="false">
      <frame xDepth="3" yDepth="1" leftAxisPlacement="Back" isHStripVisible="true">
           <background minColor="#FDFEF6"/>
      </frame>
      <yAxis scaleMin="1" scaleMax="500">
           <labelFormat pattern="#,##0.###"/>
           <parseFormat pattern="#,##0.###"/>
      </yAxis>
      <legend>
           <decoration style="None"/>
      </legend>
      <elements place="Default" shape="Line" drawShadow="true">
           <morph morph="Grow"/>
      </elements>
</frameChart>

The above code will show 0 instead of 1.

This seems to be a common problem using cfchart, but it appears to be a problem in the web charts program as well.

Does anyone have a good solution?

1

There are 1 answers

0
Leigh On BEST ANSWER

Short answer: It is possible, but there are some side effects in your specific case.

Longer answer: You can force the y-axis to start at 1 by specifying the number of labels (ie grid lines). But as long the range is an odd number (ie 500 - 1 ==> 499) some of the y-axis values may not line up evenly.

<!--- labelCount is number of grid lines + 1 --->
<yAxis scaleMin="1" scaleMax="500" labelCount="6">
    <labelFormat style="Integer" pattern="#,##0"/>
</yAxis>

That is because y-axis values are calculated by dividing the scale range by the number of grid lines. With odd ranges that typically produces fractional numbers. For example, if you generated five (5) grid lines, the axis values would be:

Actual   => Rounded Value
500.0    => 500
400.2    => 400
300.4    => 300
200.6    => 201  **
100.8    => 101  **
  1.0    => 1

The only way to have complete control over all y-axis values is to ensure the range / grid lines works out to a whole number.