This script will generate a Column Graph with the data indicated in the
first part of the script
-
Tableheight will be the height of the table
-
Tablewidth will be the width of the table
-
We will include a list of values separated by commas. These values will
be Y values. We will consider X values will start in 1 and the maximun
X value will be the total number of values in the list.
In the same directory where this script is located we will need to save
the figure bellow:
red.gif 
You will find the resulting Column Graph bellow
<html><body>
<center>
<%
Tableheight=200
Tablewidth=300
DataArray=Array(1,2,3,4,5,6,5,4,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1,1,0)
' lets calculate maximun number of values for Y
max=ubound(DataArray)
' lets calculate maximun value for Y
Ymaxvalue=DataArray(0)
for i=1 to max
if DataArray(i)>Ymaxvalue then
Ymaxvalue=DataArray(i)
end if
next
response.write("<table border=0 height=" & Tableheight &
" cellspacing=0 cellpadding=0><tr><td valign=top align=center>")
' next line will write minimun and maximun value for Y
response.write("<table border=0 height=" & Tableheight &
" bgcolor=8888FF cellspacing=0 cellpadding=0><tr><td valign=top>")
response.write("Ymaxvalue & "</td></tr><tr><td valign=bottom
align=right>O</td></tr></table>")
response.write("</td><td width=" & Tablewidth & "valign=bottom>")
' next lines will create the columns
for x=0 to max
response.write("<img src=red.gif width="
& Tablewidth/max)
response.write(" height=" & int(DataArray(x)*Tableheight/Ymaxvalue)
& ">")
next
response.write("</tr><tr><td></td><td>")
' next lines will write minimun and maximun value for X
response.write("<table width=" & Tablewidth & " border=0
bgcolor=8888FF cellspacing=0 cellpadding=0>")
response.write("<tr><td>")
' this is the minimun value for X
response.write("1")
response.write("</td><td align=right>")
' this is the maximun value for X
response.write(max+1)
response.write("</td></tr></table>")
response.write("</td></tr></table>")
response.write("</td></tr></table>")
%>
</center>
</body>
</html>
|
Tableheight=200
Tablewidth=300
DataArray=Array(1,2,3,4,5,6,5,4,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1,1,0)
Tableheight=230
Tablewidth=350
DataArray=Array(1,2,13,4,5,6,15,4,3,4,5,6,7,0,0,0,9,8,7,6,5,14,3,12,1,1,5,0,0,5,6,5,7)
AspTutorial.info.