<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>JavaScript Diagram Builder - PHP & ASP versions</title>
<link rel=stylesheet type="text/css" href="diagram.css" />
</head>
<body>
<TABLE NOBORDER CELLPADDING=2 CELLSPACING=2 WIDTH=720><TR><TD>
<H3>LT Diagram Builder - <a href="#php">PHP</a> & <a href="#asp">ASP</a> versions</H3>
</TD></TR><TR><TD>
Since version 3.0 you can generate images of coordinate diagrams (resp. charts or graphs) at serverside (using PHP or ASP)
and save it as file or send it back as a stream. These 2 versions are independent from the clientside JavaScript version
of the script. The method calls of the 2 scripts are very similar to the method calls of the JavaScript version.
However, the methods for changing the properties of objects (MoveTo, ResizeTo, SetColor, etc.) are not available,
because it is not possible to change these properties after the image has been created. Because of this, the bar, box, dot,
pixel, line, area, arrow and pie objects in the JavaScript version, are methods of the diagram object in the PHP and ASP version.
The usage of the script versions is shown in the following table:<br />
<br />
<table border=0 cellpadding=2 cellspacing=1 bgcolor="#808080">
<tr bgcolor="#cccccc"><td colspan=2>Include the script file</td></tr>
<tr bgcolor="#ffffff"><td>JavaScript</td><td><SCRIPT Language="JavaScript" src="diagram.js"></SCRIPT></td></tr>
<tr bgcolor="#ffffff"><td>PHP</td><td>include ("diagram.php");</td></tr>
<tr bgcolor="#ffffff"><td>ASP</td><td><!--#include file="diagram.asp"--></td></tr>
<tr bgcolor="#cccccc"><td colspan=2>Generate a new diagram</td></tr>
<tr bgcolor="#ffffff"><td>JavaScript</td><td>
//_DiagramTarget=window; //only necessary, if the target is not the current window<br />
D=new Diagram();</td></tr>
<tr bgcolor="#ffffff"><td>PHP</td><td>$D=new Diagram(); <br />
$D->Img=@ImageCreate(480, 320) or die("Cannot create a new GD image.");<br />
ImageColorAllocate($D->Img, 255, 255, 255); //background color</td></tr>
<tr bgcolor="#ffffff"><td>ASP</td><td>
Set D=New Diagram<br />
Set D.Img=CreateObject("gdImage.Images.1")<br />
D.Img.ImageCreate 480, 320<br />
D.Img.ImageColorAllocate 0,255,255,255 'Background Color
</td></tr>
<tr bgcolor="#cccccc"><td colspan=2>Add a bar, box, dot, etc...</td></tr>
<tr bgcolor="#ffffff"><td>JavaScript</td><td>
new Bar(10, 20, 80, 40, "#ff0000", "This is Text", "#000000", "This is TooltipText", "alert(\"This is onClick event.\")");</td></tr>
<tr bgcolor="#ffffff"><td>PHP</td><td>
$D->Bar(10, 20, 80, 40, "#ff0000", "This is Text", "#000000", "This is TooltipText", "alert(\"This is onClick event.\")");</td></tr>
<tr bgcolor="#ffffff"><td>ASP</td><td>
D.Bar 10, 20, 80, 40, "#ff0000", "This is Text", "#000000", "This is TooltipText", "alert(""This is onClick event."")"</td></tr>
</td></tr>
<tr bgcolor="#cccccc"><td colspan=2>Save the image as file</td></tr>
<tr bgcolor="#ffffff"><td>JavaScript</td><td>//not available and not necessary</td>
<tr bgcolor="#ffffff"><td>PHP</td><td>
ImagePng($D->Img, "my_image.png");<br />
ImageDestroy($D->Img);</td></tr>
<tr bgcolor="#ffffff"><td>ASP</td><td>
D.Img.ImagePng 0, Server.mappath("my_image.png")<br />
D.Img.ImageDestroy 0<br />
Set D.Img=Nothing</td></tr>
<tr bgcolor="#cccccc"><td colspan=2>Send the image from the server back to the client as a stream</td></tr>
<tr bgcolor="#ffffff"><td>JavaScript</td><td>//not available and not necessary</td>
<tr bgcolor="#ffffff"><td>PHP</td><td>
header("Content-type: image/png");<br />
ImagePng($D->Img);<br />
ImageDestroy($D->Img);</td></tr>
<tr bgcolor="#ffffff"><td>ASP</td><td>
'There is no direct support but you can get it working this way:<br />
Set objFS=Server.CreateObject("Scripting.FileSystemObject")<br />
FN = objFS.GetTempName()<br />
FN=Server.mappath(FN)<br />
D.Img.ImagePng 0, FN<br />
Set objStream = Server.CreateObject("ADODB.Stream")<br />
objStream.Charset = "x-ansi"<br />
objStream.Type = 2<br />
objStream.Open<br />
objStream.LoadFromFile FN<br />
Response.ContentType = "image/png"<br />
Response.AddHeader "Content-Disposition","filename=image.png"<br />
objStream.Position = 0<br />
objStream.Type = 1<br />
Response.BinaryWrite objStream.Read()<br />
objStream.Close<br />
Set objStream = Nothing<br />
objFS.DeleteFile FN, false<br />
Set objFS=Nothing<br />
D.Img.ImageDestroy 0<br />
Set D.Img=Nothing</td></tr>
</table>
<H3>Differences between <font style="background-color:#cccccc">JavaScript</font> version and
<font style="background-color:#ffccff">PHP</font>/<font style="background-color:#ffffcc">ASP</font> version</H3>
In JavaScript you can use code like<br />
<font style="background-color:#cccccc">
D.Font="font-family:Verdana;font-weight:normal;font-size:10pt;line-height:13pt;";<br />
_BFont="font-family:Verdana;font-weight:bold;font-size:10pt;line-height:13pt;";<br />
</font>
to set the font for the Diagram object or the Bar/Box object.<br />
In <font bgcolor="#ffccff">PHP</font> <font bgcolor="#ffffcc">(ASP)</font> you will use code like<br />
<font style="background-color:#ffccff">$D->Font=4;</font> <font style="background-color:#ffffcc">D.Font=4</font><br />
<font style="background-color:#ffccff">$D->BFont=5;</font> <font style="background-color:#ffffcc">D.BFont=5</font><br />
to set the font(1..5) for the Diagram object or the Bar/Box object.<br />
You can set the <B>font of the bar and box</B> object <I>BFont</I> to <B>-1..-5</B> for <B>vertical text</B>.<br />
For <B>vertical text of the X-axis</B> use a <I>Font</I> value from <B>-1..-5</B>.<br />
<br />
In JavaScript you can use the result of the predefined JavaScript function<br />
<font style="background-color:#cccccc">Date.UTC(2001,0,1,0,0,0);</font> //date/time: year, month(0..11), day, hour, min, sec<br />
as argument for the SetBorder method of a diagram with date/time scale.<br />
In PHP (ASP) you can use the function<br />
<font style="background-color:#ffccff">UTC(2001,1,1,0,0,0);</font> <font style="background-color:#ffffcc">UTC(2001,1,1,0,0,0)</font> //date/time: year, month(1..12), day, hour, min, sec<br />
which is defined in the script file <font style="background-color:#ffccff">diagram.php</font> <font style="background-color:#ffffcc">diagram.asp</font>.<br />
Take care with the difference in the argument for the month!
<hr />
<a name="php"></a><H3>PHP version</H3>
<B>You can use the following methods:</B>
<UL>
<LI><B>$D=new Diagram()</B> //Constructor</LI>
<LI><B>$D->SetFrame($theLeft, $theTop, $theRight, $theBottom)</B> //Screen</LI>
<LI><B>$D->SetBorder($theLeftX, $theRightX, $theBottomY, $theTopY)</B> //World</LI>
<LI><B>$D->SetText($theScaleX, $theScaleY, $theTitle)</B> //Labels (optional)</LI>
<LI><B>$D->ScreenX($theRealX)</B> //Coordinate transformation world->screen</LI>
<LI><B>$D->ScreenY($theRealY)</B> //Coordinate transformation world->screen</LI>
<LI><B>$D->RealX($theScreenX)</B> //Coordinate transformation screen->world</LI>
<LI><B>$D->RealY($theScreenY)</B> //Coordinate transformation screen->world</LI>
<LI><B>$D->GetXGrid()</B> //returns array, which contains min, delta and max of the X grid</LI>
<LI><B>$D->GetYGrid()</B> //returns array, which contains min, delta and max of the Y grid</LI>
<LI><B>$D->SetGridColor($theGridColor[, $theSubGridColor])</B> //Colors of X and Y grid lines</LI>
<LI><B>$D->SetXGridColor($theGridColor[, $theSubGridColor])</B> //Colors of X grid lines</LI>
<LI><B>$D->SetYGridColor($theGridColor[, $theSubGridColor])</B> //Colors of Y grid lines</LI>
<LI><B>$D->Draw($theDrawColor, $theTextColor, $isScaleText[, $theTooltipText[, $theOnClickAction[, $theOnMouseoverAction[, $theOnMouseoutAction]]]])</B> //Display</LI>
</UL>
<B>Before drawing, you can set the following pr
没有合适的资源?快使用搜索试试~ 我知道了~
javascript 编写的绘制图表程序

共67个文件
gif:30个
html:30个
js:5个


完全用javascript编写的绘制图表程序,没有采用额外的插件,可以绘制柱状图,折线图,饼状图等,适用于绘制简单图形。
资源推荐
资源详情
资源评论























收起资源包目录





































































共 67 条
- 1
资源评论

- linxx2_02013-02-21很不错。很全。效果很好
- lunarlili2012-12-04这个图表的效果不错
- ben1234rts2012-10-19这个图表的效果不错啊,谢谢分享
visa_compass
- 粉丝: 0
- 资源: 1

上传资源 快速赚钱
我的内容管理 收起
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

会员权益专享
安全验证
文档复制为VIP权益,开通VIP直接复制
