用Flash图形化数据(二)

祂叫_柒柒

祂叫_柒柒

2016-01-29 14:35

用Flash图形化数据(二),用Flash图形化数据(二)

  让我们烤点甜饼(做饼图)
成功地安装了PHP地Shockwave Flash支持后,就可以用PHP创建Shockwave文件了。学习的最好方法就是直接跳到程序去,所以下面就让我们看看程序。第一个文件包括怎样使用类的示例代码,同时也显示了如何将一个Flash文件嵌入到HTML文档中。

<?php

// include class needed for flash graph
include("class.pie.flash.php");

mysql_connect ("localhost", "root", "");

$query = "SELECT DISTINCT city_name, COUNT(city_id)
    FROM city
    GROUP BY city_name;";

$result = mysql_db_query ("hermes",$query);

while ($row = mysql_fetch_array ($result)) {
    $city_counts[] = $row["COUNT(city_id)"];
    $city_names[] = $row["city_name"];
}

mysql_free_result ($result);

// Instantiate new object
$graph = new flash_pie($city_counts, "city.swf");

// set graph title (should not exceed about 25 characters)
$graph-pie_title("City Results", 30);

// set graph legend
$graph-pie_legend($city_names);

// show graph
$graph-show();

// free resources
$graph-close();

?  

<html
<head
<meta http=equiv="Expires" content="Fri, Jun 12 1981 08:20:00 GMT"
<meta http=equiv="Pragma" content="no-cache"
<meta http=equiv="Cache-Control" content="no-cache"
<meta http=equiv="Content-Type" content="text/html; charset=iso-8859-1"
<body bgcolor=white
<div align=center
<embed src="https://img.tulaoshi.com/attachment/portal/jcwcj/2005-12/10/05121010212229426.swf"" quality=high loop=false pluginspage="http://www.macromedia.com/
shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"
type="application/x-shockwave-flash" width=600 height=300


<?php

class flash_pie {

// class variables

// setup some global colors
var $r_arr = array(0.1,  1, 0, 1, 0, 1, 0.388235294, 0.4, 0.388235294, 0.929411765);
var $g_arr = array(1,    0, 0, 1, 1, 0, 0.8,         0.4, 0.8,         0.439215686);
var $b_arr = array(0.25, 0, 1, 0, 1, 1, 1,           0.4, 1,           0.043137255);  

var $percents;

function flash_pie($values, $this_file) { //begin constructor
    // to write out code directly to browser, set content header and use "php://stdout"
    //swf_openfile ("php://stdout", 700, 250, 30, 1, 1, 1);
    //header("Content-type: application/x-shockwave-flash");

    swf_openfile ($this_file, 1000, 450, 30, 1, 1, 1);
     
    // set up viewport for flash movie
    swf_ortho2 (-400, 300 , -90, 250);  

    // choose the font we will use for pie graph
    swf_definefont(10, "Mod");

    // get sum of array for percents/slices
    while(list($key,$val) = each($values)) {  
        $sum = $sum + $val;  
    }

    for ($i=0; $i<count($values); $i++) {
        // calculate how big they need to be and then
      &n

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/php/)
展开更多 50%)
分享

猜你喜欢

用Flash图形化数据(二)

PHP
用Flash图形化数据(二)

用Flash图形化数据(一)

PHP
用Flash图形化数据(一)

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

Delphi制作图形化的ComboBox

Delphi
Delphi制作图形化的ComboBox

Samba的图形化配置工具-SWAT

Linux Linux命令 Linux安装 Linux编程 Linux桌面 Linux软件 Linux内核 Linux管理
Samba的图形化配置工具-SWAT

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

字体图形化设计的方法与技巧

平面设计 海报设计 广告设计 画报设计 签名设计 服装设计 名片设计 画册设计 版式设计 商标设计
字体图形化设计的方法与技巧

通向MySQL神秘王国的图形化之路

编程语言 网络编程
通向MySQL神秘王国的图形化之路

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

《全民精灵》宠物图鉴之小火狐

《全民精灵》宠物图鉴之小火狐

一个简单的自动发送邮件系统(三)

一个简单的自动发送邮件系统(三)
下拉加载更多内容 ↓