Search:
Main Menu
Login | RSS |

Quick PHP Code Tips and Examples

PHP Programming Tips, Tutorials and Source Code Examples for newbie

Libchart : Howto Create Bar Chart and Pie Chart Easily with PHP

March 18th, 2007 by Jon Moffet

Libchart is a lightweight PHP class library which can be use to create charts. It support creating Horizontal Bar , Vertical Bar, Pie chart and Line graph which is useful for data representation on your PHP scripts.

Here's a sample of Libchart output :
bar graph
pie chart

Sample Code

PHP:
  1. include "libchart/libchart.php";
  2.  
  3.     header("Content-type: image/png");
  4.    
  5.     $chart = new VerticalChart(500,250);
  6.  
  7.     $chart->addPoint(new Point("Jan 2005", 273));
  8.     $chart->addPoint(new Point("Feb 2005", 321));
  9.     $chart->addPoint(new Point("March 2005", 442));
  10.     $chart->addPoint(new Point("April 2005", 711));
  11.  
  12.     $chart->setTitle("Monthly usage for www.example.com");
  13.     $chart->render();

You can download Libchart from its author's website.

Alternatively you can use JpGraph to produce chart with PHP. However Libchart is much simpler to use and it can be used freely in commercial applications without requiring you to pay extra licensing fees.

Tags: , , , ,

Bookmark Post:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • NewsVine
  • Reddit
  • Netvouz
  • Spurl
  • Furl
  • digg
  • YahooMyWeb
  • del.icio.us

Posted in Uncategorized |

Related Posts

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.