Skip to content
Derek Jones edited this page Jul 5, 2012 · 18 revisions

Category:Library | Category:Library::External | Category:Library::Charts

Panaci: A Charting Library

Panaci is an application library for CodeIgniter. If your application needs to output graphic charts at run-time, such as bar, line area, step or impulse charts, then Panaci makes this rather easy.It utilises the Panachart charting class released under the GPL by Eugen Fernea.

Requirements

PHP 4 or 5. Codeigniter 1.4.0 or higher No changes to CI code The graphics library GD version 2

**Update **2007-04-22: (Please download latest version) Fixed a bug in the class not trapping division by zero. Added an initialization routine, this will improve handling of multiple plots to one page Thx to justhatched for the patch.

**Update **2006-11-04: There are now 2 versions, one is for CI v1.4.x and the other for CI v1.5.0

Please note, this is NOT a commercial grade library such as jpgraph or chartdirector, but it is quite adequate for basic plots and provides the following features:

Features

Compact (23k) and efficient code. 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 eg. bars, lines, dots, areas, step, impulse Supports multiple series plots on the same image Supports automatic scaling of plot area by axis labels size

An example plot

Image:chart.png

Basic usage

From your controller

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

From your Controller function

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->setFormat(0,',','.');

  $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);
  $this->chart->plot('./images/file.png');

  $this->load->view('graph');
}

Demo and Documentation

There is an online demo available at Panaci

Download

A download is available from here Panaci

The file contains everything you need, including documentation and examples. Unzip the file into a temporary directory, open the index.html file for instructions.

I would like to know if anyone is using this, it might help persuade Eugen to release his latest version of Panachart. He has been sitting on it for a bit.

Enjoy Oscar Bajner

Clone this wiki locally