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 | // generate some random data
|
---|
24 | srand((double)microtime()*1000000);
|
---|
25 |
|
---|
26 | $data_1 = array();
|
---|
27 | $data_2 = array();
|
---|
28 | $data_3 = array();
|
---|
29 | for( $i=0; $i<9; $i++ )
|
---|
30 | {
|
---|
31 | $data_1[] = rand(1,6);
|
---|
32 | $data_2[] = rand(7,13);
|
---|
33 | $data_3[] = rand(14,19);
|
---|
34 | }
|
---|
35 |
|
---|
36 |
|
---|
37 | $line_dot = new OFC_Charts_Line_Dot();
|
---|
38 | $line_dot->set_width( 4 );
|
---|
39 | $line_dot->set_colour( '#DFC329' );
|
---|
40 | $line_dot->set_dot_size( 5 );
|
---|
41 | $line_dot->set_values( $data_1 );
|
---|
42 |
|
---|
43 | $line_hollow = new OFC_Charts_Line_Hollow();
|
---|
44 | $line_hollow->set_width( 1 );
|
---|
45 | $line_hollow->set_colour( '#6363AC' );
|
---|
46 | $line_hollow->set_dot_size( 5 );
|
---|
47 | $line_hollow->set_values( $data_2 );
|
---|
48 |
|
---|
49 | $line = new OFC_Charts_Line();
|
---|
50 | $line->set_width( 1 );
|
---|
51 | $line->set_colour( '#5E4725' );
|
---|
52 | $line->set_dot_size( 5 );
|
---|
53 | $line->set_values( $data_3 );
|
---|
54 |
|
---|
55 | $y = new OFC_Elements_Axis_Y();
|
---|
56 | $y->set_range( 0, 20, 5 );
|
---|
57 |
|
---|
58 | $chart = new OFC_Chart();
|
---|
59 | $chart->set_title( new OFC_Elements_Title( 'Three lines example' ) );
|
---|
60 | $chart->set_y_axis( $y );
|
---|
61 | //
|
---|
62 | // here we add our data sets to the chart:
|
---|
63 | //
|
---|
64 | $chart->add_element( $line_dot );
|
---|
65 | $chart->add_element( $line_hollow );
|
---|
66 | $chart->add_element( $line );
|
---|
67 |
|
---|
68 | echo $chart->toPrettyString();
|
---|