# SVGGraph 2.23.1 - a PHP SVG graph library

Skip to:

SVGGraph is an object-oriented PHP library for creating simple PHP graphs, released as open source under the LGPL v3 license. Here are some examples of different types of graph supported by SVGGraph.

## Getting SVGGraph

There are several ways you can get hold of SVGGraph:

1. Download from this site:

2. Clone, download or browse the repository on GitHub:

3. Use Composer and Packagist to download and install SVGGraph from GitHub:

The SVGGraph Composer installer supports the standard Composer autoload facility.

If you are still using PHP4, then you should use version 1.2.1 of SVGGraph: SVGGraph.zip [35k] or SVGGraph.tar.bz2 [25k]. Please read the included README.txt file for the correct instructions for the earlier version. You should seriously consider upgrading to PHP5 too.

This library provides PHP classes and functions for easily creating SVG graphs from data. As of version 2.0, SVGGraph works with PHP 5 only, PHP 4 support has been dropped.

Here is a basic example:

$graph = new SVGGraph(640, 480); $graph->colours = array('red','green','blue'); $graph->Values(100, 200, 150); $graph->Links('/Tom/', '/Dick/', '/Harry/'); $graph->Render('BarGraph');

This will create a SVG file containing a 640x480 bar graph with three hyperlinked bars.

## Graph types

At the moment these types of graph are supported by SVGGraph - the class
name of the type of graph you want to generate should be passed to the
`$graph->Render()`

or `$graph->Fetch()`

function.

### Bar graphs

Class name | Description | Example |
---|---|---|

BarGraph | Vertical bars, optionally hyperlinked. | |

StackedBarGraph | Vertical bars, with multiple datasets stacked. | |

GroupedBarGraph | Vertical bars, with multiple datasets grouped side-by-side. | |

StackedGroupedBarGraph | Vertical bars, with both stacked and grouped datasets. | |

BarAndLineGraph | Grouped bar graph with multi-line graph. | |

Histogram | A series of bars that represent the spread of values. |

For more details and examples, see the bar graph page.

### 3D Bar graphs

Class name | Description | Example |
---|---|---|

Bar3DGraph | A 3D-looking version of the BarGraph type. | |

StackedBar3DGraph | 3D vertical bars, with multiple datasets stacked. | |

GroupedBar3DGraph | 3D vertical bars, with multiple datasets grouped side-by-side. | |

StackedGroupedBar3DGraph | 3D vertical bars, with both stacked and grouped datasets. | |

CylinderGraph | Vertical 3D cylinder-shaped bars. | |

StackedCylinderGraph | Cylinder-shaped version of stacked bar graph. | |

GroupedCylinderGraph | Cylinder-shaped version of grouped bar graph. | |

StackedGroupedCylinderGraph | Cylinder-shaped version of stacked and grouped bar graph. |

For more details and examples, see the 3D bar graph page.

### Horizontal bar graphs

Class name | Description | Example |
---|---|---|

HorizontalBarGraph | Horizontal bars, optionally hyperlinked. | |

HorizontalStackedBarGraph | Horizontal bars, with multiple datasets in-line. | |

HorizontalGroupedBarGraph | Horizontal bars, with multiple datasets grouped vertically. | |

PopulationPyramid | A horizontal bar graph with the bars drawn from a central axis, used to show male and female populations and ages. |

For more details and examples, see the horizontal bar graph page.

### Line graphs

Class name | Description | Example |
---|---|---|

LineGraph | A line joining the data points, with optionally hyperlinked markers at the data points. | |

MultiLineGraph | Multiple lines joining the data points in each data set, with optionally hyperlinked markers at the data points. | |

StackedLineGraph | Multiple lines joining data points, with the values from different data sets added together. |

For more details and examples, see the line graph page.

### Scatter graphs

Class name | Description | Example |
---|---|---|

ScatterGraph | Markers drawn at arbitrary horizontal and vertical points. | |

MultiScatterGraph | Markers from multiple data sets drawn at arbitrary horizontal and vertical points. |

For more details and examples, see the scatter graph page.

### Radar graphs

Class name | Description | Example |
---|---|---|

RadarGraph | A line joining the data points, measured from the centre point, with optionally hyperlinked markers at the data points. | |

MultiRadarGraph | Multiple lines joining the data points in each data set, measured from the centre point, with optionally hyperlinked markers at the data points. |

For more details and examples, see the radar graph page.

### Pie graphs

Class name | Description | Example |
---|---|---|

PieGraph | A pie chart, with optionally hyperlinked slices and option to fade labels in/out when the pointer enters/leaves a slice. | |

Pie3DGraph | A 3D-looking version of the PieGraph type. | |

DonutGraph | A pie chart, with a hole in the centre where text can be displayed. | |

PolarAreaGraph | A pie chart where the area of the slice indicates the value instead of the slice angle. | |

ExplodedPieGraph | A pie chart with slices pushed out from the centre point. |

For more details and examples, see the pie graph page.

### Other miscellaneous graphs

Class name | Description |
---|---|

FloatingBarGraph | A bar graph where the top and bottom of each bar use separate data points. |

HorizontalFloatingBarGraph | A horizontal version of the FloatingBarGraph. |

BubbleGraph | A scatter graph where the markers are replaced by filled circles, their areas coming from another data point. |

BoxAndWhiskerGraph | A bar-like graph for displaying statistical distributions. |

For more details and examples, see the other graphs page.

## Help!

If you have trouble figuring out how to get your graph working from the details on these pages, or if you find any bugs or have suggestions for improvements, please contact me at the usual address, graham(at)goat1000.com.

Thanks to Pierre-Sylvain Luquet for his code submissions.