CFChart does not do trend lines of any type. However, it is not too difficult to compute the regression of your choice and to plot it as a second series.
Not sure what you are asking here. In theory, cfchart does do log-lin and log-log charts.
However, it is so buggy, and the scaling problems are so great, that we have never been able to get it to work well.
We use ChartDirector for anything that requires a log scale.
You cannot control these directly. Here are some workarounds:
- For "Category" axis:
- Make sure the "isBucketed" property is set to true (this is the
- If that is not enough, add extra bars to your data series,
usually value zero. It's not ideal but it may be good enough.
- Make sure the "isBucketed" property is set to true (this is the default).
- For "Scale" axis:
- Usually this works well enough. Otherwise, try toggling the
- The only other recourse is to manually scale the plot using the
"scaleMin" and "scaleMax" properties. This can be a real pain for
obvious reasons and also because cfchart scaling is fraught with
bugs and "quirks".
- Usually this works well enough. Otherwise, try toggling the "isAbsolute" property.
- For "Category" axis:
These work. Perhaps there was a setting conflict within the XML or between the CFChartSeries setting and the XML?
Also the cylinders will only look round when 3D is turned on. (Side view of a cylinder is just a shaded bar.)
Anyway, I've said it before: cfchart is barely usable for a very limited range of charts.
For real business or common engineering and scientific needs, you need to step up to something better.
The package we use (has all the features and very reasonably priced) is ChartDirector ( http://www.advsofteng.com/cdcoldfusion.html). (And, no, I'm not affiliated.)
- Trend Lines:
If you have CF7 installed, research "WebCharts3D" - it is a free package included with CF7. I'm not sure it will meet all of your needs, but it certainly is a step up from regular charts.
Thanks MikerRoo. It's just good to know I wasn't missing some "option" in WebCharts3D that helped control the margins. I'll try your suggestions. Sounds like you've had some experiene with WebCharts3D. And I know what you mean about the auto-scaling being flaky. Sometimes I'll set min/max options that don't make any sense, but the chart will come out looking just right. Then the next time you run it, it will be different. I've learned you just have to experiment, until you get something that seems to work consistently, as best as it can.
Still, the advances in chart capability in CF7 are light-years ahead of CF5. Everyone at work is VERY pleased with the new charts coming out of CF7. Many thanks again,
And thanks for the tip about ChartDirector. Sounds nice, but I've got to convince the company to spend $500 for it, plus $99 for the developer license (we'll be running it on Windows XP-Developer, and Windows 2000/2003 Server).
Again, many thanks for all the tips. Much appreciated.
In case anyone is looking, here's something simple I threw together for linear best fit:
<!--- The min setting is a preference based on how you want the data to be displayed. --->
<!---<cfset min = arrayMin(grabData["value"]) - 5>--->
<cfset min = 0>
<cfset max = ceiling(arrayMax(grabData["value"])) + 1>
<cfset n = grabData.recordCount>
<cfset sum_x = 0>
<cfset sum_x2 = 0>
<cfset sum_xy = 0>
<cfloop from="1" to="#grabData.RecordCount#" index="i">
<cfset sum_x = sum_x + i>
<cfset sum_xy = (i*grabData.value[i]) + sum_xy>
<cfset sum_x2 = sum_x2 + (i*i)>
<cfset sum_y = arraySum(grabData["value"])>
<cfset slope = round(((n*sum_xy) - (sum_x*sum_y))/((n*sum_x2) - (sum_x*sum_x)))>
<cfset intercept = round((sum_y - (slope*sum_x))/n)>
<cfset best_fit = QueryNew("id, value")>
<cfloop from="1" to="#grabdata.RecordCount#" index="i">
<cfset value = round((slope*i) + intercept)>
<cfset QuerySetCell(best_fit, "id", grabData.xlabel[i])>
<cfset QuerySetCell(best_fit, "value", value)>
<cfchart scalefrom="#min#" scaleto="#max#" title="#GrabDatapointInfo.label#" format="jpg" chartHeight="450" chartwidth="500" xaxistitle="Month/Year">
<cfchartseries type="line" query="best_fit" valuecolumn="value" itemcolumn="id"/>
<cfchartseries type="line" query="grabData" valuecolumn="value" itemcolumn="xlabel"/>