| 65 |
|
bw.flush(); |
| 66 |
|
} |
| 67 |
|
|
| 68 |
< |
public static void printGraph(BufferedWriter bw, String filename, int width, int height) throws IOException{ |
| 68 |
> |
public static void printGraph(BufferedWriter bw, String filename, int width, int height, int type, long startDate, long endDate) throws IOException{ |
| 69 |
> |
|
| 70 |
> |
String graphTitle = "Unknown time period"; |
| 71 |
> |
String xAxisTitle = "Time"; |
| 72 |
> |
String yAxisTitle = "Value"; |
| 73 |
> |
String scaleRow = " <tr><td> </td><td align=\"left\">"+DateUtils.dateString(startDate)+"</td><td align=\"right\">"+DateUtils.dateString(endDate)+"</td></tr>"; |
| 74 |
> |
|
| 75 |
> |
switch (type) { |
| 76 |
> |
case ReportPage.HOUR: |
| 77 |
> |
graphTitle = "Hourly report from "+DateUtils.dateString(startDate)+" to "+DateUtils.dateString(endDate); |
| 78 |
> |
break; |
| 79 |
> |
case ReportPage.DAY: |
| 80 |
> |
graphTitle = "24 hour report from "+DateUtils.dateString(startDate)+" to "+DateUtils.dateString(endDate); |
| 81 |
> |
break; |
| 82 |
> |
case ReportPage.WEEK: |
| 83 |
> |
graphTitle = "7 day report from "+DateUtils.shortDateString(startDate)+" to "+DateUtils.shortDateString(endDate); |
| 84 |
> |
break; |
| 85 |
> |
case ReportPage.MONTH: |
| 86 |
> |
graphTitle = "30 day report from "+DateUtils.shortDateString(startDate)+" to "+DateUtils.shortDateString(endDate); |
| 87 |
> |
break; |
| 88 |
> |
default: |
| 89 |
> |
// Do nothing, leave values as they are. |
| 90 |
> |
} |
| 91 |
> |
|
| 92 |
|
bw.write("<table border=\"0\">"); |
| 93 |
< |
bw.write(" <tr><td> </td><td colspan=\"2\"><b>Visual representation of the last 7 days</b></td></tr>"); |
| 94 |
< |
bw.write(" <tr><td>y axis</td><td colspan=\"2\"><img src=\""+filename+"\" width=\""+width+"\" height=\""+height+"\"></td></tr>"); |
| 95 |
< |
bw.write(" <tr><td> </td><td align=\"left\">7 days ago</td><td align=\"right\">now</td>"); |
| 93 |
> |
bw.write(" <tr><td> </td><td colspan=\"2\"><b>"+graphTitle+"</b></td></tr>"); |
| 94 |
> |
bw.write(" <tr><td>"+yAxisTitle+"</td><td colspan=\"2\"><img src=\""+filename+"\" width=\""+width+"\" height=\""+height+"\"></td></tr>"); |
| 95 |
> |
bw.write(scaleRow); |
| 96 |
|
bw.write("</table>"); |
| 97 |
|
bw.newLine(); |
| 98 |
|
bw.flush(); |
| 99 |
|
} |
| 100 |
|
|
| 101 |
|
public static void printTable(BufferedWriter bw, PlotData pd) throws IOException{ |
| 102 |
+ |
|
| 103 |
|
bw.write("<table border=\"0\" align=\"center\">"); |
| 104 |
|
|
| 105 |
|
bw.write("<tr bgcolor=\"black\"><td><font color=\"white\">Date</font></td><td><font color=\"white\">Value</font></td></tr>"); |
| 106 |
|
|
| 107 |
+ |
// Alternating row colours. |
| 108 |
|
String rowColour1 = "#ccccff"; |
| 109 |
|
String rowColour2 = "#ffffff"; |
| 110 |
|
|