Cloud Photo

Azure Data Architect | DBA

ColdFusion: Less Code, More Results

The primary reason why I prefer ColdFusion over other web app languages is the efficiency afforded in the programming stage. ColdFusion is a genuine Rapid Application Development (RAD) language. For example, to run a database query and draw a pie chart using the Google Chart API, takes about 20 lines of code and does not require additional libraries such as jQuery.

Here’s an image of the pie chart generated by the code below.

ColdFusion, Google Pie Chart
ColdFusion, Google Pie Chart


The following code is enough to generate a Google pie chart in ColdFusion.

<cfquery dbtype="query" name="qSelect_userPie">
select sum(totalMinutes) as tmin, ucase(dbUser) as dbUser from qSelect_userTime group by dbUser order by tmin desc, dbUser
<script type="text/javascript" src=""></script>
 <script type="text/javascript">
 google.load("visualization", "1", {packages:["corechart"]});
 function drawChart() {
 var data = google.visualization.arrayToDataTable([
 ['db', 'CPU Time'],
 <cfoutput query="qSelect_userPie">
 ['#dbuser#', #round(tmin)#]<cfif currentRow lt recordCount>,</cfif>
 var options = {
 title: 'DB CPU Activity Last 24 Hours',
 // colors: ['orange','green','blue','gray','black','gold']
 var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
 chart.draw(data, options);
<div id="chart_div" style="width: 500px; height: 300px;"></div>


Leave a Reply