Microsoft
Software
Hardware
Network
Question : CFChart and graphing a month
I am trying to graph data for a month.
The problem is that there may be no data for a particular day.
For example, I have the following data
MyCount TheDay TheYear
----------- ----------- -----------
9 2 2003
12 3 2003
8 5 2003
13 6 2003
6 7 2003
8 8 2003
14 9 2003
13 10 2003
5 11 2003
11 12 2003
7 13 2003
3 14 2003
6 15 2003
14 16 2003
18 17 2003
10 18 2003
13 19 2003
13 20 2003
13 21 2003
12 22 2003
19 23 2003
23 24 2003
15 25 2003
19 26 2003
9 27 2003
10 28 2003
11 29 2003
12 30 2003
2 1 2004
5 2 2004
12 3 2004
25 4 2004
20 6 2004
Notice that there is no data for the 4th of 2003 nor the 1st of 2003 nor the 5th for 2004 (although the missing data doesn't seem to matter as long as there is data for teh corresponding day in the earliest month graphed).
Now when I chart this data I get the days across the X axis like this :
2 3 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 1 4
Notice that the 1st and the 4th get put at the end because they did not exists in the first month that was graphed.
I need either :
1) a SQL way to ensure that I pull data for every date in the earliest year (or every year) so that the data looks like
MyCount TheDay TheYear
----------- ----------- -----------
0 1 2003
9 2 2003
12 3 2003
0 4 2003
8 5 2003
13 6 2003
6 7 2003
8 8 2003
14 9 2003
13 10 2003
5 11 2003
11 12 2003
7 13 2003
3 14 2003
6 15 2003
14 16 2003
18 17 2003
10 18 2003
13 19 2003
13 20 2003
13 21 2003
12 22 2003
19 23 2003
23 24 2003
15 25 2003
19 26 2003
9 27 2003
10 28 2003
11 29 2003
12 30 2003
2 1 2004
5 2 2004
12 3 2004
25 4 2004
0 5 2004
20 6 2004
2) a way to do this in Cold Fusion. I tried Query of Queries, but an outer join is needed and that is not yet supported in query of queries.
Here is my chart code :
chartheight="600"
chartwidth="950"
yaxistitle="MyCount"
format="jpg"
scalefrom="0"
scaleto="60"
gridlines="13"
name="output_graph">
Answer : CFChart and graphing a month
1. Get the data from your query, sorted by day.
2. Get the number of days in any given month that you are interested in:
3. Set the year (you can do this programattically to cover mutliple years)
3. Loop over the number of days in that month within your cfchart. Do a query on your query for that day's values, and if one does not exist, insert your own "zero".
chartheight="600"
chartwidth="950"
yaxistitle="MyCount"
format="jpg"
scalefrom="0"
scaleto="60"
gridlines="13"
name="output_graph">
SELECT MyCount FROM MyQuery WHERE TheYear = '#thisyear#' AND TheDay = '#thisday#'
I haven't tested this, there are other variables in there I've not accounted for, but that is the gist of it.
cheers,
Random Solutions
I need to get to the Nth field in the Nth line of a text datafile, change it and save it back to the text file.
Converting a batch of CMYK images to jpg
97 Runtime problems in XP limited user account
Creat Running Balance Like Checkbook Register
Treeview Events and References
Scheduling a PowerShell Script to run - the file is Blank
Heterogenous Queries,ANSI_NULLS,ANSI_WA<wbr />RNINGS,Lin<wbr />ked Servers(AS400),Crystal Reports
Exchange 2003 Outbound mail using smart host not sending to internal mail servers
setup terminal server "gateway" to individual desktop machines
Exchange Server 2007