用Flash图形化数据(二)

2016-01-29 14:35 4 1 收藏

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

【 tulaoshi.com - PHP 】

  让我们烤点甜饼(做饼图)
成功地安装了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://www.tulaoshi.com/php/)

来源:https://www.tulaoshi.com/n/20160129/1493699.html

延伸阅读
设计前的思考 文字是一种记录与传达语言的符号,是人类文明进步的重要标志。随着图形化时代的来临,文字与图形的关系在设计领域起着举足轻重的作用。当练习字体设计时,找有代表性的字体来做,练习有代表性的字体不但可以激发你的创意,还可以提高你的思维能力。文字经过艺术化设计后,可以让文字形象变得情景化、视觉化、强化语言效果,对提升...
标签: 服务器
在Ubuntu系统上安装KDE图形化界面的教程   KDE Plasma 5.2已经发布一段时间了,在本篇中我们将看到如何在Ubuntu 14.10 上安装KDE Plasma 5.2。 Ubuntu的默认桌面环境Unity很漂亮还有很多特性,但是如果你问任何有经验的Linux用户关于桌面定制能力,他的回答将是KDE。KDE在定制上是王者并且它得到流行大概是由于Ubuntu有官方的KDE...
设计前的思考 文字是一种记录与传达语言的符号,是人类文明进步的重要标志。随着图形化时代的来临,文字与图形的关系在设计领域起着举足轻重的作用。当练习字体设计时,找有代表性的字体来做,练习有代表性的字体不但可以激发你的创意,还可以提高你的思维能力。文字经过艺术化设计后,可以让文字形象变得情景化、视觉化、强化语言效果,对提...
标签: FLASH flash教程
本例继续讲解AS的基础知识,今天我们来学习Flash AS入门系列教程第七课:影片剪辑第10节用AS绘图,教程详细讲解了运用AS绘制各种图形的方法,对Flash的AS编程有兴趣的朋友可以到论坛与作者交流。 上一篇文章:Flash as入门(15):filters类滤镜 用AS绘图 AS2.0这我们提供了一些绘图方法,利用这些方法,我们可以绘制一些图形。下面来认识一下...
标签: 服务器
Linux图形化界面下使用命令进行截图的方法   以前在LINUX里面截图都是直接按print screen键或者 alt + print screen。 但是print screen是整个屏幕, alt + print screen是当前窗口。 想要截屏幕中的一块区域用什么来? 答案是import命令, 输入: 代码如下: $ import ddd.jpg 然后鼠标就会变成"+&qu...

经验教程

248

收藏

12
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部