phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


Chart: How to Build Cool Animation Real Time Chart

Tag: 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.

  1. 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)

  2. 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!



Series this article:
Chart: How to Build Wonderfull PHP - Flash Chart
Chart: How to Build Cool Animation Real Time Chart

| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting