/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/widgets/svg/SVGXYPlotGraph.inc
ViewVC logotype

Contents of /nfo/php/libs/com.newsblob.phphtmllib/widgets/svg/SVGXYPlotGraph.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations)
Thu May 6 16:27:53 2004 UTC (20 years, 3 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -0 lines
 updated all to v2.4.1 - Apr 01, 2004

1 <?php
2 /**
3 * This file holds the base Graph class for doing
4 * graphs on an XY coordinate system.
5 *
6 * $Id: SVGXYPlotGraph.inc,v 1.2 2003/03/04 22:18:28 hemna Exp $
7 *
8 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
9 * @package phpHtmlLib
10 * @subpackage SVG
11 */
12
13 /**
14 * we need the SVGGraph class
15 */
16 require_once($phphtmllib."/widgets/svg/SVGXYGraph.inc");
17
18 /**
19 * This is the base Graph class for doing XY coordinate
20 * system based graphs in SVG.
21 *
22 * $Id: SVGXYPlotGraph.inc,v 1.2 2003/03/04 22:18:28 hemna Exp $
23 *
24 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
25 * @package phpHtmlLib
26 * @subpackage SVG
27 */
28 class SVGXYPlotGraph extends SVGXYGraph {
29
30 function SVGXYPlotGraph($title, $width, $height) {
31
32 //set up the options.
33 $this->_add_options();
34
35 //turn these on by default
36 $this->set_grid_line_flag("x", TRUE);
37 $this->set_grid_line_flag("y", TRUE);
38
39 $this->set_title($title);
40 $this->set_width($width);
41 $this->set_height($height);
42 }
43
44 /**
45 * This enables you to add another line
46 * to the graph
47 *
48 * @param string - the x coordinates
49 * @param string - the y coordinates
50 * @param string - the color for the line
51 */
52 function add_point($x, $y, $color="red") {
53 $this->add_x_values($x);
54 $this->add_y_values($y);
55 $this->_colors[] = $color;
56 }
57
58
59 /**
60 * This function does the work of
61 * building the graph itself
62 *
63 * @return Container
64 */
65 function graph_data() {
66 $container = container();
67
68 $num_lines = count($this->_x_data);
69 for( $i=0; $i<=$num_lines-1; $i++) {
70 $container->add( $this->_build_point($this->_x_data[$i],
71 $this->_y_data[$i],
72 $this->_colors[$i]) );
73 }
74
75 return $container;
76 }
77
78
79 function _build_point( $x, $y, $color ) {
80 return svg_circle( $x, $y, 2, $color, $color);
81 }
82 }
83 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed