Pie Chart for PHP 3D effect

Source: Internet
Author: User

// If you want to publish this article, please indicate the exit, no outgoing copyright notice, I do not like to see this kind of website. My work website does not indicate the person who is serving Seven {See7di # Gmail.com}

<? Php

// Reprinted Please note: Producer Seven (QQ9256114)
// Parameter meaning (array, abscissa, ordinate, chart width, chart height, chart title, Unit)
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 = '000000' o: spt = '95' adj = '000000' path = 'al10800, 10800 @ 0 @ 0 @ 2 @ 14,10800, 10800,10800, 10800 @ 3 @ 15xe '> </v: shapetype> ";

Echo "<v: shapetype id = '3dtxt 'coordsize = '000000' o: spt = '000000' adj = '000000' 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 = '1970, 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 = '000000'> ";
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 = '000000' 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 = '000000' type = 'gradient'/> ";
Echo "</v: rect> ";

Echo "<v: rect id = 'back' style = 'position: relative; left: 15000; top: 1400; width: 5000; height :". ($ num + 1) x 9000/11 + 200 ). "; 'fillcolor = '# 9cf' stroked = 't'strokecolor = '# 0099ff'> ";
Echo "<v: fill rotate = 't'angle = '-175 'focus = '000000' 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 =' # ffff'> <B> total :". $ 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) x 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 = '000000' type = 'gradient '/> ";
Echo "</v: Rect> ";
Echo "<v: Rect style = 'position: relative; left: 15500; top :". ($ I + 1) x 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) x 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 * sin ($ k5) * 0.7;
$ Txt_y = $ table_top + $ all_height/14-39 + $ R * cos ($ k5) * 0.7*0.5;

$ Titlestr = "name :". $ stat_array [$ I] [1]. "& #13; & #10; Value :". $ stat_array [$ I] [0]. $ unit. "& #13; & #10; Proportion :". ($ 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 = '-000000' method = 'linear sigma 'focus = '000000' type = 'gradient'/> ";
Echo "<o: extrusion v: ext = 'view' on = 't'background= '25' rotationangle = '60' viewpoint = '0, 0' viewpointorigin = '0, 0 'skewamt = '0' lightposition = '-50000,-50000 'lightposition2 = '20140901'/> ";
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 = '# ffff' 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 = '-000000' method = 'linear sigma 'focus = '000000' 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">
<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 => "Project 1", 2 => "# ff1919 "),
1 => array (0 => 1800,1 => "Project 2", 2 => "# ffff19 "),
2 => array (0 => 1700,1 => "Project 3", 2 => "# 1919ff "),
3 => array (0 => 1500,1 => "Project 4", 2 => "#19ff19 "),
4 => array (0 => 1222,1 => "Project 5", 2 => "# fc0 "),
5 => array (0 => 1100,1 => "Project 6", 2 => "# 3cc "),
6 => array (0 => 1000,1 => "Project 7", 2 => "# ff19ff "),
7 => array (0 => 993300 => "Project 8", 2 => "),
8 => array (0 => 700,1 => "Project 9", 2 => "# f60 "),
9 => array (0 => 600,1 => "Project 10", 2 => "# a18c19 ")

);

Table2 ($ total, 140,100,700,400, "3D pie chart", "RMB ");
?>
</Body>
</Html>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.