Free Web Hosting

Panaci :: A Charting Library for CodeIgniter

If your web applications require dynamically created charts or graphs, then this library may just be what you need.

In the spirit of CodeIgniter, the library is open source, small, (20KB) efficient and Object-oriented. It will run on either PHP 4 or 5, with no changes to core CI code.

The Panachart library is written by Eugen Fernea and is licensed under the GPL.
Modifications to provide the code as a Code Igniter library by Oscar Bajner.

Minimum requirements:
PHP version 4 or 5.
CodeIgniter framework version 1.4.0 or higher.
GD graphics library version 2.

Bandwidth friendly, the average image size for a 450*250 image is around 2K
Can output to a file or directly to an HTTP stream
Supports several plot types: bars, lines, dots, areas, step, impuls
Supports multiple series plots on the same image
Supports automatic scaling of plot area by axis labels size
More advanced plots will be supported in future versions.

The library has been updated: 22 April 2007:
1. A division by zero bug has been fixed
2. Improved class initialization, to handle situations where multiple plots are made on one page.
Patch provided by justhatched.

Download the library:

Example usage: In your controller constructor,

$params = array('width' => 450, 'height' => 250, 'margin' => 15, 'backgroundColor' => '#eeeeee');
$this->load->library('chart', $params);

In your controller functions,

function graph()
  $data_2001 = array(43,163,56,21,0,22,0,5,73,152,123,294);
  $data_2002 = array(134,101,26,46,22,64,0,28,8,0,50,50);
  $Labels = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');

  $this->chart->setTitle("Annual Rainfall","#000000",2);
  $this->chart->setLegend(SOLID, "#444444", "#ffffff", 2);
  $this->chart->setPlotArea(SOLID,"#444444", '#dddddd');

  $this->chart->addSeries($data_2001,'dot','2001 ', SOLID,'#00ff00', '#00ff00');
  $this->chart->addSeries($data_2002,'area','2002 ', SOLID,'#ff0000', '#00ffff');

  $this->chart->setXAxis('#000000', SOLID, 1, "2001");
  $this->chart->setYAxis('#000000', SOLID, 2, "Rainfall in MM");
  $this->chart->setLabels($Labels, '#000000', 1, HORIZONTAL);
  $this->chart->setGrid("#bbbbbb", DASHED, "#bbbbbb", DOTTED);


Will produce the chart below:

Documentation on this page

Page rendered in 0.0163 seconds