cfchart ignores my scalefrom value
I have the following codes in my page.
The style variable holds the custom style.
<cfchart chartheight="450" chartwidth="550" gridlines="9" yaxistitle="Score" scalefrom="20" scaleto="100" style="#style#" format="p开发者_运维百科ng" >
<cfchartseries query="variables.chart_query" type="scatter" seriescolor="##000000" itemcolumn="MyItem" valuecolumn="MyScore"/>
</cfchart>
Before I begin, please see chart_good.jpg. This is how I want my report to come up. On the x-axis, there will always be three items as long as at least one of them has values. If an item does not have any values (i.e. 2010), there would not be a marker in the chart.
The problem occurs only when only one item has value. Please see chart_bad.jpg. As you can see, 2008 and 2010 do not have any values; y-axis is now scaled from 0 to 100. I have tried setting one of the items (ex. 2008) a value of 0 or something off the chart; it would scale according to this off-the-chart value and the 2009 value. In short, I have to have at least two items with values between 20 and 100 in order for cfchart to scale from 20 to 100.
My question is, how can I correct the issue so that cfchart would ALWAYS scale from 20 to 100? I am running CF9.
What is inside your style variable?
I would suggest not using scaleFrom="" and scaleTo="" in the cfchart tag as they can be buggy sometimes. I believe that Coldfusion's cfchart tag attempts to scale the chart automatically to what it deems the best fit. Instead I would build the chart's minimum and maximum scales inside a frameChart tag.
Example of a style variable to build a chart
<cfsavecontent variable="style">
<?xml version="1.0" encoding="UTF-8"?>
<frameChart is3D="false" font="Arial-11-bold">
<frame xDepth="0" yDepth="0" outline="black" lightColor="#CCCCCC" darkColor="#CCCCCC"
wallColor="#CCCCCC" frameSize="5" dashSize="3" gridColor="#333333">
<background type="HorizontalGradient" maxColor="#828EB0"/>
</frame>
<!--- THE BREAD AND BUTTER
NOTE: if you use variables for the scaleMin and scaleMax
make sure to surround them with a cfoutput tag
--->
<yAxis scaleMin="20" scaleMax="100">
<!--- --------------------- --->
<labelFormat style="Currency" pattern="#,##0"/>
<parseFormat pattern="#,##0"/>
<titleStyle></titleStyle>
</yAxis>
<legend allowSpan="true" isVisible="false" placement="Bottom" valign="Bottom" foreground="black"
isMultiline="true">
<decoration style="None"/>
</legend>
<elements outline="black" shapeSize="40"/>
<popup background="#748BA6" foreground="white"/>
<paint palette="Modern" paint="Plain" isVertical="true"/>
<insets right="5"/>
</frameChart>
</cfsavecontent>
Then all you have to do is load the variable into the style attribute like you already mentioned.
<cfchart format="png" chartWidth="550" chartHeight="175" style="#style#">
Also a great resource to use, is the Webcharts program that will be in your C:/coldfusion/charting/ directory. Just open webcharts.bat, create your custom chart, copy the xml code into your style variable, and voila!
Make sure to remove the scaleTo= and scaleFrom= from your cfchart tag if you decide to go this route.
精彩评论