macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

Histogram

Subject: Histogram
From: "Kulp"
Date: Thu, 23 Aug 2007 17:07:23 +0000 UTC
Newsgroups: macromedia.coldfusion.cfml_general_discussion
Hello Coldfusion people

 I am asking you for help in creating a histogram in coldfusion. I have tried 
several things but have run into a brick wall each time hampered by my lack of 
knowledge of coldfusion. How have you done histograms for your web sites? Are 
you using special software? Is there special statistical software available for 
purchase like a SPSS lite version?

 I am trying to create histograms in Coldfusion. The end result should be 
ambulance response times based on 60 second increments.  I have tried four 
approaches.
 1.) create the histogram in Crystal Reports and then use the cfreport tab to 
make it work. I have concluded this does not work.
 2.) using cflib histogram javascript. I have concluded I don't have the 
expertise to make this work. Please note: I am a Coldfusion newbie. This is a 
shame too because cflib.org is a goldmine of information for other mathematical 
things I want to do using statistics. The author of the script is unavailable.
 3.) I have downloaded Webtrends 3D but I was not able to make it work. I might 
recommend to my boss that we purchase it.  But I would have to make it work 
before we spend $3,000.
 4.) I have rigged the following code to approximate a histogram. And in a 
fashion it does work, but really not very well. 

 The following is my code for how I am currently doing it. But it is unwieldy. 
It is more like a bar graph and the X axis sorts like text (1, 10, 11,12, 13, 2 
etc) as opposed to sorting as numbers (1, 2,3,4,5,6, etc).

 ********************************************************
  <!---Module 3 - creates a graph for the response time for individual EMT--->
   <cfquery name="qryResponseTimeParamedic" datasource="emsCAD" username="sa" 
password="sa">
 SELECT IIU_IncidentUnitSummary_PK, 
 IIU_kIncident, 
 IIU_kUnit, IIU_kOfficer1, 
 IIU_kOfficer2, 
 IIU_kDisposition, 
 IIU_tDispatch, 
 IIU_tEnroute, 
 IIU_tArrive, 
 IIU_tEnrouteHospital, 
 IIU_tArriveHospital, 
 IIU_tClear, 
 I_Incident_PK, 
 ITI_TypeText, 
 <!---create a CASE statement to show if ResponseTime is late or on time. Bin 
them into groups of one minute intervals--->
 CASE 
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)<=59 THEN '0'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 60 and 120 THEN '1'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 121 and 180 THEN '2'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 181 and 240 THEN '3'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 241 and 300 THEN '4'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 301 and 360 THEN '5'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 361 and 420 THEN '6'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 421 and 480 THEN '7'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 481 and 540 THEN '8'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 541 and 600 THEN '9'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 601 and 660 THEN '_10'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 661 and 720 THEN '_11'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 721 and 780 THEN '_12'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 840 and 900 THEN '_13'
 WHEN DATEDIFF("S",IIU_tDispatch, IIU_tArrive)between 901 and 960 THEN '_14'
 ELSE '_15up'
 END 
 AS OnTime_EMT
 FROM dbo.IIncidentUnitSummary LEFT JOIN dbo.IIncident ON 
IIU_kIncident=I_Incident_PK
 INNER JOIN dbo.ITypeInfo ON I_kTypeInfo=ITI_TypeInfo_PK
 WHERE I_Agency='#EMSAgencyName#' 
 AND IIU_tDispatch BETWEEN '#FORM.Personnel_Start_dtm#' AND 
'#FORM.Personnel_End_dtm# 23:59'
 AND ((#form.POF_Officer_PK# = IIU_kOfficer1) OR (#form.POF_Officer_PK# = 
IIU_kOfficer2))
 AND I_kTypeinfo not in (#ComplaintReportedbyDispatch#)
 AND IIU_tArrive IS NOT NULL
 AND IIU_tDispatch IS NOT NULL
 ORDER BY IIU_kIncident ASC
 </cfquery>
 <!---this subquery counts the number of time brackets from the previous query 
and aggregates them together--->
 <cfquery name="qryCountResponseTimeParamedic" dbtype="query">
 SELECT OnTime_EMT, COUNT(OnTime_EMT) AS CountOnTime_EMT
 FROM qryResponseTimeParamedic
 GROUP BY OnTime_EMT
 </cfquery>
 <!---Create a series of charts to compare the medic to the organization as a 
whole--->
 <cfchart format="flash" chartheight="250" chartwidth="900" showxgridlines="no" 
showygridlines="no" seriesplacement="cluster" showborder="yes" fontbold="no" 
fontitalic="no" labelformat="number" xaxistitle="Minutes of Response Time" 
yaxistitle="Number of Calls" show3d="yes" rotated="no" sortxaxis="no" 
showlegend="no" showmarkers="no" title="Response Time for 
#qryShowOfficerName.POF_OfficerName#" backgroundcolor="##CCCCCC">
 <!---create a chart series for the individual EMT--->
 <cfchartseries type="bar" query="qryCountResponseTimeParamedic" 
itemcolumn="OnTime_EMT" valuecolumn="CountOnTime_EMT" 
 serieslabel="OnTime_EMT" seriescolor="##0033FF" paintstyle="light" 
markerstyle="snow">
 </cfchartseries>
 </cfchart>
   <br />
   <br />
   


<Prev in Thread] Current Thread [Next in Thread>