顯示文章

這裡允許您檢視這個會員的所有文章。請注意, 您只能看見您有權限閱讀的文章。


主題 - see7di

頁: [1]
1
再發一個我寫的小東西,請大家幫忙測試,執行效果如下圖:
[attachment=1]

實現代碼如下:
//转载请标注:制作人Seven(QQ9256114)
//参数含义(数组,横坐标,纵坐标,图表的宽度,图表的高度,图表标题,单位)
Function table2($stat_array,$table_left,$table_top,$all_width,$all_height,$table_title,$unit){
$num =Count($stat_array);

For($i=0;$i<$num;$i++){
Static $allvalues=0;
$allvalues = $allvalues+$stat_array[$i][0];
}

$pie=Array();
For($i=0;$i<$num;$i++){
Static $k=0;
$pie[$i]=Round($stat_array[$i][0]/$allvalues,2);
$k=$k+$pie[$i];
}

$pie[$num]=Round((1-$k),2);

Echo "<v:shapetype id='Cake_3D' coordsize='21600,21600' o:spt='95' adj='11796480,5400' path='al10800,10800@0@0@2@14,10800,10800,10800,10800@3@15xe'></v:shapetype>";

Echo "<v:shapetype id='3dtxt' coordsize='21600,21600' o:spt='136' adj='10800' path='m@7,l@8,m@5,21600l@6,21600e'> ";
Echo "<v:path textpathok='t' o:connecttype='custom' o:connectlocs='@9,0;@10,10800;@11,21600;@12,10800' o:connectangles='270,180,90,0'/>";
Echo "<v:textpath on='t' fitshape='t'/>";
Echo "<o:lock v:ext='edit' text='t' shapetype='t'/>";
Echo "</v:shapetype>";

Echo "<v:rect id='background' style='position:absolute;left:".$table_left."px;top:".$table_top."px;WIDTH:".$all_width."px;HEIGHT:".$all_height."px;' fillcolor='#EFEFEF' strokecolor='gray'>";
Echo "<v:shadow on='t' type='single' color='silver' offset='4pt,4pt'/>";
Echo "</v:rect>";

Echo "<v:group ID='table' style='position:absolute;left:".$table_left."px;top:".$table_top."px;WIDTH:".$all_width."px;HEIGHT:".$all_height."px;' coordsize = '21000,11500'>";
Echo "<v:Rect style='position:relative;left:500;top:200;width:20000;height:800'filled='false' stroked='false'>";
Echo "<v:TextBox inset='0pt,0pt,0pt,0pt'>";
Echo "<table width='100%' border='0' align='center' cellspacing='0'>";
Echo "<tr><td align='center' valign='middle'><div style='font-size:15pt; font-family:黑体;'><B>".$table_title."</B></div></td></tr>";
Echo "</table>";
Echo "</v:TextBox>";
Echo "</v:Rect> ";

Echo "<v:rect id='back' style='position:relative;left:500;top:1000;width:20000; height:10000;' onmouseover='movereset(1)' onmouseout='movereset(0)' fillcolor='#9cf' strokecolor='#888888'>";
Echo "<v:fill rotate='t' angle='-45' focus='100%' type='gradient'/>";
Echo "</v:rect>";

Echo "<v:rect id='back' style='position:relative;left:15000;top:1400;width:5000; height:".(($num+1)*9000/11+200).";' fillcolor='#9cf' stroked='t' strokecolor='#0099ff'>";
Echo "<v:fill rotate='t' angle='-175' focus='100%' type='gradient'/>";
Echo "<v:shadow on='t' type='single' color='silver' offset='3pt,3pt'/>";
Echo "</v:rect>";

Echo "<v:Rect style='position:relative;left:15500;top:1500;width:4000;height:700' fillcolor='#000000' stroked='f' strokecolor='#000000'>";
Echo "<v:TextBox inset='8pt,4pt,3pt,3pt' style='font-size:11pt;'><div align='left'><font color='#ffffff'><B>总数:".$allvalues.$unit."</B></font></div></v:TextBox>";
Echo "</v:Rect> ";

For($i=0;$i<$num;$i++){
Echo "<v:Rect id='rec".$i."' style='position:relative;left:15400;top:".(($i+1)*9000/11+1450).";width:4300;height:800;display:none' fillcolor='#efefef' strokecolor='".$stat_array[$i][2]."'>";
Echo "<v:fill opacity='.6' color2='fill darken(118)' o:opacity2='.6' rotate='t' method='linear sigma' focus='100%' type='gradient'/>";
Echo "</v:Rect>";
Echo "<v:Rect style='position:relative;left:15500;top:".(($i+1)*9000/11+1500).";width:600;height:700' fillcolor='".$stat_array[$i][2]."' stroked='f'/>";
Echo "<v:Rect style='position:relative;left:16300;top:".(($i+1)*9000/11+1500).";width:3400;height:700' filled='f' stroked='f'>";
Echo "<v:TextBox inset='0pt,5pt,0pt,0pt' style='font-size:9pt;'><div align='left'>".$stat_array[$i][1].":".$stat_array[$i][0].$unit."</div></v:TextBox>";
Echo "</v:Rect> ";
}

Echo "</v:group>";

$k1=180;
$k4=10;
For($i=0;$i<$num;$i++){
$k2=360*$pie[$i]/2;
$k3=$k1+$k2;
IF($k3>=360){
   $k3=$k3-360;
}
$kkk=(-11796480*$pie[$i]+5898240);

$k5=3.1414926*2*(180-($k3-180))/360;
$R=$all_height/2;
$txt_x = $table_left+$all_height/8-30+$R+$R*sin($k5)*0.7;
$txt_y = $table_top+$all_height/14-39+$R+$R*cos($k5)*0.7*0.5;

$titlestr = "名 称:".$stat_array[$i][1]."&#13;&#10;数 值:".$stat_array[$i][0].$unit."&#13;&#10;所占比例:".($pie[$i]*100)."% ";
Echo "<div style='cursor:hand;'>";
Echo "<v:shape id='cake".$i."' type='#Cake_3D' title='".$titlestr."' style='position:absolute;left:".($table_left+$all_height/8)."px;top:".($table_top+$all_height/14)."px;WIDTH:".$all_height."px;HEIGHT:".$all_height."px;rotation:".$k3.";z-index:".$k4."' adj='".$kkk.",0' fillcolor='".$stat_array[$i][2]."' onmouseover='moveup(cake".$i.",".($table_top+$all_height/14).",txt".$i.",rec".$i.")'; onmouseout='movedown(cake".$i.",".($table_top+$all_height/14).",txt".$i.",rec".$i.");'>";
Echo "<v:fill opacity='60293f' color2='fill lighten(120)' o:opacity2='60293f' rotate='t' angle='-135' method='linear sigma' focus='100%' type='gradient'/>";
Echo "<o:extrusion v:ext='view' on='t'backdepth='25' rotationangle='60' viewpoint='0,0'viewpointorigin='0,0' skewamt='0' lightposition='-50000,-50000' lightposition2='50000'/>";
Echo "</v:shape>";
Echo "<v:shape id='txt".$i."' type='#3dtxt' style='position:absolute;left:".$txt_x."px;top:".$txt_y."px;z-index:20;display:none;width:50; height:18;' fillcolor='#ffffff' onmouseover='ontxt(cake".$i.",".($table_top+$all_height/14).",txt".$i.",rec".$i.")'>";
Echo "<v:fill opacity='60293f' color2='fill lighten(120)' o:opacity2='60293f' rotate='t' angle='-135' method='linear sigma' focus='100%' type='gradient'/>";
Echo "<v:textpath style='font-family:'宋体';v-text-kern:t' trim='t' fitpath='t' string='".($pie[$i]*100)."%'/>";
Echo "<o:extrusion v:ext='view' backdepth='8pt' on='t' lightposition='0,0' lightposition2='0,0'/>";
Echo "</v:shape>";
Echo "</div>";
$k1=$k1+$k2*2;
IF($k1>=360){
   $k1=$k1-360;
}
IF($k1>180){
   $k4=$k4+1;
}else{
   $k4=$k4-1;
}
}
}
?>
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<STYLE>v\:* { Behavior: url(#default#VML)}o\:* { behavior: url(#default#VML)}</STYLE>
</head>
<body>

<SCRIPT LANGUAGE="JavaScript">
<!--
onit=true
num=0
function moveup(iteam,top,txt,rec){
temp=eval(iteam)
tempat=eval(top)
temptxt=eval(txt)
temprec=eval(rec)
at=parseInt(temp.style.top)
temprec.style.display = "";
if (num>27){
   temptxt.style.display = "";
}
if(at>(tempat-28)&&onit){
   num++
   temp.style.top=at-1
   Stop=setTimeout("moveup(temp,tempat,temptxt,temprec)",10)
}else{
   return
}
}
function movedown(iteam,top,txt,rec){
temp=eval(iteam)
temptxt=eval(txt)
temprec=eval(rec)
clearTimeout(Stop)
temp.style.top=top
num=0
temptxt.style.display = "none";
temprec.style.display = "none";
}
function ontxt(iteam,top,txt,rec){
temp = eval(iteam);
temptxt = eval(txt);
temprec = eval(rec)
if (onit){
   temp.style.top = top-28;
   temptxt.style.display = "";
   temprec.style.display = "";
}
}
function movereset(over){
if (over==1){
   onit=false
}else{
   onit=true
}
}
-->
</script>
<?php
$total=array(
    0=>array(0=>2000,1=>"项目1",2=>"#ff1919"),
    1=>array(0=>1800,1=>"项目2",2=>"#ffff19"),
    2=>array(0=>1700,1=>"项目3",2=>"#1919ff"),
    3=>array(0=>1500,1=>"项目4",2=>"#19ff19"),
    4=>array(0=>1222,1=>"项目5",2=>"#fc0"),
    5=>array(0=>1100,1=>"项目6",2=>"#3cc"),
    6=>array(0=>1000,1=>"项目7",2=>"#ff19ff"),
    7=>array(0=>800,1=>"项目8",2=>"#993300"),
    8=>array(0=>700,1=>"项目9",2=>"#f60"),
    9=>array(0=>600,1=>"项目10",2=>"#a18c19")

);


table2($total,140,100,700,400,"三维饼状图","元");
?>
</body>
</html>


2
這是我前幾天寫的,請大家幫忙測試一下
$work=StrToLower(_r($_GET["work"]));
Switch ($work){
Case "export":
_Export();
Break;
Case "exportloop":
_ExportLoop();
Break;
Case "tozip":
_Tozip();
Break;
}
/*---------------------------------*/
Function _Export(){
Global $Mysql,$work;
$f1=_r($_GET["f1"]);

//如果是第一个回圈
IF($f1=="1"){
   //首先获取一次是否指定了备份表
   $tables=$_REQUEST["tables"];
   Echo ($tables);
   IF(Empty($tables)){
    //得到数据表
    $Result=$Mysql->View("Show Tables From ".BLK_SysDbname."");
    Foreach($Result as $val){
     $tables[]=$val[0];
    }
   }Else{
    $tables=Explode(",", $tables);
    $tables=Array_Filter($tables,'_nul');
   }
   $_SESSION['Tab'] = $tables;

   //初始化数据表表序号
   $nList=0;
   //初始化文件序号
   $nFile=1;
   //用来做比较,看看是否已经写入建表信息
   $_SESSION['nList'] = ($nList-1);
}Else{
   $nList=_r($_GET["nList"]);
   $nFile=_r($_GET["nFile"]);
}
$iSql = '';        //抓取的内容
$fPath = "Cache/";      //保存目录
$cName = "DB_Export.sql";    //缓存文件
$_Tab = $_SESSION['Tab'][$nList]; //当前所操作的表
$fName = "DB".Date('_md_').$nFile.".sql";

//判断目录状况
IF(!Is_writable($fPath)){Exit("数据无法备份到服务器!请检查 ".$fPath." 目录是否可写。");}

//判断是否备份完毕
IF(Count($_SESSION['Tab'])<=$nList){
   @Unlink($fPath.$cName);
   For($i=1;$i<=$nFile;$i++){
    $FileArr[]=$fPath."DB".Date('_md_').$i.".sql";
   }
   $_FileName="DB".Date('_md').".zip";
   Tozip($FileArr,$_FileName,2,2);

   Alert("","?work=backdb&rback=1");
   Die();
}

//每次读一个表,得到头信息和建表信息
IF($_SESSION['nList'] < $nList){
   IF($nFile==1 And $nList==0){
    //删除文件
    For($i=1;$i<1000;$i++){
     IF(File_exists($fPath."DB".Date('_md_').$i.".sql")){
      @Unlink($fPath."DB".Date('_md_').$i.".sql");
     }Else{
      Break;
     }
    }
    //建立文件
    File_put_contents($fPath.$fName,"");
    File_put_contents($fPath.$cName, "");
    $iSql = "# Create by ".BLK_SysName."\n# Create time ".Date('Y-m-d')."\n# Mysql Version ".$Mysql->Version()."\n# PHP Version ".@phpversion()."\n# --------------------------------------------------------\n\nSET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";\n";
   }
   $iSql .= "DROP TABLE IF EXISTS `".$_Tab."`;\n";
   $_iSql = Mysql_fetch_row(mysql_query("SHOW CREATE TABLE ".$_Tab.""));
   $iSql .= $_iSql[1].";\n\n";
}

//写入头信息
$iSql=Trim(File_get_contents($fPath.$fName)."\n\n".$iSql);
File_put_contents($fPath.$fName,$iSql);

//得到缓存的内容并判断是否为空,如果为空,抓取当前表所有的内容放入缓存
$_Cache=Trim(File_get_contents($fPath.$cName));
IF(Empty($_Cache)){
   $_Cache=DropInfo($_Tab);
   File_put_contents($fPath.$cName,$_Cache);
}

//循环抓取,直到备份文件满额为止(因为循环不能及时得到文件尺寸)
Alert("","?work=exportloop&nList=".$nList."&nFile=".$nFile."&Session=".$Session."","",10);
}
/*---------------------------------*/
Function _ExportLoop(){
Global $work;
$nList=_r($_GET["nList"]);
$nFile=_r($_GET["nFile"]);
$iSql = '';        //抓取的内容
$fPath = "Cache/";      //保存目录
$fSize = (BLK_SysDbsplit*1024);   //文件大小,2048K=2M
$fName = "DB".Date('_md_').$nFile.".sql";
$cName = "DB_Export.sql";

//显示进度
Echo "<br><br><strong>备份正在进行中请稍候,现在正在生成 <span style='color:red;'>".$fName."</span></strong><br><br>";
Echo "<br>".(FileSize($fPath.$fName))."<br>".$fSize."<br><br>";
Echo Loading((FileSize($fPath.$fName)),$fSize);

//如果备份文件满了
IF(((FileSize($fPath.$fName))+9000)>$fSize){
   $nFile++;       //备份文件序号加一
   $_SESSION['nList'] = $nList; //防止再次写入建表信息
   Alert("","?work=export&nList=".$nList."&nFile=".$nFile."&Session=".$Session."","",30);
}Else{
   //取得现在缓存的内容,编译为数组
   $_Cache = (File($fPath.$cName));

   //为备份文件抓取需要的数据,每次4条
   $_Info=Array();
   For($i=0;$i<2;$i++){
    $_Info[]=$_Cache[$i];
   }

   //得到新的缓存数据
   $_Cache=array_diff_key($_Cache,$_Info);
   File_put_contents($fPath.$cName,Trim(Implode("",$_Cache)));

   //重新整理备份文件的内容并写入
   $iSql=Trim(File_get_contents($fPath.$fName))."\n".Trim(Implode("",$_Info));
   File_put_contents($fPath.$fName,$iSql);

   //如果备份文件未满而缓存空了,则进入下一个表
   IF(Count($_Cache)<1){
    $nList++;
    $_SESSION['nList'] = ($nList-1);
    Alert("","?work=export&nList=".$nList."&nFile=".$nFile."&Session=".$Session."","",10);
   //如果备份文件未满而缓存未空,则循环该函数
   }Else{
    Alert("","?work=exportloop&nList=".$nList."&nFile=".$nFile."&Session=".$Session."","",10);
   }
}
}

頁: [1]