source: code/Website/graph_line.php@ 7937

Last change on this file since 7937 was 7878, checked in by dennisw, 15 years ago
File size: 2.5 KB
Line 
1<?php
2include_once 'php-ofc-library/open-flash-chart.php';
3include_once 'cfg/mysql.php';
4connectdb();
5
6$room = $_COOKIE['room'];
7$description = $_COOKIE['description'];
8
9if($description=='Radiator Rechts' OR $description=='Radiator Links' OR $description=='Luchtuitlaat temperatuursensor' OR $description=='atrium, 1e' OR $description=='atrium, 3e' OR $description=='buiten' OR $description=='kamer, buro')
10{
11 $result = mysql_query("SELECT TIME(start) AS xaxis, (value) as value, sensors.description as description FROM tuples LEFT JOIN sensors ON tuples.sensorID=sensors.sensorID WHERE (roomID=$room) AND (sensors.description='$description') ORDER BY start limit 100");
12}
13else
14{
15 $result = mysql_query("SELECT TIME(start) AS xaxis, (value*1000) as value, sensors.description as description FROM tuples LEFT JOIN sensors ON tuples.sensorID=sensors.sensorID WHERE (end IS NOT NULL) AND (roomID=$room) AND (sensors.description='$description') ORDER BY start limit 100");
16}
17
18$result2 = mysql_query("SELECT MAX(value) AS yaxis from tuples ORDER BY start limit 100");
19
20$data = array();
21while($row = mysql_fetch_array($result))
22{
23 $data[] = intval($row['value']);
24 $xaxis[] = ($row['xaxis']);
25}
26
27while($row = mysql_fetch_array($result2))
28{
29 $yaxis = intval($row['yaxis']);
30}
31
32$title = new title('Kamer '.$room);
33
34$yaxisnew = (ceil($yaxis / 50)) * 50;
35
36//-- LINE 1 --\\
37
38$line_1_default_dot = new dot();
39$line_1_default_dot->size(4)->halo_size(2)->colour('#339933')->on_click("line_1");
40$line_1 = new line();
41$line_1->set_default_dot_style($line_1_default_dot);
42$line_1->set_values( $data );
43$line_1->set_width( 2 );
44$line_1->set_colour('#f7921c');
45$line_1->set_key($description, 14);
46
47
48//-- Y AXIS --\\
49
50$y = new y_axis();
51$y->set_range( 0, 300, 30 );
52$y->set_colour('#000000');
53$y->set_grid_colour('#D8D8D8');
54
55
56//-- X AXIS --\\
57
58$x = new x_axis();
59$x->offset(false)->steps(10);
60$x->colour('#000000')->grid_colour('#D8D8D8');
61
62$x_labels = new x_axis_labels();
63$x_labels->set_steps( 10 );
64$x_labels->set_colour( '#000000' );
65$x_labels->set_labels( $xaxis );
66$x->set_labels( $x_labels );
67
68
69//--CHART --\\
70
71$chart = new open_flash_chart();
72$chart->set_title( $title );
73$chart->add_element( $line_1 );
74$chart->set_x_axis( $x );
75$chart->set_y_axis( $y );
76$chart->set_bg_colour( '#FFFFFF' );
77
78echo $chart->toPrettyString();
79$chartwrite = $chart->toPrettyString();
80
81$fh = fopen("graphs/".$room."_".$description.".txt", 'w') or die("can't open file");
82fwrite($fh, $chartwrite);
83fclose($fh);
84
85
86?>
Note: See TracBrowser for help on using the repository browser.