1 |
<?php |
2 |
/** |
3 |
* Another example of how to build an |
4 |
* SVG Image with phpHtmlLib. |
5 |
* SVG = Scalable Vector Graphics. |
6 |
* that phpHtmlLib provides. |
7 |
* |
8 |
* |
9 |
* $Id: example8.php,v 1.11 2003/06/05 18:30:00 hemna Exp $ |
10 |
* |
11 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
12 |
* @package phpHtmlLib |
13 |
* @subpackage examples |
14 |
* @version 2.0.0 |
15 |
* |
16 |
*/ |
17 |
|
18 |
/** |
19 |
* Include the phphtmllib libraries |
20 |
*/ |
21 |
include_once("includes.inc"); |
22 |
include_once($phphtmllib."/widgets/svg/includes.inc"); |
23 |
include_once($phphtmllib."/widgets/svg/SVGXYLineGraph.inc"); |
24 |
|
25 |
//allow the user to change the width |
26 |
//and the height of the graph itself |
27 |
$width = 320; |
28 |
if (!empty($_REQUEST["width"])) { |
29 |
$width = $_REQUEST["width"]; |
30 |
} |
31 |
|
32 |
$height = 240; |
33 |
if (!empty($_REQUEST["height"])) { |
34 |
$height = $_REQUEST["height"]; |
35 |
} |
36 |
|
37 |
$svgdoc = new SVGDocumentClass("100%","100%"); |
38 |
$graph = new SVGXYLineGraph("The Title of the Graph", $width,$height); |
39 |
$graph->set_x_title("X-Axis dude"); |
40 |
$graph->set_y_title("Some Y Axis Data points"); |
41 |
|
42 |
//ok add a line and make it red |
43 |
$graph->add_line("0,1,2.3,4.2,6,8", "1,2,2.7,0.3,6,1", "red"); |
44 |
|
45 |
//add 2 more lines |
46 |
$graph->add_line("0,1,4.1,6", "0,4,2,3", "blue"); |
47 |
$graph->add_line("1,2,3,4,5", "0,4,3,1,7", "black"); |
48 |
|
49 |
//add the line graph widget to the document. |
50 |
$svgdoc->add( $graph ); |
51 |
|
52 |
print $svgdoc->render(); |
53 |
?> |