Web Dev Tuts

/ Stuffs About Website Development /

Menu
  • Home
  • Wp Plugins
  • How To
  • FAQ
    • GIT
    • JQuery
    • PHP
    • WooCommerce
    • WordPress
  • Contact Us
Menu

Create a Graph Using PHP and SVGGraph

Posted on May 21, 2016September 24, 2017 by admin

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.

[code]

$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;

$graph->Values($values);

echo $graph->Fetch(‘PieGraph’);

[/code]

Category: PHP

Leave a Reply Cancel reply

You must be logged in to post a comment.

Recent Posts

  • How to add wp_editor Dynamically
  • How to Hide Certain Pages from Certain Users (WP Dashboard)
  • How to Set Up Gmail SMTP
  • How to Set Up Virtual Host in Localhost & Xampp
  • How to Determine the Current WordPress Version Used
  • AngularJs
  • CSS
  • For Me Only
  • geo location api
  • GIT
  • GoDaddy
  • Hosting
  • How To
  • Javascript
  • JQuery
  • Magento
  • My Notes
  • PHP
  • Private
  • Sass
  • WooCommerce
  • Wordpress
  • Xampp
© 2023 Web Dev Tuts | Powered by Minimalist Blog WordPress Theme