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 | $chart = new OFC_Chart();
|
---|
24 |
|
---|
25 | $title = new OFC_Elements_Title( date("D M d Y") );
|
---|
26 | $chart->set_title( $title );
|
---|
27 |
|
---|
28 | $scatter = new OFC_Charts_Scatter( '#FFD600', 10 );
|
---|
29 | $scatter->set_values(
|
---|
30 | array(
|
---|
31 | new OFC_Charts_Scatter_Value( 0, 0 )
|
---|
32 | )
|
---|
33 | );
|
---|
34 |
|
---|
35 | $chart->add_element( $scatter );
|
---|
36 |
|
---|
37 |
|
---|
38 | //
|
---|
39 | // plot a circle
|
---|
40 | //
|
---|
41 | $s2 = new OFC_Charts_Scatter( '#D600FF', 3 );
|
---|
42 | $v = array();
|
---|
43 |
|
---|
44 | for( $i=0; $i<360; $i+=5 )
|
---|
45 | {
|
---|
46 | $v[] = new OFC_Charts_Scatter_Value(
|
---|
47 | number_format(sin(deg2rad($i)), 2, '.', ''),
|
---|
48 | number_format(cos(deg2rad($i)), 2, '.', '') );
|
---|
49 | }
|
---|
50 | $s2->set_values( $v );
|
---|
51 | $chart->add_element( $s2 );
|
---|
52 |
|
---|
53 | $x = new OFC_Elements_Axis_X();
|
---|
54 | $x->set_range( -2, 2 );
|
---|
55 | $chart->set_x_axis( $x );
|
---|
56 |
|
---|
57 | $y = new OFC_Elements_Axis_Y();
|
---|
58 | $y->set_range( -2, 2 );
|
---|
59 | $chart->add_y_axis( $y );
|
---|
60 |
|
---|
61 |
|
---|
62 | echo $chart->toPrettyString();
|
---|
63 |
|
---|