Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 18 revisions

Category:Charting [h3]Panaci: A Charting Library[/h3]

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 [url=http://sourceforge.net/projects/panachart/]Panachart[/url] charting class released under the GPL by Eugen Fernea.

[h4]Requirements[/h4] PHP 4 or 5. Codeigniter 1.4.0 or higher No changes to CI code The graphics library GD version 2

[b]Update [/b]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 [url=http://codeigniter.com/forums/member/41058/]justhatched[/url] for the patch.

[b]Update [/b]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:

[h4]Features[/h4] 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

[h4]An example plot[/h4] Image:chart.png

[h4]Basic usage[/h4] From your controller [code] $params = array('width' => 450, 'height' => 250, 'margin' => 15, 'backgroundColor' => '#eeeeee'); $this->load->library('chart', $params);[/code]

From your Controller function

[code]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'); }[/code]

[h4]Demo and Documentation[/h4] There is an online demo available at [url=http://bleakview.orgfree.com/]Panaci[/url]

[h4]Download[/h4] A download is available from here [url=http://bleakview.orgfree.com/dl/Panaci.zip]Panaci.zip[/url]

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