Create a Graph Using PHP and SVGGraph

Creating a graph is very easy with the aid of SVGGraph library. You can download it here. This library supports almost all kinds of graphs such as pie graph, line graph, bar graph, and many more.

In this tutorial, you will learn how to create a simple pie graph using PHP and SVGGraph. Simply copy the codes below and replace the values and settings in order to produce the pie graph that you want.

$values = array(
'Val 1' => 70,
'Val 2' => 30

$settings = array(
'back_colour' => '#fff',
'stroke_colour' => '#000',
'back_stroke_width' => 0,
'back_stroke_colour' => '#eee',
'pad_right' => 20,
'pad_left' => 20,
'link_base' => '/',
'link_target' => '_top',
'show_labels' => true,
'show_label_amount' => false,
'label_font' => 'Arial',
'label_font_size' => '11',
'label_colour' => '#000',
'show_label_percent' => true,
'sort' => false

$colours = array('#8a9b00','#9d9d9d');

$graph = new SVGGraph(300, 200, $settings);
$graph->colours = $colours;


echo $graph->Fetch('PieGraph');

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPrint this pageEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *