![]() ![]() ![]() Introduction HanengCharts is Java applets that you use with your website by supplying the parameters (the values and labels) through HTML PARAM tags. This allows any technology that can generate HTML to work dynamically with HanengCharts. This whitepaper will give you some sample scripts and explanations on how you can use HanengCharts and ColdFusion to generate charts based on data stored in a database. ![]() ![]() ![]() Example 1: ColdFusion and MS Access In this sample script we will access an MS Access database with ColdFusion and then output the HTML needed for HanengCharts to display a pie chart based on the data. The script is tested on ColdFusion Express 4.5.1 for Windows. 1. Sample scripts: The sample scripts are located in the ColdFusion folder 2. Unzip the download and upload all files to your server It is important that the HanengCharts.cfm and HanengCharts3.jar is in the same directory. The HanengCharts_Database.mdb may be located in another directory. 3. Connect the database with ColdFusion Follow the steps below to connect HanengCharts_Database.mdb to ColdFusion. The name of items etc. may vary depening on the version of ColdFusion you are using.
Make sure that your ColdFusion server is running and that you run the file through a browser with the URL being: It should now show up like this: 5. The code for HanengCharts.cfm <CFQUERY NAME="Sales" DATASOURCE="HanengCharts"> SELECT * FROM Chart </CFQUERY> <HTML> <BODY> <CENTER> <APPLET CODE="HanengCharts.class" ARCHIVE="HanengCharts3.jar" WIDTH=460 HEIGHT=260> <PARAM NAME="LicenseKey" VALUE="DEMO-DTKTG2s3R8xNVzNVFxN"> <PARAM NAME="ChartType" VALUE="pie"> <CFLOOP QUERY="Sales"> <CFOUTPUT>"<</CFOUTPUT><CFOUTPUT>PARAM NAME="#ParameterName#" VALUE="#Value#"</CFOUTPUT><CFOUTPUT>"></CFOUTPUT> </CFLOOP> </APPLET> </CENTER> </BODY> </HTML> ![]() ![]() ![]() Example 2: ColdFusion and Oracle We got this script from one of our customers that use HanengCharts with ColdFusion and Oracle with great success. We have not been able to test it our selves yet. <cfquery datasource="Pie" username="Pie" password="Pie" name="Pie_region"> SELECT region, SUM(ROUND( <CFLOOP INDEX="ListElement" LIST=#sum_sales_list#> <CFOUTPUT> #ListElement# + </CFOUTPUT> </CFLOOP> 0)) total_sales FROM dwload.shoppers_report GROUP BY region </cfquery> <APPLET CODE="HanengCharts.class" ARCHIVE="HanengCharts3.jar" WIDTH=460 HEIGHT=260> <PARAM NAME="LicenseKey" VALUE="DEMO-DTKTG2s3R8xNVzNVFxN"> <PARAM NAME="ChartType" VALUE="pie"> <cfloop query="Pie_region"> <cfset c=incrementValue(c)> <cfoutput>"<</cfoutput><cfoutput>param name=value_#c# value="#Total_Sales#"</cfoutput><cfoutput>"></cfoutput> </cfloop> <cfset c=0> <cfloop query="Pie_region"> <cfset c=incrementValue(c)> <cfoutput>"<</cfoutput><cfoutput>param name=text_#c# value="#Region#"</cfoutput><cfoutput>"></cfoutput> </cfloop> </APPLET> |