NetCharts® Server: Example Report with Query for ColdFusion
This example uses CFQUERY to interact with a datasource, and uses the result of that query to populate a chart and a table.
The chart and table are defined inside a CF_NCSESSION which defines the server, port, project and query.
The data source, SupplierData is a sample ODBC data source that is installed with NetCharts Server. See the source code.

Source Code:
<!---
ReportWithCFQuery.cfm
Visual Mining, Inc.
This example uses CFQUERY to interact with a datasource, and uses the result of that query to populate a chart and a table.The chart and table are defined inside a CF_NCSESSION which defines the server, port, project and query.
The data source, SupplierData is a sample ODBC data source that is installed with NetCharts Server.
--->
<html>
<body>
<cfquery name="supplyQuery" datasource="SupplierData">
select LocationID, Location,
avg ("Part Price") as UnitPrice,
sum("Units Available") as Available,
sum("Inventory Value") as InventoryValue
from SupplierTable group by LocationID,Location
</cfquery><!--- insert javascript that supports displaying mouse-over labels on chart images --->
<cf_ncchartscript><!---
Start a session with NetCharts Server, using the Cold Fusion Examples project and the results of the database query
--->
<cf_ncsession project="Examples/ToolkitExamples" server="localhost" port="8001" query="supplyQuery">
<!---
Populate the chart with data from the result set.
The Bar data comes from columns 2,3,4 of all rows in the result set. The Bar Labels comes from column 0 of the result set. Use "Supplier Data" as the title for the chart Set fullpage=false bacause the necessary javascript has already been inserted by cf_ncchartscript
--->
<cf_ncchart chart="simplebar.cdx" fullPage="false">
<cf_ncchartdata type="Bars" rows="0*" columns="2-4">
<cf_ncchartdata type="Bar Labels" rows="0*" columns="0">
<cf_ncvariable name="THETITLE" value="Supplier Data">
</cf_ncchart>
<P>
<!---
Populate the table with data from the result set
--->
<cf_nctable table="suppliers.tbl">
<cf_nctabledata rows="0*" columns="0*">
<cf_ncvariable name="tableCaption" value="Supplier Data">
<cf_ncvariable name="tableStyleSheet" value="/NCSExamples/styles/defaultTableStyleRight.css">
</cf_nctable>
</cf_ncsession>
</body>
</html>
![]()



