Info: Open Flash Chart 2 is out. Version 1.x and these pages will
never disappear and the charts will continue working forever, but further
development on 1.x has stopped. Take a look at version 2 here
Open Flash Chart 2.
How it works.
In this tutorial we are going to try and get the following chart onto your web site:
1: Install files
Before we can start you should have downloaded the Open Flash Chart .zip file.
Open the .zip file and copy the open-flash-chart.swf to the root folder of your web server.
You can move all the files to wherever you want on your webserver, but for this tutorial lets keep
everything nice and simple. When you finish the tutorial and have a working example, then move the
files to a better location. If anything stops working, you know what file you moved and so should
be able to fix the paths.
So, once you have open-flash-chart.swf in the root directory of your web server, copy the
folder ofc-library to the root directory. Set the
permissions of this folder and the .php files inside it so they will run correctly.
Get help with hosting and publishing charts on your
web hosting provider,
make sure you read with reliable web hosting reviews.
2. The Code
Now we can start coding!
First create a new PHP file that will show a simple 'hello world!' page. Copy the following into a new file,
save it as 'chart.php'
<html> <head> </head> <body> <?php
echo 'Hello World!';
?> </body> </html>
Test this page by browsing to it from Friefox: http://your.web.site.com/chart.php.
When that is working, insert the following code into chart.php:
Ugh! Crazy! This is the HTML to insert Open Flash Chart into your HTML page.
3. The Data File
Open Flash Chart downloads a data file, reads it and then displays it as a chart.
The data file has a very specific format, it is readable and possible to create by hand but
we will use the PHP helper class to build it.
Create a new file in the root of your webserver called 'chart-data.php'.
Note in the PHP code you copied into your web page (chart.php), we passed the URL of the data file into the function:
Your data file is now set up. Now browse to the first page you created: http://your.web.site.com/chart.php,
this should now display a chart of 'Spoon Sales'.
To show a different graph with different data you need to edit your chart-data.php page. All of the tutorials show different charts and the code that you
need to put into your data file to make them work.
Of course you can move the .swf and .php files anywhere you want on your server. You will have to change all
the include_once paths to reflect your changes. You may also have to edit the 'ofc-library/open_flash_chart_object.php' file, because
it assumes that open-flash-chart.swf is in the root directory.
But ultimately, I don't want to over explain any of this. I hope the code examples show you how easy it is to make a chart. And if you
have any questions drop me an email.