FusionCharts plugin for CakePHP

Posted in CakePHP on 02.02.2009.

I've started working on a FusionCharts plugin for CakePHP. Lo and behold the first release.

Update 28/06/2010: For an updated version, read this link.

A while ago, I've accidentally stumbled upon FusionCharts Free (FSF). I liked them, and so I've decided to create this simple plugin for CakePHP.

In fact, this plugin is only a wrapper for the existing FSF class, with CakePHP users in mind. Id est, all params are passed as arrays, and then converted to FSF format internally.

Polar. Bear in mind that this is still a work in progress, so the plugin provides only the basic features of FSF, i.e. rendering charts in a simplistic manner.

The only thing that surprised me was the candlestick chart, which cannot be generated using the FSF PHP class. However, you can manually build the XML and set it as a source for the chart. I didn't try this, but it should be fairly easy to accomplish (in the next release).

Since this is the first release, the only way to use this plugin is to generate the charts using the FusionChartsComponent and then rendering it using the FusionChartsHelper. So basically, the helper doesn't have any tag-rendering capabilities just yet, but it will.

Also, being the first release, I've only wrapped the necessary methods to reconstruct all the demo charts shown in the official FSF download. Since a picture - or in this case a chart - is worth a thousand words, take a look at the demos:

These samples are included in the download, and basically are pseudo unit tests.

To use the plugin, unzip it in your ~/app/plugins folder and add the FusionCharts component and helper to your controller:

var $components = array('FusionCharts.FusionCharts');
var $helpers = array('FusionCharts.FusionCharts');

Look at the code samples within the plugin to see how to generate individual chart types. In my opinion the toughest was Gantt chart, with a lot of information needed for the graph to be rendered properly. That bastard.

In any case, the plugin can be downloaded here:

Please leave any comments and/or suggestions here or send me an e-mail to <neutrinocms[at]>

Edit: Forgot to add this, thanks Bad Dog ;)

Update: This is only necessary for CakePHP 1.2!

Add route to app/config/routes.php

                'plugin' => 'FusionCharts',
                'controller' => 'swf',
                'action' => 'proxy'

Article comments — View · Add

Page 1 of 13
1 · 2 · 3 · 4 · 5 · 6 · 7 · 8 · 9

Bad Dog :: 06.02.2009 00:48:56
Add route to app/config/routes.php

Router::connect('/fusion_charts/swf/:chart', array('plugin' => 'FusionCharts', 'controller' => 'swf', 'action' => 'proxy'));
lecterror :: 07.02.2009 08:54:50
Ouch..yes, I can't believe I forgot to mention that.. I'll do that in the next article on plugin usage. Thanks :-)
Daniel :: 17.02.2009 13:14:32
Hey, I'm fairly new to cake and have been having trouble getting your plugin to work, i've placed the code in the controller as stated and added the routing in in routes.php. I had a look at your examples and placed a pie2d chart render in my view, is there something i'm missing?

lecterror :: 18.02.2009 02:13:58
Hi Daniel!

Can you tell me what part is not working? Are you getting an error message? Can you see in Firebug that you're getting the SWF from the server properly (i.e. no cake error page or 404s)? Feel free to contact me by mail if you think it's necessary.

Daniel :: 18.02.2009 18:50:35
I found the issues, I was using the latest versions of the swf files and Javascript, I've replaced the FusionCharts.php and FusionCharts_Gen.php in the vendors folder and also replaced all the swf files with the latest ones and the FusionCharts.js with the latest an now have full FusionCharts 3 Eye Candy and functionality :D

Wouldn't of been able to do that without your awesome plugin, Cheers