Lightweight free PHP chart library


Please note that this blog has been moved.

Now it has its own domain: mynixworld.info🙂

If you want to read the latest version of this article (recommended) please click here and I open the page for you.

This project has a weird history (like any other project, though).

I have an application and its dedicated website where I’m collecting some sort of data/statistics of the application usage. The statistics are automatically send to me by e-mail in a tabular report layout.

So, two weeks ago I said: “OK, but it should be nice if I would see some kind of trends, so I would grasp in a second what’s going on without chewing 1000 data rows from the tabular report”. That was the moment when I understood that I need some sort of PHP charts. I’ve googled the Internet, I’ve found some candidates, they’ve looked nice and mature projects. But they were more complex than I really need. So, naive like always, I said : “it will take me less time to write 100 lines of code then getting a lightweight bar chart than deploying a mammoth library and trying to figure how it works”.

So I’ve wrote the vertical|horizontal bar chart in like one-two days, then I’ve thought it will require only few hours to extend the code so that it supports points/lines. Then I’ve said it should be a breeze to draw few arcs and to get a pie. Later I’ve seen a pattern so I’ve rewritten some parts of the code, moving the common parts to a base class. After one week, after playing with these charts and some real-life data I’ve understood that they really need to support multiple data sets so I’ve began to rewrite some parts of the code.

One week later it get a final shape so now I am using it in real live.
I’ve thought that it would be nice if someone else could join to the project team and improve the work already done or at least if some other people might try using it.

The whole project has about 1000+ lines of code, the code is fully OOP oriented, well documented and more than anything else is open and free.
I call it “Poor man’s PHP chart library” and it can be found at its bitbucket.org repository.

Features

  • 1000+ full (documented) source code
  • fast speed and small memory footprint
  • easy to setup and to integrate into your PHP apps
  • fully OOP oriented code
  • 2D chart control with header, footer, legend
  • 3D pie chart class
  • standard series style (horizontal|vertical bar and 100% stacked bar, scattered points and line charts with regression line)
  • single and multiple data sets
  • add data by code or load it from CSV files
  • customization of title and axes names, their visibility, fg/bg colour, fonts, grid visibility, legend visibility, margins, bar orientation (vertical|horizontal), tool-tip visibility, anti-aliasing on|off, etc.
  • PHP 5 compatible
  • no external dependency, only PHP with GD support is required

License

This project is licensed under the Apache License, Version 2.0.

Screenshots

click to open its screen shots Wiki page

Here you can try some LIVE charts randomly generated (once the page is loaded just press F5 to get another random sample).

About Eugen Mihailescu

Always looking to learn more about *nix world, about the fundamental concepts of arithmetic, algebra and geometry. I am also passionate about programming, database and systems administration.
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s