200分求teechart在asp中的例子,我手头上有LPNG.DLL和TEECHART.OCX (200分)

L

llk

Unregistered / Unconfirmed
GUEST, unregistred user!
200分求teechart在asp中的例子,要有连库,取数据,及详细参数的设置,
我要做的图表参数都是活的,最好有中文注解,或有中文文档,
我手头上有LPNG.DLL和TEECHART.OCX
 
好像有人这样实现过,用DELPHI编写的DLL在ASP中调用后生成图表,保存为图片后,再在网页中输出;不过我没做过,关注此问题!
 
同上,
步骤就是这样。
我用于正式产品中
 
我刚刚开发出这个组件,原理同二楼所说
 
<html>
<body>
<link href="../common/css1.css" rel="stylesheet" type="text/css">
<form action="showchart.asp" method="post" name="form1" class="text1">
<div align="center">
<select name="charttype">
<%
dim selectchart
if request.Form("charttype")<>"" then
if request.Form("charttype")="1" then
selectchart="饼状图"
elseif request.Form("charttype")="2" then
selectchart="柱状图"
elseif request.Form("charttype")="3" then
selectchart="横向柱状图"
elseif request.Form("charttype")="4" then
selectchart="波形图"
elseif request.Form("charttype")="5" then
selectchart="形状图"
end if
response.Write("<option value="&amp
request.Form("charttype") &amp;" selected>"&amp;selectchart&amp;"</option>")
end if
%>
<option value="1">饼状图</option>
<option value="2">柱状图</option>
<option value="3">横向柱状图</option>
<option value="4">波形图</option>
<option value="5">形状图</option>
</select>
图形宽:
<%
if request.Form("width")<>"" then
response.Write("<input name=width type=text id=width size=5 value="&amp;trim(request.Form("width"))&amp;">")
else
response.Write("<input name=width type=text id=width size=5>")
end if
%>
图形高:
<%
if request.Form("height")<>"" then
response.Write("<input name=height type=text id=height size=5 value="&amp;trim(request.Form("height"))&amp;">")
else
response.Write("<input name=height type=text id=height size=5>")
end if
%>
生成质量(0~100)
<%
if request.Form("quality")<>"" then
response.Write("<input name=quality type=text id=quality size=5 value="&amp;trim(request.Form("quality"))&amp;">")
else
response.Write("<input name=quality type=text id=quality size=5>")
end if
%>
<input type="submit" name="Submit" value="生成">
 如果没有看到最新的图形,请<a href="javascript:this.location.reload()"><img src="images/refresh.gif" width="40" height="12" border="0" id="reload"></a></div>
</form>
<div align="center">
<%
'以下不是调用,是用来查一下你这个asp程序运行的服务器绝对路径
dim pathall,path,leftnum
pathall=server.mappath(request.ServerVariables("PATH_INFO"))
leftnum=InStrRev(pathall,"/",-1,1)
path=left(pathall,leftnum)
'以上不是调用,是用来查一下你这个asp程序运行的服务器绝对路径

'调用组件
application.Lock()
dim chart
Set chart = Server.CreateObject("heartsong.chartshow")

chart.chartpath=path '图像生成路径,绝对的
if trim(request.Form("charttype"))<>"" then
chart.charttype=cint(request.Form("charttype"))
else
chart.charttype=1
end if
chart.charttitle="测试一下"
chart.chartname="项目1|项目2|项目3" '这是chart的几项名称,用"|"隔开
chart.chartvalue="100|200|300"  '这是chart的几项名称对应的数据,用"|"隔开
if trim(request.Form("width"))<>"" then
chart.chartwidth=cint(request.Form("width"))
else
chart.chartwidth=600
end if
if trim(request.Form("height"))<>"" then
chart.chartheight=cint(request.Form("height"))
else
chart.chartheight=400
end if
if trim(request.Form("quality"))<>"" then
chart.chartquality=cint(request.Form("quality"))
else
chart.chartquality=80
end if

chart.chartcreate '调用这个方法后自动在服务器当前目录的chartimage文件包里生成图片,并显示在页面上
application.UnLock()
%>
</div>
</body>
</html>
 
上述代码调用heartsong.dll
chart.charttitle="测试一下"
chart.chartname="项目1|项目2|项目3" '这是chart的几项名称,用"|"隔开
chart.chartvalue="100|200|300"  '这是chart的几项名称对应的数据,用"|"隔开
最重要就是这几个,你可以在连接数据库查询后把需要的值传过去,这儿就不写了
 
<SCRIPT Language="VBScript" RUNAT=Server>
dim TChart1
Set TChart1 = Server.CreateObject("TeeChart.TChart")
TChart1.removeallseries
'设置标题
TChart1.Header.Text.Clear
TChart1.Header.Text.Add ("chart测试")
TChart1.Header.Font.Color=RGB(22,5,120)
'TChart1.Header.Font.Size=2  



'赋值
TChart1.AddSeries(1)
TChart1.Series(0).Clear
TChart1.Series(0).Add 100, "Apples", RGB(111,166,196)
TChart1.Series(0).Add 300, "Pears", RGB(101,122,205)
TChart1.Series(0).Add 200, "Bananas", RGB(255,255,0)


' 把图形文件名转化成本地绝对路径表达方式
JpegLocalFile = Server.Mappath( "pic.jpg" )

' 把制定的图形生成、存入本指定文件
TChart1.Export.SaveToJPEGFile JpegLocalFile, False, jpegBestQuality, 100,_
TChart1.Width, TChart1.Height

Response.Write("<img src=pic.jpg>")
</SCRIPT>
 
谢谢大家,搞定了,用了xpims的建议
 
多人接受答案了。
 

Similar threads

顶部