source: code/Website/php5-ofc-library/examples/scatter-chart.php@ 7849

Last change on this file since 7849 was 7849, checked in by dennisw, 15 years ago
File size: 1.7 KB
Line 
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
21require_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
44for( $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
62echo $chart->toPrettyString();
63
Note: See TracBrowser for help on using the repository browser.