Location: PHPKode > scripts > SVGraph > svgraph/example/index.php
header("Content-Type: application/xhtml+xml; charset=utf-8");
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="application/xml; charset=utf-8" />
<title>SVGraph example</title>

<h1>NOTE! SVG support in browser is required for this page to be rendered correctly!</h1>
Known to work in Opera 9+ and Firefox 2+

<table style="width:100%"><tbody><tr>
<td style="width:30%;vertical-align:top;">

<h1 style="display:block;clear:both;">SVGraph example (PHP)</h1>

/* All the usage is exactly the same as for JavaScript class - see the above example */
require_once dirname(__FILE__) . '/../SVGraph.php';
$svg = new SVGraph(400, 300);
$svg->setLegend(0, 'Graphic 1')
	->setLegend(1, 'Graphic 2')
	->setLegend(2, 'Graphic 3')
	->setLegend(3, 'Graphic 4')->setFactor(3, 1000)
	->setLegend(4, 'Graphic 5')->setFactor(4, 100)
	->setLegend(5, 'Graphic 6')->setFactor(5, 100);

<td style="width:70%;vertical-align:top;">

<h1>SVGraph example (JavaScript)</h1>

<div id="dia"></div>
<script src="../SVGraph.js"></script>

/* Create new SVGraph instance */
window.svg = new SVGraph(400, 300);

/* Setup graphics: legengs & multiplying-factors */
window.svg.setLegend(0, 'Graphic 1').setLegend(1, 'Graphic 2').
	setLegend(2, 'Graphic 3').
	setLegend(3, 'Graphic 4').setFactor(3, 1000).
	setLegend(4, 'Graphic 5').setFactor(4, 100).
	setLegend(5, 'Graphic 6').setFactor(5, 100);

 * Import data. 
 * Data is an array, where each item is itself an array like this: [x, y1, y2,.. ,yN]
 * As you may have guessed, the first element in a data-item represents value on the X-axis of the graphic,
 * whereas y1, y2,.. ,yN - represent Y-axis values for lines ## 1, 2,.. N.
 * In the below example, we have 6 lines in our graphic

/* render graphic inside div#dia */

<p>Click the legends below the graphic to toggle lines' visibility.</p>


<h2>About SVGraph</h2>
SVGraph is an opensource chartmaker available in JavaScript and PHP. Javascript version is completely client-side, 
whilst PHP, in contrast, is completely server-side.
Both PHP anf JavaScript versions of SVGraph have the same API, feature-list etc. 
The PHP version is no more than a port from Javascript. Should the graphics appear a bit clumsy - 
that should be true for both versions.
SVGraph is in alpha stage. It lacks many fetures that obviously should be present. The first thing to work on
will be a detection of minimum value as well as maximimum - and adjusting the resulting graphic accordingly.
I'm gonna pay much attention to customization of the layout also - through custom CSS classes, extending the API etc.

<h2>A bit of history</h2>
I designed SVGraph for my own needs - one of my apps needed this kind of app, and I decided that JPGraph 
is not that good - for me. 
(ok guys, I know that JPGraph is an incomparably richer application, but isn't it good to have another one?)

<h2>About this example</h2>
One thing you should notice - is that the document is forced to be served as &quot;application/xhtml+xml&quot;. Otherwise, 
the PHP version will fail to render (at least in my Opera). 
JavaScript version does not require application/xhtml+xml HTTP header.

<h2>Contact me</h2>
Please write your reviews, suggestions etc. - to <a href="mailto:hide@address.com?subject=SVGraph">my email</a>. 
My name is Victor Bolshov, I live in Obninsk, Russia.

Return current item: SVGraph