Chart: How to Build Cool Animation Real Time ChartTag: Chart, Graphic Category: PHP Classes post: 10 Nov 2007 read: 2,655
Now, I will show you how to build real time chart. It is still using PHP/SWF. It is realy cool animation real time chart. You can develop this idea to your project like tickecting real time report, sales real time report, etc.
In this tutorial, I will use random data (use rand() function in php). But, you can extend with your real time data.
- Assuming, you still work within C:\AppServ\www\test\chart. Create "realtime.php" file and enter following code:
<?php
include "charts.php";
$chart['chart_data'] =
array(
array("","Shop A","Shop B","Shop C","Shop D"),
array("Apple",rand(0,50),rand(0,50),rand(0,50),rand(0,50)),
array("Banana",rand(0,50),rand(0,50),rand(0,50),rand(0,50)),
array("Mango",rand(0,50),rand(0,50),rand(0,50),rand(0,50))
);
$chart['live_update'] =
array(
'url' => "realtime.php",
'delay' => 1 );
SendChartData ($chart);
?>
This chart will be updated by accessing realtime.php ('url'=>'realtime.php'). It will updated every 1 second ('delay'=>1)
- Create "test2.php" and enter following code:
<HTML>
<BODY bgcolor="#FFFFFF">
<?php
include "charts.php";
echo InsertChart ( "charts.swf", "charts_library",
"realtime.php", 400, 250 );
?>
</BODY>
</HTML>
Point your browser to http://localhost/test/chart/test2.php. Its realy simple, isn't it? Simple and cool!
|
|
| Give Your Opinion | Recommend
|