Graphs » Usage

Copyright© 2005 Peter Taurins

Graphing is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Graphing is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with graphing; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

The software expects the font files to be in /resources so ensure that you place your TTF (True Type Font) file in the /resources direcory.

Create a new file, call it example.php

Provide the data to the graph software in simple arrays, one for each of the labels and one for each of the series of data.
Build as many or as few array series as you need to convey your meaning.

  • $x_values[0] = array("", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
  • $x_values[1] = array("The Values Series 1", 1, 5, 12, 16, 22, 38, 45, 70, 80, 99);
  • $x_values[2] = array("The Values Series 2", 10, 15, 25, 46, 27, 55, 80, 50, 20, 10);
  • $x_values[3] = array("The Values Series 3", 12, 80, 45, 20, 78, 12, 72, 82, 84, 48);

Include the graph software (amending the path as necessary) and set the minimum variables as follows:

  • require($_SERVER["DOCUMENT_ROOT"]."/graphs/graph.php");
  • $newgraph = new Graph();
  • $newgraph->setGraphType("barGraph");
  • $newgraph->setXValues($x_values);
  • $newgraph->setXTitle("Total");
  • $newgraph->setYTitle("Period");
  • $newgraph->setGraphTitle("Example 1 Series Bar Graph");
  • $newgraph->drawGraph();

Generate the image either by calling the file example.php directly in your browser or by wrapping it in an image tag for display on your webpage.
<img src="example.php">