1 | <?php
|
---|
2 | /**
|
---|
3 | * PHP Integration of Open Flash Chart
|
---|
4 | * Copyright (C) 2008 John Glazebrook <open-flash-chart@teethgrinder.co.uk>
|
---|
5 | *
|
---|
6 | * This library is free software; you can redistribute it and/or
|
---|
7 | * modify it under the terms of the GNU Lesser General Public
|
---|
8 | * License as published by the Free Software Foundation; either
|
---|
9 | * version 2.1 of the License, or (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This library is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
14 | * Lesser General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU Lesser General Public
|
---|
17 | * License along with this library; if not, write to the Free Software
|
---|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
19 | */
|
---|
20 |
|
---|
21 | require_once('OFC/OFC_Chart.php');
|
---|
22 |
|
---|
23 | $data_1 = array();
|
---|
24 | $data_2 = array();
|
---|
25 | $data_3 = array();
|
---|
26 |
|
---|
27 | for( $i=0; $i<6.2; $i+=0.2 )
|
---|
28 | {
|
---|
29 | $data_1[] = (sin($i) * 1.9) + 7;
|
---|
30 | $data_2[] = (sin($i) * 1.9) + 10;
|
---|
31 | $data_3[] = (sin($i) * 1.9) + 4;
|
---|
32 |
|
---|
33 | // just show to two decimal places
|
---|
34 | // in our labels:
|
---|
35 | //$labels[] = number_format($tmp,2);
|
---|
36 | }
|
---|
37 |
|
---|
38 | $title = new OFC_Elements_Title( date("D M d Y") );
|
---|
39 |
|
---|
40 | $line_1 = new OFC_Charts_Line_Dot();
|
---|
41 | $line_1->set_values( $data_1 );
|
---|
42 | $line_1->set_halo_size( 0 );
|
---|
43 | $line_1->set_width( 2 );
|
---|
44 | $line_1->set_dot_size( 4 );
|
---|
45 |
|
---|
46 | $line_2 = new OFC_Charts_Line_Dot();
|
---|
47 | $line_2->set_values( $data_2 );
|
---|
48 | $line_2->set_halo_size( 1 );
|
---|
49 | $line_2->set_width( 1 );
|
---|
50 | $line_2->set_dot_size( 4 );
|
---|
51 |
|
---|
52 | $line_3 = new OFC_Charts_Line_Dot();
|
---|
53 | $line_3->set_values( $data_3 );
|
---|
54 | $line_3->set_halo_size( 1 );
|
---|
55 | $line_3->set_width( 6 );
|
---|
56 | $line_3->set_dot_size( 4 );
|
---|
57 |
|
---|
58 | $y = new OFC_Elements_Axis_Y();
|
---|
59 | $y->set_range( 0, 15, 5 );
|
---|
60 |
|
---|
61 |
|
---|
62 | $chart = new OFC_Chart();
|
---|
63 | $chart->set_title( $title );
|
---|
64 | $chart->add_element( $line_1 );
|
---|
65 | $chart->add_element( $line_2 );
|
---|
66 | $chart->add_element( $line_3 );
|
---|
67 | $chart->set_y_axis( $y );
|
---|
68 |
|
---|
69 | echo $chart->toPrettyString();
|
---|