I do not think so. But double check the documentation on that. However, you could always create your own function that wraps the cfchart tags. Then call that function from cfscript.
Mark Mongeau wrote:
I am building a component and want to do it in the CFscript style. Is there a cfscript version of cfchart, cfshartseries, cfchartdata etc that can be accessed from CF script, or is it possible to acces the jars that provide this service in Cold Fusion from a user defined cfc?
It is possible to create a chart on Windows 7, with CF 9.0.1 and cfscript. Here is sample code(there have been many examples like it in the past in this forum):
serverComponent = createobject("java","com.gp.api.jsp.MxServerComponent");
chartDescription = createobject("java","com.gp.api.jsp.MxChartDescription");
myApplication = getPageContext().getServletContext();
serverInstance = serverComponent.getDefaultInstance(myApplication);
chartDescription = serverInstance.newImageSpec();
chartDescription.width = 400 ;
chartDescription.height= 300 ;
chartDescription.type = "PNG" ;
chartDescription.style = " <frameChart is3D='false'> <frame xDepth='3' yDepth='1' leftAxisPlacement='Back' isHStripVisible='true'> <background minColor='##FDFEF6'/> </frame> <xAxis> <labelFormat pattern='##,####0.######'/> <parseFormat pattern='##,####0.######'/> </xAxis> <legend> <decoration style='None'/> </legend> <elements place='Default' shape='Curve' drawShadow='true'> <morph morph='Grow'/> </elements> </frameChart>" ;
myChart.model = "<?xml version='1.0' encoding='UTF-8'?><XML type='default'><COL>2000</COL><COL>2001</COL><COL>2002</COL><COL>2003</COL><COL>2004</COL ><COL>2005</COL><ROW col0='100.0' col1='200.0' col2='100.0' col3='180.0' col4='200.0' col5='400.0'>Income</ROW><ROW col0='150.0' col1='300.0' col2='250.0' col3='230.0' col4='250.0' col5='450.0'>Expense</ROW></XML>";
You might ask, where does the code come from. From a sample in the webCharts engine that ships with ColdFusion.
To see this open the directory 'charting' in the ColdFusion installation directory. The webcharts engine comes with a Designer. It helps you to design a chart, without writing any code. You can then simply copy the code that the designer used to generate your sample chart. Neat, heh?
Double-click on webcharts.bat to start the webcharts designer. You will get a user interface showing a Chart Gallery. These are prefabricated chart samples. I will use one such sample to illustrate this approach.
On the list to the left, click to choose, for example, '3D Line, Curve, Step,...'. Images of the appropriate chart sample should appear. Click on the second image (the one showing 2 smooth, wavy curves). Press OK.
You will now get all the details for that type of chart. Below, left, are tabs showing you the Design, Style, Model and code used to generate the chart. The code is in JSP. If you translate it to CFML, you will get the code I have given above.
Awesome - Thanks.
Something I've just noticed. When I ran similar code, it kept giving me a red cross, telling me the image had expired.
I searched further and found the following solution. Apparently, ColdFusion's default timeout setting for keeping chart images in the cache is too small.
To correct this, go to ColdFusion's lib directory. Open the file webCharts3D.xml in a text editor. Change the value of minTimeout from 5 seconds to, say, 30 seconds. That is, change from minTimeout="5000" to minTimeout="30000". Restart ColdFusion.