1 | <?php
|
---|
2 | include_once 'php-ofc-library/open-flash-chart.php';
|
---|
3 | include_once 'cfg/mysql.php';
|
---|
4 | connectdb();
|
---|
5 |
|
---|
6 |
|
---|
7 | $result = mysql_query("select AVG(value) AS average FROM tuples LEFT JOIN sensors ON tuples.sensorID=sensors.sensorID WHERE end IS NULL GROUP BY sensors.roomID");
|
---|
8 |
|
---|
9 | $data = array();
|
---|
10 | while($row = mysql_fetch_array($result))
|
---|
11 | {
|
---|
12 | $data[] = intval($row['average']);
|
---|
13 | }
|
---|
14 |
|
---|
15 | $title = new title( 'All rooms' );
|
---|
16 |
|
---|
17 | $bar = new bar();
|
---|
18 | $bar->colour( '#BF3B69');
|
---|
19 | $bar->key('Gemiddelde', 14);
|
---|
20 | $bar->set_values( $data );
|
---|
21 | $bar->set_on_click("bar_1");
|
---|
22 | $bar->set_colour('#f7921c');
|
---|
23 |
|
---|
24 |
|
---|
25 | //-- Y AXIS --\\
|
---|
26 |
|
---|
27 | $y = new y_axis();
|
---|
28 | $y->set_range( 0, 50, 10 );
|
---|
29 | $y->set_colour('#000000');
|
---|
30 | $y->set_grid_colour('#D8D8D8');
|
---|
31 |
|
---|
32 |
|
---|
33 | //-- X AXIS --\\
|
---|
34 |
|
---|
35 | $x = new x_axis();
|
---|
36 | $x->colour('#000000')->grid_colour('#D8D8D8');
|
---|
37 | $x_legend = new x_legend( 'Kamer ID' );
|
---|
38 | $x_legend->set_style( '{font-size: 14px; color: #000000}' );
|
---|
39 |
|
---|
40 |
|
---|
41 | //--CHART --\\
|
---|
42 |
|
---|
43 | $chart = new open_flash_chart();
|
---|
44 | $chart->set_title( $title );
|
---|
45 | $chart->set_x_legend( $x_legend );
|
---|
46 | $chart->set_x_axis( $x );
|
---|
47 | $chart->set_y_axis( $y );
|
---|
48 | $chart->add_element( $bar );
|
---|
49 | $chart->set_bg_colour( '#FFFFFF' );
|
---|
50 | //$chart->add_element( $bar2 );
|
---|
51 |
|
---|
52 |
|
---|
53 | echo $chart->toString();
|
---|
54 | ?>
|
---|