请问如何用asp画出条形图、饼形图、k线图等统计图形?

sun_2000 2002-09-26 10:18:50
请问如何用asp画出条形图、饼形图、k线图等统计图形?
...全文
327 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuge1002 2003-03-15
  • 打赏
  • 举报
回复
1
liuyutinglyt 2002-09-26
  • 打赏
  • 举报
回复
BackStyle:指定背景为透明(1)或不是(0)
ColorScheme:预定的色彩配置,有0、1、2三种
ColumnIndex:指定行的索引值
RowIndex:指定列的索引值
ColumnName:指定行的标题名称
RowName:指定列的标题名称
Columns:给予数据数列的行数
Rows:给与数据数列的列数
Data:指定数据项,较常用的是二维的方式,例如:
<Param name="Data[0][0] value="20">
DataItem:图标的数据项(数据点),搭配RowIndex与ColumnIndex使用,如果上述两个属性均为0时,DataItem即为Data[0][0]的内含值
DisplayLegend:是否显示图例,1为是,0为否
GridPlacement:网格线的位置,1是前景,0是背景
hgridStyle:是否显示水平网格线,1为是,0为否
vgridStyle:是否显示垂直网格线,1为是,0为否
Scale:指定缩放的比例,内定值是100%,建议不要更动。
URL:图表来源的URL地址,若指定此项,便可省略上述之Data参数,改以一文本文件代替,例如:
<param name="URL" value="sales.txt">
liuyutinglyt 2002-09-26
  • 打赏
  • 举报
回复
需要使用Chart Control。它可以从微软的网站下载。成功下载后会顺道安装于系统中,所以理论上无需使用者操心。如果不是非常顺利的话,只好以手动方式安装之。
codebase=http://activex.microsoft.com/controls/iexplorer/x86/iechart.cab。
下面介绍一下它的属性:
ChartType=0:Simple Tie Chart(简单的饼图)
1:Special Pie Chart(特殊的饼图)
2:Simple Point Chart(简单点状图,或称XY散布图)
3:Stacked Point Chart(均匀点状图)
4:Full Point Chart(完全点状图)
5:Simple Line Chart(简单线形图,或称趋势图)
6:Stacked Line Chart(均匀线行图)
7:Full Line Chart(完全线形图)
8:Simple Area Chart(简单区域图)
9:Stacked Area Chart(均匀区域图)
10:Full Area Chart(完全区域图)
11:Simple Column Chart(简单柱形图)
12:Stacked Column Chart(均匀柱形图)
13:Full Column Chart(完全柱形图)
14:Simple Bar Chart(简单横条图)
15:Stacked Bar Chart(均匀横条图)
16:Full Bar Chart(完全横条图)
17:HLC SimpleStock Chart(最高、最低与收盘价)
18:HLC WSJ Simple Stock Chart
19:OHLC SimpleStock Chart(开盘、最高、最低与收盘价)
20:OHLC WSJ SimpleStock Chart
arclala 2002-09-26
  • 打赏
  • 举报
回复
怎样在ASP里面创建统计图表 (条形图 )

--------------------------------------------------------------------------------
转载自:编程爱好者 人气:1261

