PHP SVG Charts

Download and more on Github

Simple. MIT Open-Source licensed. Generate SVG image charts in your backend, no javascript or browser needed.
The main reason this library was built is to generate PDFs with charts in PHP only.


The most basic line chart example

Time01245-90.00-56.00-22.0012.0046.0080.00Awesome lines

Basic line charts with custom labels and step lines

TimeFooBarCoolIsn'tItMinus Ninety-56-221246EightyAwesome lines

Line charts with multiple lines sharing same yaxis

Also including a grid and smooth curved lines
Each series has different x values so it starts and stops independently
Also each series have different styles so each series can be styled for your needs
Extra annotations on each of the axis are also added
And on top, we a have a few special stylings attached, like gradients
Time13.08.2002 22:1813.08.2002 22:3513.08.2002 22:5113.08.2002 23:0813.08.2002 23:1313.08.2002 23:1513.08.2002 23:2913.08.2002 23:33-30.00-15.000.0015.0030.0045.0060.0075.0090.00105.00120.00BEST30.0070.0080.00100.00-10.00-20.00Annotation X Annotation YAnnotation Point

Line charts with multiple lines each having it's own y-axis

Multi line charts, each line with it's own y-axis
Time13.08.2002 22:1813.08.2002 22:3513.08.2002 22:5113.08.2002 23:0813.08.2002 23:1313.08.2002 23:1513.08.2002 23:2913.08.2002 23:33-30.00-22.00-14.00-6.002.0010.0018.0026.0034.0042.0050.00-30.00-15.000.0015.0030.0045.0060.0075.0090.00105.00120.00BEST30.0070.0080.00100.00-10.00-20.00

Line charts with many data points and auto rotation/skip

This chart show how the x-axis auto fit itself so nothing overlaps
Time13.08.2002 23:3514.08.2002 01:3114.08.2002 03:4514.08.2002 05:5814.08.2002 08:1114.08.2002 10:2514.08.2002 12:3814.08.2002 14:5114.08.2002 17:0514.08.2002 19:1814.08.2002 21:3114.08.2002 23:4515.08.2002 01:5815.08.2002 04:1115.08.2002 06:2515.08.2002 08:3815.08.2002 10:5115.08.2002 13:0515.08.2002 15:1815.08.2002 17:3115.08.2002 19:4515.08.2002 21:5816.08.2002 00:1116.08.2002 02:2516.08.2002 04:3816.08.2002 06:5116.08.2002 09:0516.08.2002 11:1816.08.2002 13:3116.08.2002 15:4516.08.2002 17:5816.08.2002 20:1116.08.2002 22:08-110.00-87.00-64.00-41.00-18.005.0028.0050.9973.9996.99119.99BEST

Annotations and Fonts

You can add several annotation types to x and y axis
Also there are most websafe fonts built in
You can use any font you want, but only the websafe ones correctly calculates text dimensions (required to properly place labels)
01245-90.00-56.00-22.0012.0046.0080.00Awesome linesX Line Annotation Y Line AnnotationAnnotation PointarialAnnotation PointverdanaAnnotation PointtahomaAnnotation Pointtrebuchet msAnnotation Pointtimes new romanAnnotation PointgeorgiaAnnotation PointgaramondAnnotation Pointcourier new

Basic column chart example

Very basic column charts. y-Baseline is set to -110, bellow all given values. So all columns grow upwards.
01245-110.00-72.00-34.004.0042.0080.00Awesome lines5.0010.0080.001.00-90.00

Stacked columns

Multiple values stacked in one column
y-Baseline is set to zero (default), so values bellow zero go down
Value labels are added as well as a summary label for each column
012456-85.0%-19.0%47.0%113.0%179.0%245.0%Awesome lines5.0%30.0%20.0%55.0%1.0%20.0%66.0%87.0%80.0%20.0%33.0%133.0%90.0%120.0%15.0%225.0%20.0%22.0%10.0%52.0%-15.0%-30.0%-20.0%-65.0%

Mixed column and line charts

You can freely mix any line and column chart together
TimeJanuaryFebruaryMarchAprilMayJune-55.00-1.0053.00107.00161.00215.00Awesome lines

Column and line charts with grouped and stacked data combined

You can group and stack at the same time, as well as adding line charts on top
Time012340.0043.0086.00129.00172.00215.00Awesome lines