tags:

views:

2034

answers:

8

I would like to be able to create a pie chart in PHP. Are there any libraries that will allow me to easily create a pie chart from a list of names and percentages?

+12  A: 
Keith
A: 

If you don't want external images, have a look at php's gd functions. You will probably have to code the pie chart function yourself, but it should fit in 1-2 pages of code and there are lots of examples out there.

Marie Fischer
+2  A: 

There are several librarys:

These three are just some of them, and they are free:

  • XML/SWF Charts - nice Flash diagrams -> puts load of drawing to the client and looks nice!
  • PHP Chart Library - Doesn't look so nice, but calculates charts on the server
  • YUI! - Not specifically for PHP, but nice to wirk with.

Personally I'm using YUI at the moment, but I haven't tried to create pie charts with it. Just line graphs.

(I don't like to use Google for that. They already have enough information about everything. And if they decide to close down their service: You're stuck ;) )

BlaM
A: 

I agree with Keith. The Google Charts API is fantastic. I've never actually used it for pie charts, but for many other types of graphs it was fast, simple and looked fantastic.

Andrew G. Johnson
+2  A: 

Google Charts are a great way to do quick and dirty charts.

AnyChart is the package that we use at my current job that's also very nice. It's flash-based and takes XML inputs so it's pretty language-agnostic. I wrote a PHP wrapper for it in a couple of days.

Mark Biek
A: 

I had never even heard of google charts api...and I should, since I love google. I will look into this some more tonight, Thanks guys!

Adam Lerman
so you connect your php to the google api and it generates the graphs?
HollerTrain
@HollerTrain - no, you specify a URL of an image that the client's browser retrieves from the Google Charts API. Your server doesn't have to do any more work at all.
Keith
A: 

PHP installs comes with a default chart library, GD.

phpinfo();

to see if it's supported.

Olaf
A: 

PChart looks nice

VokilaM