<%
REM 首先我们设计一个ShowCart函数,其中
REM aValues 是一个数值数组
REM aLables 是横坐标的标号
REM strTitle是这个统计图的标题
REM strXAxisLable X轴的标签
REM strYAxisLable Y轴的标签
Sub ShowChart(ByRef aValues, ByRef aLabels, ByRef strTitle, ByRef strXAxisLabel, ByRef strYAxisLabel)
" 你可以随便改变的图形常数
" 单位是屏幕像素点
Const GRAPH_WIDTH = 450 " 图形宽度
Const GRAPH_HEIGHT = 250 " 图形
Const GRAPH_BORDER = 5 " 坐标线宽度
Const GRAPH_SPACER = 2 " 统计条之间的距离
Const TABLE_BORDER = 0
" 变量声明
Dim I
Dim iMaxValue
Dim iBarWidth
Dim iBarHeight
" 取得aValues最大值
iMaxValue = 0
For I = 0 To UBound(aValues)
If iMaxValue < aValues(I) Then iMaxValue = aValues(I)
Next "I
" 计算每条图形的宽度
iBarWidth = (GRAPH_WIDTH \ (UBound(aValues) + 1)) - GRAPH_SPACER
" 开始绘图
%>
<TABLE BORDER="<%= TABLE_BORDER %>" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD COLSPAN="3" ALIGN="center"><H2><%= strTitle %></H2></TD>
</TR>
<TR>
<TD VALIGN="center"><B><%= strYAxisLabel %></B></TD>
<TD VALIGN="top">
<TABLE BORDER="<%= TABLE_BORDER %>" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD ROWSPAN="2"><IMG SRC="./images/spacer.gif" BORDER="0" WIDTH="1" HEIGHT="<%= GRAPH_HEIGHT %>"></TD>
<TD VALIGN="top" ALIGN="right"><%= iMaxValue %> </TD>
</TR>
<TR>
<TD VALIGN="bottom" ALIGN="right">0 </TD>
</TR>
</TABLE>
</TD>
<TD>
<TABLE BORDER="<%= TABLE_BORDER %>" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD VALIGN="bottom"><IMG SRC="./images/spacer_black.gif" BORDER="0" WIDTH="<%= GRAPH_BORDER %>" HEIGHT="<%= GRAPH_HEIGHT %>"></TD>
<%
" 对数组所有数值进行循环,绘制条形图!
For I = 0 To UBound(aValues)
iBarHeight = Int((aValues(I) / iMaxValue) * GRAPH_HEIGHT)
" 因为浏览器会忽略0高度的条形图,所以用1代替!
If iBarHeight = 0 Then iBarHeight = 1
%>
<TD VALIGN="bottom"><IMG SRC="./images/spacer.gif" BORDER="0" WIDTH="<%= GRAPH_SPACER %>" HEIGHT="1"></TD>
<TD VALIGN="bottom"><IMG SRC="./images/spacer_red.gif" BORDER="0" WIDTH="<%= iBarWidth %>" HEIGHT="<%= iBarHeight %>" ALT="<%= aValues(I) %>"></A></TD>
<%
Next "I
%>
</TR>
<TR>
<TD COLSPAN="<%= (2 * (UBound(aValues) + 1)) + 1 %>"><IMG SRC="./images/spacer_black.gif" BORDER="0" WIDTH="<%= GRAPH_BORDER + ((UBound(aValues) + 1) * (iBarWidth + GRAPH_SPACER)) %>" HEIGHT="<%= GRAPH_BORDER %>"></TD>
</TR>
<% " 检查横坐标数组是否有效! %>
<% If IsArray(aLabels) Then %>
<TR>
<TD><!-- 留点空间 --></TD>
<% For I = 0 To UBound(aValues) %>
<TD><!-- 留点空间 --></TD>
<TD ALIGN="center"><FONT SIZE="1"><%= aLabels(I) %></FONT></TD>
<% Next "I %>
</TR>
<% End If %>
</TABLE>
</TD>
</TR>
<TR>
<TD COLSPAN="2"><!-- 使下一个TD元素居中--></TD>
<TD ALIGN="center"><BR><B><%= strXAxisLabel %></B></TD>
</TR>
</TABLE>
<%
End Sub
%>
<%
" 一个带有横坐标的条形图
ShowChart Array(6, 10, 12, 18, 23, 26, 27, 28, 30, 34, 37, 45, 55), _
Array("P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", _
"P10", "P11", "P12", "P13"), "连续几个月的销售额", "X 轴", "Y 轴"
" 空行
Response.Write "<BR>" & vbCrLf
Response.Write "<BR>" & vbCrLf
Response.Write "<BR>" & vbCrLf
" 构造一个由随机数组成的数组
Dim I
Dim aTemp(49)
Randomize
For I = 0 to 49
aTemp(I) = Int((50 + 1) * Rnd)
Next "I
" 由随机数组生成的条形图
ShowChart aTemp, "这不是一个数组!", "随机条形图", "序号", "随机数"
%>
iStringTheory 2002-09-26
  • 打赏
  • 举报
回复
asp实现k线图(在线)
2002-4-22 动网先锋

