-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathyearlyGraph.php
More file actions
executable file
·117 lines (97 loc) · 3.63 KB
/
yearlyGraph.php
File metadata and controls
executable file
·117 lines (97 loc) · 3.63 KB
1
2
3
4
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
////////////////////////////////////////////////////
//
// WeatherOffice
//
// http://www.sourceforge.net/projects/weatheroffice
//
// Copyright (C) 04/2007 Mathias Zuckermann &
// Bernhard Heibler
//
// See COPYING for license info
//
////////////////////////////////////////////////////
include("jpgraphSetup.php");
include("class.MinMaxAvg.php");
$dispyear = $_REQUEST["year"];
$graph = new Graph($GraphWidth, $GraphHeight, "auto", 86400);
$graph->SetMargin(50,50,10,90);
$graph->SetScale("datlin");
$graph->SetY2Scale( "lin");
$graph->SetMarginColor($MarginColor);
$graph->SetFrame(true,$FrameColor,1);
$title = "{$text['yearly_overview_graph']} $dispyear";
$graph->xaxis->scale->SetDateFormat('d.m');
$graph->title->Set(encodeStringForGraph($title));
$graph->title->SetColor($LegendColor);
$graph->yaxis->SetColor($YAxisColors[0]);
$graph->yaxis->title->SetMargin(0);
$graph->yaxis->title->SetColor($LegendColor);
$graph->yaxis->title->Set(encodeStringForGraph("°C"));
$graph->y2axis->SetColor($YAxisColors[1]);
$graph->y2axis->title->SetMargin(10);
$graph->y2axis->title->SetColor($LegendColor);
$graph->y2axis->title->Set(encodeStringForGraph("mm"));
$graph->SetTickDensity(TICKD_SPARSE);
$graph->xaxis->SetLabelAngle(90);
$graph->xaxis->SetPos('min');
$graph->xaxis->SetColor($XAxisColors);
$graph->legend->SetColor($LegendColor);
$graph->legend->SetFillColor($LegendFillColor);
$graph->legend->SetPos( 0.03,0.95,"right" ,"bottom");
$graph->legend->SetColumns(4);
$xdata = array();
$ydata1 = array();
$ydata2 = array();
$ydata3 = array();
$ydata4 = array();
/*** START DATA QUERY */
$nextDay = getdate(strtotime("+ 0 sec", mktime(0, 0, 0, 1, 1, $dispyear)));
$day = $nextDay['mday'];
$month = $nextDay['mon'];
$year = $nextDay['year'];
$idx = 0;
while($dispyear == $year )
{
$stat=MinMaxAvg::getStatArray('DAY', $year, $month, $day);
if ($stat)
{
$xdata[$idx] = mktime(0, 0, 0, $nextDay['mon'], $nextDay['mday'], $nextDay['year']);
$ydata1[$idx] = $stat["temp_out"]["min"];
$ydata2[$idx] = $stat["temp_out"]["avg"];
$ydata3[$idx] = $stat["temp_out"]["max"];
$ydata4[$idx] = $stat["rain_total"]['max']; // - $stat["rain_total"]['min'];
$idx++;
}
$nextDay = getdate(strtotime("+1 day", mktime(0, 0, 0, $nextDay['mon'], $nextDay['mday'], $nextDay['year'])));
$day = $nextDay['mday'];
$month = $nextDay['mon'];
$year = $nextDay['year'];
}
$lineplot1=new LinePlot($ydata1, $xdata);
$graph->Add($lineplot1);
$lineplot1->SetColor($YearlyColors[0]);
if ($YearlyFillColors[0]) $lineplot1->SetFillColor($YearlyFillColors[0]);
$lineplot1->SetWeight($LineThickness);
$lineplot1->SetLegend(encodeStringForGraph($text['min'] . " " . $text['temp']));
$lineplot2=new LinePlot($ydata2, $xdata);
$graph->Add($lineplot2);
$lineplot2->SetColor($YearlyColors[1]);
if ($YearlyFillColors[1]) $lineplot2->SetFillColor($YearlyFillColors[1]);
$lineplot2->SetWeight($LineThickness);
$lineplot2->SetLegend(encodeStringForGraph($text['avg'] . " " . $text['temp']));
$lineplot3=new LinePlot($ydata3, $xdata);
$graph->Add($lineplot3);
$lineplot3->SetColor($YearlyColors[2]);
if ($YearlyFillColors[2]) $lineplot3->SetFillColor($YearlyFillColors[2]);
$lineplot3->SetWeight($LineThickness);
$lineplot3->SetLegend(encodeStringForGraph($text['max'] . " " . $text['temp']));
$lineplot4=new LinePlot($ydata4, $xdata);
$graph->AddY2($lineplot4);
$lineplot4->SetColor($YearlyColors[3]);
if ($YearlyFillColors[3]) $lineplot4->SetFillColor($YearlyFillColors[3]);
$lineplot4->SetWeight($LineThickness);
$lineplot4->SetLegend(encodeStringForGraph($text['precipitation']));
$graph->SetShadow();
$graph->Stroke();
?>