Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

format y-axis in cfchart

Status
Not open for further replies.

cfdeveloper

Programmer
Nov 20, 2003
144
0
0
GB
The values displayed on the y-axis are are mix of float and int. The chart displays int values on the y-axis if I use only one cfchartseries tag. The code below calculates the value for the gridlines and scaleto attributes.

Code:
<cfset scTo=evaluate(ArrayMax(ListToArray(valuelist(qJobsLogged.JOBSCOUNT)))+1)>
When I output this variable, the value returned is 88 and when I execute the below code I get the following on the y-axis:

6 ,18, 30, 42, 54, 66, 78

Code:
<cfchart show3d="yes" gridlines="#evaluate(scTo+1)#" yaxistype="scale" 
labelformat="number" scalefrom="0" scaleto="#scTo#" format="jpg" 
xAxisTitle="log date" yAxisTitle="jobs logged" chartheight="300" chartwidth="450" sortxaxis="no" showborder="yes" 
showxgridlines="yes" showygridlines="yes" seriesplacement="stacked" font="Arial" fontsize="12" fontbold="yes"> 

<cfchartseries type="bar" serieslabel="Critical" query="qJobsLogged" itemcolumn="DTLOGGED" valuecolumn="JOBSCOUNT"> 
  <cfif qJobsLogged.jobPriority eq 1>   
    <cfchartdata item="#qJobsLogged.DTLOGGED#" value="#qJobsLogged.JOBCOUNT#"> 
  </cfif> 
</cfchartseries> 

</cfchart>

However, when I add 3 more chartseries tag to the above code, I get
27.7, 83, 138.4, 193.8, 249.1, 304.5

Code:
<cfset scTo=evaluate(ArrayMax(ListToArray(valuelist(qJobsLogged.JOBCOUNT)))+1)> 

<cfchart show3d="yes" gridlines="#evaluate(scTo+1)#" yaxistype="scale" 
labelformat="number" scalefrom="0" scaleto="#scTo#" format="jpg" 
xAxisTitle="log date" yAxisTitle="jobs logged" chartheight="300" chartwidth="450" sortxaxis="no" showborder="yes" 
showxgridlines="yes" showygridlines="yes" seriesplacement="stacked" font="Arial" fontsize="12" fontbold="yes"> 

<cfchartseries type="bar" serieslabel="Critical" query="qJobsLogged" itemcolumn="DTLOGGED" valuecolumn="JOBSCOUNT"> 
  <cfif qJobsLogged.jobPriority eq 1>   
    <cfchartdata item="#qJobsLogged.DTLOGGED#" value="#qJobsLogged.JOBCOUNT#"> 
  </cfif> 
</cfchartseries> 

<cfchartseries type="bar" serieslabel="Urgent" query="qJobsLogged" itemcolumn="DTLOGGED" valuecolumn="JOBCOUNT"> 
  <cfif qJobsLogged.jobPriority eq 2>   
    <cfchartdata item="#qJobsLogged.DTLOGGED#" value="#qJobsLogged.JOBCOUNT#"> 
  </cfif> 
</cfchartseries> 

<cfchartseries type="bar" serieslabel="Normal" query="qJobsLogged" itemcolumn="DTLOGGED" valuecolumn="JOBCOUNT"> 
  <cfif qJobsLogged.jobPriority eq 3>   
    <cfchartdata item="#qJobsLogged.DTLOGGED#" value="#qJobsLogged.JOBCOUNT#"> 
  </cfif> 
</cfchartseries> 

<cfchartseries type="bar" serieslabel="Other" query="qJobsLogged" itemcolumn="DTLOGGED" valuecolumn="JOBCOUNT"> 
  <cfif qJobsLogged.jobPriority gt 3>   
    <cfchartdata item="#qJobsLogged.DTLOGGED#" value="#qJobsLogged.JOBCOUNT#"> 
  </cfif> 
</cfchartseries> 

</cfchart>

Can any mathematician help please

Regards
cfcoder
 
why are you plotting individual points with <cfchartdata ...> ?
this should be enough
<cfchartseries type="bar" serieslabel="Other" query="qJobsLogged" itemcolumn="DTLOGGED" valuecolumn="JOBCOUNT">
</cfchartseries>

can you also post your qJobsLogged query?
 
Hi again, I'm just so loosing my focus here. Not knowing how this things works is probably what's getting me all frustrated. Ok, here is what my query looks like

Code:
<cfquery name="qBar" datasource="testDB"> 
SELECT CONVERT(varchar(15), dt.dtlogged, 106) AS dtlogged, dt.jobcount, j.jobPriority, j.jobNumber
FROM (
	SELECT CAST(CONVERT(varchar(15), logdatetime, 106) AS datetime) AS dtlogged,
	  COUNT(*) AS jobcount
	FROM job
	WHERE logdatetime >= '01/02/2005 00:00:00'
	  AND logdatetime <= '02/02/2005 23:59:59'
	GROUP BY CAST(CONVERT(varchar(15), logdatetime, 106) AS datetime)
  ) dt JOIN job j ON dt.dtlogged = CAST(CONVERT(varchar(15), j.logdatetime, 106) AS datetime)
  ORDER BY dtLogged
</cfquery>

And when I dump it, it looks something like this:

Code:
query 
  CALLCOUNT JOBNUMBER JOBPRIORITY 		DTLOGGED 
1 2 		01BS093789 2 				01 Feb 2005 
2 2 		01BS093795 3 				01 Feb 2005 
3 3 		01BS093872 6 				02 Feb 2005 
4 3 		01BS093883 6 				02 Feb 2005 
5 3 		01BS093888 1 				02 Feb 2005

I hope it is making sense so far.

I now what to build a chart with the date on the x-axis and the no of jobs logged in a day on the y-axis. In the example above, there are 2 jobs logged on the 1st of Feb each with a different jobPriority. I want the the user to be able to see this in the chart which is why I've added the <cfif> block inside the chartseries tag, but becuase the cfif is inside the chartseries tag and not outside, the chart representation of the data is not right. I don't know the right way to do this. Can you please help

Regards
cfcoder
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top