📄 php-swf charts tutorial.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0050)http://www.maani.us/charts/index.php?menu=Tutorial -->
<HTML><HEAD><TITLE>PHP/SWF Charts > Tutorial</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<META
content="chart charts php swf php/swf xml xml/swf tool shockwave flash web graph graphs dynamic data Line column 3D Pie Stacked bar area Candlestick Scatter Mixed Jarir Maani charting plot"
name=Keywords>
<META
content="A simple, yet powerful PHP tool to create attractive web charts from dynamic data."
name=description><LINK href="PHP-SWF Charts Tutorial.files/style.css"
type=text/css rel=stylesheet><LINK href="favicon.ico" type=image/x-icon
rel=icon><LINK href="favicon.ico" type=image/x-icon rel="shortcut icon">
<SCRIPT src="PHP-SWF Charts Tutorial.files/urchin.js" type=text/javascript>
</SCRIPT>
<SCRIPT type=text/javascript>
_uacct = "UA-160905-1";
urchinTracker();
</SCRIPT>
<META content="MSHTML 6.00.2800.1595" name=GENERATOR></HEAD>
<BODY bottomMargin=0 leftMargin=0 topMargin=0 rightMargin=0 Marginwidth="0"
Marginheight="0"><!-- table width must be greater than ever needed to avoid menu shrinking -->
<TABLE height=600 cellSpacing=0 cellPadding=10 width="100%" align=left border=0
frame=void>
<TBODY>
<TR>
<TD class=header vAlign=center colSpan=2 height=30><!-- header start ========================================================= --><!-- <a href="/charts/index.php">PHP/SWF Charts</a> --><A
href="http://www.maani.us/charts/index.php"><FONT color=#aabbcc>PHP/SWF
Charts</FONT></A> <FONT color=#ff4400><SMALL>4.5</SMALL></FONT>
<!--<img src="graphics/blank.gif" width=20 height=1><font color=222222>|</font><img src="graphics/blank.gif" width=20 height=1>
<a href="/slideshow/"><font color=666666>PHP/SWF Slideshow</font></a>--><IMG
height=1 src="PHP-SWF Charts Tutorial.files/blank.gif" width=20><FONT
color=#222222>|</FONT><IMG height=1
src="PHP-SWF Charts Tutorial.files/blank.gif" width=20> <A
href="http://www.maani.us/xml_charts/"><FONT color=#666666>XML/SWF
Charts</FONT></A> <IMG height=1
src="PHP-SWF Charts Tutorial.files/blank.gif" width=20><FONT
color=#222222>|</FONT><IMG height=1
src="PHP-SWF Charts Tutorial.files/blank.gif" width=20> <A
href="http://www.maani.us/xml_slideshow/"><FONT color=#666666>XML/SWF
Slideshow</FONT></A> <IMG height=1
src="PHP-SWF Charts Tutorial.files/blank.gif" width=20><FONT
color=#222222>|</FONT><IMG height=1
src="PHP-SWF Charts Tutorial.files/blank.gif" width=20> <A
href="http://www.maani.us/gauge/"><FONT color=#666666>XML/SWF
Gauge</FONT></A> <!-- header end --></TD></TR>
<TR>
<TD class=menu width=150><!-- menu start ========================================================= --><!-- SiteSearch Google -->
<FORM action=http://www.google.com/search method=get><INPUT type=hidden
value=UTF-8 name=ie> <INPUT type=hidden value=UTF-8 name=oe> <INPUT
class=form maxLength=255 size=10 name=q> <INPUT class=form type=submit value=Search name=btnG> <INPUT type=hidden
value=www.maani.us/charts/ name=domains> <INPUT type=hidden
value=www.maani.us/charts/ name=sitesearch> </FORM>
<HR color=#888888 noShade SIZE=1>
<B><A
href="http://www.maani.us/charts/index.php?menu=Introduction">Introduction</A></B><BR><B><A
href="http://www.maani.us/charts/index.php?menu=Gallery">Gallery</A></B><BR><B><A
href="http://www.maani.us/charts/index.php?menu=Requirements">Requirements</A></B><BR><B><A
href="http://www.maani.us/charts/index.php?menu=Download">Download</A></B><BR><B><A
href="http://www.maani.us/charts/index.php?menu=Installation">Installation</A></B><BR><B><FONT
color=#dddddd>Tutorial</FONT></B><BR><SMALL> </SMALL><BR><SMALL><B> Basics</B></SMALL><BR><SMALL> <A
href="http://www.maani.us/charts/index.php?menu=Tutorial&submenu=Chart_Data">Chart
Data</A></SMALL><BR><SMALL> <A
href="http://www.maani.us/charts/index.php?menu=Tutorial&submenu=Chart_Attributes">Chart
Attributes</A></SMALL><BR><SMALL> <A
href="http://www.maani.us/charts/index.php?menu=Tutorial&submenu=Chart_Source">Chart
Source</A></SMALL><BR><SMALL> </SMALL><BR><B><A
href="http://www.maani.us/charts/index.php?menu=Reference">Reference</A></B><BR><B><A
href="http://www.maani.us/charts/index.php?menu=FAQ">FAQ</A></B><BR>
<HR color=#888888 noShade SIZE=1>
<B><A
href="http://www.maani.us/charts/index.php?menu=License">License</A></B><BR><B><A
href="http://www.maani.us/charts/index.php?menu=Contact_Us">Contact
Us</A></B><BR><IMG height=150
src="PHP-SWF Charts Tutorial.files/blank.gif"> <!-- menu end --></TD>
<TD class=body><!-- body start ========================================================= -->
<TABLE cellSpacing=0 cellPadding=5 width="100%" align=left border=0>
<TBODY>
<TR>
<TD width=40><IMG src="PHP-SWF Charts Tutorial.files/blank.gif"
width=20></TD><!-- left margin -->
<TD vAlign=top>
<P></P>
<TABLE cellSpacing=0 cellPadding=2 width="100%" border=0>
<TBODY>
<TR class=prev_next>
<TD align=left> </TD>
<TD align=right><A
href="http://www.maani.us/charts/index.php?menu=Tutorial&submenu=Chart_Data"><B>next
></B></A> </TD></TR></TBODY></TABLE>
<P></P>
<P> </P>
<P><IMG height=0 src="PHP-SWF Charts Tutorial.files/blank.gif"></P><!-- top margin -->
<P><B><BIG>Basics</BIG></B></P>
<P> </P>
<P><B>1.</B> Type the following text in a text document, name the
document <B>sample.php</B>, and place it on your server:</P><!-- PHP -------------------------------------->
<P></P>
<TABLE cellPadding=10 border=0>
<TBODY>
<TR>
<TD class=php><FONT size=3><PRE><?php
<FONT color=#888888>//include charts.php to access the SendChartData function</FONT>
include "charts.php";
SendChartData ();
?>
</PRE></FONT></TD></TR></TBODY></TABLE>
<P></P><!-- PHP -------------------------------------->
<P> </P>
<P>If <B>charts.php</B> isn't in the same directory as this text
document, the include statement must contain the appropriate file
path. This must be a relative path to prevent the server from
interpreting the php code before including it. Example:
"/includes/charts.php".</P>
<P>Make sure you add the include statement only once in each script
page, or use <B>include_once</B> instead.</P>
<P> </P>
<HR color=#888888 noShade SIZE=1>
<P><B>2.</B> Using another document, create a web page on the same
server, and insert the <B><U><A
href="http://www.maani.us/charts/index.php?menu=Download">charts.swf</A></U></B>
flash file into it with the <B>InsertChart()</B> function like
this:</P><!-- PHP -------------------------------------->
<P></P>
<TABLE cellPadding=10 border=0>
<TBODY>
<TR>
<TD class=php><FONT size=3><PRE><HTML>
<BODY bgcolor="#FFFFFF">
<?php
<FONT color=#888888>//include charts.php to access the InsertChart function</FONT>
include "charts.php";
echo InsertChart ( "charts.swf", "charts_library", "sample.php", 400, 250 );
?>
</BODY>
</HTML>
</PRE></FONT></TD></TR></TBODY></TABLE>
<P></P><!-- PHP -------------------------------------->
<P> </P>
<P>In this example, the <B>InsertChart()</B> function does 4 things:
<P> <B>1.</B> Inserts the flash file
<B>charts.swf</B> into the web page<BR> <B>2.</B>
Tells the tool where to find the library folder
<B>charts_library</B><BR> <B>3.</B> Tells the tool
to get the chart's data from <B>sample.php</B> created in the first
step.<BR> <B>4.</B> Determines the chart's width
and height. </P>
<P> </P>
<P>If <B>charts.php</B>, <B>charts.swf</B>, <B>charts_library</B>,
or <B>sample.php</B> aren't in the same directory as your web page
file, the URLs must contain the appropriate file paths. The path for
charts.php must be relative to prevent the server from interpreting
the php code before including it. Other paths can either be relative
or absolute. Examples: "/includes/charts.php",
"http://yourserver/graphics/charts.swf",
"/libraries/charts_library", "php/sample.php". </P>
<P>If your server isn't configured to process PHP inside .html
pages, either configure it to do so, or save this web page as .php
document.</P>
<P>The <B>InsertChart()</B> function has additional parameters
controlling the canvas color. They are described in the <B><U><A
href="http://www.maani.us/charts/index.php?menu=Reference&submenu=canvas_bg">reference</A></U></B>
section</P>
<P> </P>
<HR color=#888888 noShade SIZE=1>
<P><B>3.</B> Preview the web page in a browser. Because the PHP code
in <B>sample.php</B> doesn't describe a chart, this example
generates a basic, default chart like this:</P>
<OBJECT id=charts
codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0
height=250 width=400
classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000><PARAM NAME="movie" VALUE="charts.swf?library_path=charts_library&stage_width=400&stage_height=250&php_source=php%2FTutorial.php%3Ftime%3D0.97491200+1184727775"><PARAM NAME="quality" VALUE="high"><PARAM NAME="bgcolor" VALUE="#666666">
<EMBED
src='charts.swf?library_path=charts_library&stage_width=400&stage_height=250&php_source=php%2FTutorial.php%3Ftime%3D0.97491200+1184727775'
quality=high bgcolor=#666666 WIDTH=400 HEIGHT=250 NAME='charts'
ALIGN='' swLiveConnect='true' TYPE='application/x-shockwave-flash'
PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED></OBJECT>
<P> </P>
<P>
<HR color=#000000 noShade SIZE=2>
<P></P>
<P><B>Chart Modification</B></P>
<P>To edit the chart, create the necessary variable in
<B>sample.php</B> and pass it as an argument to the SendChartData()
function:</P><!-- PHP -------------------------------------->
<P></P>
<TABLE cellPadding=10 border=0>
<TBODY>
<TR>
<TD class=php><FONT size=3><PRE><?php
<FONT color=#888888>//include charts.php in your script</FONT>
include "charts.php";
<FONT color=#888888>//change the chart to a bar chart</FONT>
$chart [ 'chart_type' ] = "bar";
<FONT color=#888888>//send the new chart data to the charts.swf flash file</FONT>
SendChartData ( $chart );
?>
</PRE></FONT></TD></TR></TBODY></TABLE>
<P></P><!-- PHP -------------------------------------->
<OBJECT id=charts
codeBase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0
height=250 width=400
classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000><PARAM NAME="movie" VALUE="charts.swf?library_path=charts_library&stage_width=400&stage_height=250&php_source=php%2FTutorial.php%3Fchart%3Dbasics2%26time%3D0.97516000+1184727775"><PARAM NAME="quality" VALUE="high"><PARAM NAME="bgcolor" VALUE="#666666">
<EMBED
src='charts.swf?library_path=charts_library&stage_width=400&stage_height=250&php_source=php%2FTutorial.php%3Fchart%3Dbasics2%26time%3D0.97516000+1184727775'
quality=high bgcolor=#666666 WIDTH=400 HEIGHT=250 NAME='charts'
ALIGN='' swLiveConnect='true' TYPE='application/x-shockwave-flash'
PLUGINSPAGE='http://www.macromedia.com/go/getflashplayer'></EMBED></OBJECT>
<P> </P>
<P> </P>
<P></P>
<TABLE cellSpacing=0 cellPadding=2 width="100%" border=0>
<TBODY>
<TR class=prev_next>
<TD align=left> </TD>
<TD align=right><A
href="http://www.maani.us/charts/index.php?menu=Tutorial&submenu=Chart_Data"><B>next
></B></A> </TD></TR></TBODY></TABLE>
<P></P></TD><!--
google =========================================================
<td><img src="graphics/blank.gif" width=40></td><td valign=top bgcolor=eeeeee>
</td>
google =========================================================
--></TR></TBODY></TABLE><!-- body end --></TD></TR>
<TR>
<TD align=middle colSpan=2 height=10><!-- footer start ========================================================= -->
<HR color=#000000 noShade SIZE=2>
<SMALL>Copyright ? 2003-2007, maani.us</SMALL>
<!-- footer end --></TD></TR></TBODY></TABLE>
<P> </P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -