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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFHART: How to insert "blank" data for time-values line-charts?

Status
Not open for further replies.

Smapty

Programmer
Mar 12, 2005
55
US
How do you account for no data for certain time-increments when crating a line-chart?

For example, what if you want to chart the income earned over time, but have certiain days where there are no records at all for that day... but you still want to have show the line as "flat" goind across that period of time. As it is, CFCHART just skips those days in the x-axis ticking.
 
depends on how you do your chart. if you're using a DB and the DB doesn't have any records for that day you probably don't want to use "query =" within your chart. You'll want to loop manually and do checks for records per day.

you'll have to provide more information/code if you want more help than this...

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Here is my working code:
Code:
<CFQUERY NAME="Q1" datasource="sourcename">
SELECT COUNT(TranDate) AS Graded, TranDate
FROM Attendees
WHERE year(TranDate) < 2004
GROUP BY TranDate
</CFQUERY>

<CFSET tally = 0>
<CFSET Dayz = 0>

<cfchart format="flash" chartwidth="1200" chartheight="800">

<cfchartseries type="line">
<CFLOOP query="Q1">
<CFIF currentrow IS 1>
<CFSET Dayz = #DateFormat(TranDate, 'mmm-dd')#>
</CFIF>
<CFIF #DateFormat(TranDate, 'mmm-dd')# IS Dayz>

<CFSET tally = (tally + #Graded#)>
<cfchartdata item="#DateFormat(TranDate, 'mmm-dd')#" value="#tally#">
</CFIF>
<CFSET Dayz = #Evaluate(DateFormat(TranDate, 'mmm-dd') + 1)#>
</CFLOOP>
</cfchartseries>
</cfchart>
 
working code? so you get the results you wanted now?

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
No, that doesn't work. It still skips days without values. Obviously, I need to create a new CFLOOP entirely that's indexed against the range of dates I'm charting in order to account for gaps in the data-record.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top