Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1261653
  • 博文数量: 315
  • 博客积分: 10397
  • 博客等级: 上将
  • 技术积分: 3731
  • 用 户 组: 普通用户
  • 注册时间: 2007-03-07 21:21
文章分类

全部博文(315)

文章存档

2015年(10)

2014年(3)

2013年(2)

2012年(8)

2011年(8)

2010年(29)

2009年(59)

2008年(77)

2007年(119)

分类: 系统运维

2008-01-11 11:58:43

  Open Flash Chart是一个开源的Flash图表显示类库,支持.Net,Java,PHP,Perl,Ruby等动态语言来构建动态的Flash数据图表。
相关链接:
OK,闲话少叙,看一个饼图的示例代码:

1、Chart.php
      include_once 'php-ofc-library/open_flash_chart_object.php';
    open_flash_chart_object( 200, 150, 'http://'. $_SERVER['SERVER_NAME'] .'/chart/chart-data.php', false );
  ?>

2、数据文件 chart-data.php

// generate some random data:
    srand((double)microtime()*1000000);
    $max = 50;
    $data = array();
    for( $i=0; $i<12; $i++ ){ 
        $data[] = rand(0,$max);
    }
    // use the chart class to build the chart:
    include_once( 'php-ofc-library/open-flash-chart.php' );
    $g = new graph();
    // Spoon sales, March 2007
    $g->title( 'Spoon sales '. date("Y"), '{font-size: 26px;}' );
    $g->set_data( $data );
    // label each point with its value
    $g->set_x_labels( array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec' ) );
    // set the Y max
    $g->set_y_max( 60 );
    // label every 20 (0,20,40,60)
    $g->y_label_steps( 6 );
    // display the dataecho
    $g->render();
?>

3.不要忘记将open-flash-chart.swf拷贝至根目录下

现在看来,基于数组的PHP有其自身强大的优势,也是其经久不衰的原因所在吧。
基于数组,换个想法,就是基于XML,再换个想法,就是基于简约格式的数据,正是这种简约带动了XML的流行,也推动了PHP的老树新春,所以简约就是时尚不是一句空话,是切切实实的真理。

闲话说完,看看另外两款基于XML作为数据源的Flash Chart

1、PHP/SWF Charts 
相关链接:
    简单示例:chart.php


//include charts.php to access the InsertChart function
include "charts.php";
echo InsertChart ( "charts.swf", "charts_library", "sample.php", 400, 250 );
?>



sample.php
//include charts.php to access the SendChartData function
include_once("charts.php");
SendChartData ();
?>

2.FusionCharts
相关链接:

Data.xml

   
   
   
   
   
   
   
   
   
   
   
   


Chart.html

  
      My First FusionCharts
  
  
     
        
        
        
        
     



各位还在等什么呢,赶快去体验一下Flash图表带来的震撼效果吧!

阅读(3653) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~