可以考虑使用MSCHART,但是缺点是显示不太好看,不很专业,同时,如果客户端没有装的话就比较麻烦,因为显示不出来,所以一般的网站都采用生成图片的方式。下面给出MSCHART的一些东西,可以自己考虑着使用,我没有使用过其他的控件,所以不能给你满意的答复。另外附给你一个网址,www.tjinfo.com,里面有个调查题,使用了MSCHART,但是没有用折线,这个你可以自己定义的,CSDN的调查也使用了MSCHART。
=================================================================
看看我的这篇总结,你会受益匪浅!
关于Mschart的说明文档
MsChart是微软制作的功能强大的图表工具,用它可以很方便的建立各种图表。制作各种3维2维的直方图,折线图。结合前一段时间我对Mschart组件的认识,谈谈Mschart组件的使用方法。
1、 Chart Activex控件:
In the HTML page, insert an <OBJECT> tag for the License Manager object before any other <OBJECT> tags. The License Manager is an ActiveX control that is installed with Internet Explorer.
NOTE: This CLASSID, "5220cb21-c88d-11cf-b347-00aa00a28331", is for the License Manager and not for your ActiveX controls. You must use the same CLASSID every time you refer to the LPK file. In addition, you should keep the Name property of the <PARAM> tag as "LPKPath", and set the Value property for the <PARAM> tag of the License Manager object to the LPK file name and path. This path may be a relative path but must not refer to a UNC share or a URL on another domain.
Because you can only have one LPK file for each HTML page, make sure that you include all of the licensed ActiveX Controls for the page when you generate your LPK file. For example:
<object CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331"
id="Microsoft_Licensed_Class_Manager_1_0">
<param NAME="LPKPath" VALUE="mschart.lpk">
</object>
Insert the <OBJECT> tag for your licensed control afterward. For example, an HTML page that displays the Microsoft Masked Edit control looks like this.
Here I downloaded the file mschart.cab from Microsoft's website. It has been digitally signed.
<OBJECT classid="clsid:3A2B370C-BA0A-11D1-B137-0000F8753F5D"
id=mschart1 style="HEIGHT: 326px; WIDTH: 651px" CODEBASE="mschart.cab"></OBJECT>
You can look this acticle if you need help.
http://support.microsoft.com/support/kb/articles/Q159/9/23.ASP
2、 Mschart组件的一些常用属性介绍
a、charttype:图形的类型
charttype=0>三维直方图
charttype=1>二维直方图
charttype=2>三维折线图
charttype=3>二维折线图
charttype=4>三维面积图
charttype=5>二维面积图
charttype=14>饼图
b、showlegend:是否显示解说
c、titletext:标题
d、Columncount: The number of data columns
e、Rowcount:The number of data rows
f、Footnotetext:The footnote text.
g、Plot: Returns a reference to a Plot object that describes the area upon which a chart is displayed.
h、row: A row number in the current column. Rows are numbered from top to bottom beginning with 1. column: The current data column.
i、Rowlabel: The text for a row label. The label you specify sets the label for the data points identified by the Row property. This label appears along the category axis for most chart types and is used as the label for each individual pie in a pie chart. Label text may not be displayed if it is too long to fit on a chart.columnlabel: . Label text associated with a column in the data grid.
j、Data: The data point value. If the current data point already contains a value, it is replaced by the new value. The chart is redrawn to reflect the new value for the current data point.
k、ChartData: A two-dimensional array that holds the data used to draw the chart. If the first series of a multi-dimensional array contains strings, those strings will become the labels of the chart.ChartData is the default property for the MSChart control.
It is so many properities about Mschart Activex.I only introduce so much.Now,I will provide your two example to you!I wish it can help you understand it.
Example 1:It come from:
http://www.4guysfromrolla.com/webtech/MSChartExample.shtm
<object CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331"
id="Microsoft_Licensed_Class_Manager_1_0">
<param NAME="LPKPath" VALUE="mschart.lpk">
</object>
<OBJECT classid="clsid:3A2B370C-BA0A-11D1-B137-0000F8753F5D"
id=mschart1 style="HEIGHT: 326px; WIDTH: 651px" CODEBASE="mschart.cab"></OBJECT>
<script LANGUAGE="Vbscript">
MSChart1.ChartType =1
MSChart1.Plot.SeriesCollection(1).Pen.VtColor.Set 0,0,0
MSChart1.Plot.SeriesCollection(1).Pen.Width = 50
For i = 1 To MSChart1.Plot.Axis(1).Labels.Count
MSChart1.Plot.Axis(1).Labels(i).Format = "$0,###"
MSChart1.Plot.Axis(1).Labels(i).VtFont.Name = "Tahoma"
MSChart1.Plot.Axis(1).Labels(i).VtFont.Size = 10
Next
MSChart1.RowCount = 5
MSChart1.ColumnCount =2
MSChart1.ShowLegend = True
for y = 1 to 2
for x = 1 to 5
MSChart1.Row = x
MsChart1.Column= y
MSChart1.RowLabel = "Row " & x
call MSChart1.DataGrid.SetData(x, 1, x*5,nullFlag)
call MSChart1.DataGrid.SetData(x, 2, x*10,nullFlag)
next
Mschart1.ColumnLable=y
next
</script>
Example 2:We almost can see it everywhere.
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
function window_onload()
{
t=0;
mschart1.TitleText = "标题";
mschart1.ShowLegend =true;
mschart1.ColumnCount =2;
mschart1.RowCount =3;
for (i=0;i<3;i++)
{for (j=0;j<2;j++)
{ mschart1.Row=i+1;
mschart1.Column=j+1;
if (2>1)
mschart1.ColumnLabel =document.form1.cname(j).value;
else
mschart1.ColumnLabel =document.form1.cname.value;
if ((document.form1.rcount.value*document.form1.ccount.value)>1)
mschart1.Data=document.form1.rc_data(t).value;
else
mschart1.Data=document.form1.rc_data.value;
t++;
}
if (document.form1.rcount.value>1)
mschart1.RowLabel =document.form1.rname(i).value ;
else
mschart1.RowLabel =document.form1.rname.value;
}
}
function select1_onchange() {
mschart1.chartType =select1.value
mschart1.Plot
}
//-->
</SCRIPT>
<TITLE>数据显示图</TITLE>
</HEAD>
<BODY LANGUAGE=javascript onload="return window_onload()">
<object CLASSID="clsid:5220cb21-c88d-11cf-b347-00aa00a28331"
id="Microsoft_Licensed_Class_Manager_1_0">
<param NAME="LPKPath" VALUE="mschart.lpk">
</object>
<OBJECT classid="clsid:3A2B370C-BA0A-11D1-B137-0000F8753F5D"
id=mschart1 style="HEIGHT: 326px; WIDTH: 651px" CODEBASE="mschart.cab"></OBJECT>
<BR>
显示方式
<SELECT id=select1 name=select1 LANGUAGE=javascript onchange="return select1_onchange()">
<OPTION value=1>二维直方图</OPTION>
<OPTION value=0>三维直方图</OPTION>
<OPTION value=3>二维折线图</OPTION>
<OPTION value=2>三维折线图</OPTION>
<OPTION value=5>二维面积图</OPTION>
<OPTION value=4>三维面积图</OPTION>
<OPTION value=14>饼图</OPTION></SELECT>
<!
chtitle 标题
rcount 列数
ccount 行数
rc_type 排列方式(1 以行方式,2以列方式)
rc_data 数据
rname 列名数组
cname 行名数组>
<form name=form1 id=form1>
<input type="hidden" name=rname id=rname value=1993>
<input type="hidden" name=rname id=rname value=1996>
<input type="hidden" name=rname id=rname value=1999>
<input type="hidden" name=cname id=cname value=身高>
<input type="hidden" name=cname id=cname value=体重>
<input type="hidden" name=rcount id=rcount value=3>
<input type="hidden" name=chtitle id=chtitle value=CoolFatMan的成长里程>
<input type="hidden" name=ccount id=ccount value=2>
<input type="hidden" name=rc_data id=rc_data value=179>
<input type="hidden" name=rc_data id=rc_data value=160>
<input type="hidden" name=rc_data id=rc_data value=180>
<input type="hidden" name=rc_data id=rc_data value=170>
<input type="hidden" name=rc_data id=rc_data value=182>
<input type="hidden" name=rc_data id=rc_data value=182>
</form></BODY></HTML>

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