If you are a regular reader of my blog, you will remember my “How to render Fusioncharts completely on the server” post which explained for to render Fusion Charts on the server using PHP. Since then, I have been in discussion with the great support team at Fusion Charts and they have written a .NET assembly that will allow rendering a lot easier than using the PHP that I wrote about previously.
If you don’t know what Fusion Charts is, it is a flash based charting program that creates great looking charts and is really easy to use. You can find it at http://www.fusioncharts.com/.
First up, if you haven’t already, you will need a Windows machine to be able to get .NET working. The best way to do this for LAMP developers is to create a virtual machine, to find out how to do that take a look here and then you will be able to install Windows on a Linux machine.
If you haven’t already, get in touch with the support team at Fusion Charts and ask for the .NET renderer. They will send through a set of .dll files and some sample code to get you started. To get it working on your server, you just need to put the .dll files somewhere that you can reference and then take a look at the sample code. You will need to make sure you have the latest version of Flash installed on the system as it is used to render the chart. This is an easy step to forget, so make sure you have Flash!
The sample code that is sent through is written in C#. I must confess, I do not use C# regularly in my day to day programming but, as with a lot of programming languages, spending a little time on it will make it easier to use and it will be quick to understand. The nuts and bolts of the sample code is the following line:
string fileName = "FusionCharts/fc.png"; ServerSideImageHandler ssh = new ServerSideImageHandler(Server.MapPath("FusionCharts/Column2D.swf"), 500, 400, xml,"", Server.MapPath(fileName)); ssh.BeginCapture();
Hopefully, this is not too complicated. What it is doing is naming an output file location, setting up a new instance of the ServerSideImageHandler class with the appropriate parameters and then running the ssh.BeginCapture(); function that will render the chart and output it to your selected file. You must remember that the output location must be writeable – this is another easy thing to forget.
So, that is the basics of the ServerSideImageHandler. It’s quite easy really when it comes down to it.
There are a few oddities that I have come to notice with the assembly that the guys at Fusion Charts have created.
The ServerSideImageHandler is a great tool from the Fusion Charts team. I think there is still some work to be done on it, and I think it may still be in beta so they shouldn’t be complained about too heavily yet. This tool now allows programmers a lot more functionality with their Fusion Charts and, in my case I have found a massive speed improvement between rendering the charts in the standard way and using this .dll.
If you have liked this post, please use the links in the top right of the screen to share it with others and take a look round the rest of my site for other great posts. Thanks for reading!