<% @LANGUAGE="VBSCRIPT"
%>
<%
'***************** Example:
Bar-Charts.asp **********************
'
' Use Active Server Image to Create Custom Charts
' ASP Charts --- Bar
' Written by eMarkSoft Inc. on 2002.04.29
'
'*********************************************************************
%>
<%
Server.ScriptTimeout = 900
Width = 620
Height = 540
'Set amount of bar
n = 16
BarWidth = (Width-120)/(n+2)
Radian = 3.1416/180 '
Pi/180
'Create random data
Dim Datas
ReDim Datas(n,2)
MaxY = 0
Randomize
for i=0 to
n-1
Datas(i,0) = "Field"&Cstr(i)
Datas(i,1) = Fix(rnd*400)
if Datas(i,1) > MaxY then MaxY = Datas(i,1)
next
Dim Colors
Redim Colors(20)
Colors(0) = "Blue"
Colors(1) = "chartreuse"
Colors(2) = "blueviolet"
Colors(3) = "gold"
Colors(4) = "indianred"
Colors(5) = "lightblue"
Colors(6) = "maroon"
Colors(7) = "olive"
Colors(8) = "red"
Colors(9) = "steelblue"
Colors(10) = "Blue"
Colors(11) = "chartreuse"
Colors(12) = "blueviolet"
Colors(13) = "gold"
Colors(14) = "indianred"
Colors(15) = "lightblue"
Colors(16) = "maroon"
Colors(17) = "olive"
Colors(18) = "red"
Colors(19) = "steelblue"
'Create a Graphing Object to draw
the Chart Set
obj=Server.CreateObject("eMarkASI.Painter")
obj.CreateImage Width, Height
obj.SetCanvasColor "#F0F0F0"
x0 = 60
y0 = 480
obj.MoveTo x0,y0
obj.LineTo x0,y0-400
obj.MoveTo x0,y0
obj.LineTo x0+(Width-120),y0
GridHeight = Round(MaxY/10)
obj.BrushStyle = 0
for i=0 to
1
obj.MoveTo x0 - 5 - obj.TextWidth(Cstr(i*GridHeight)),
y0-i*GridHeight-7
obj.Textout Cstr(i*GridHeight)
next
obj.BrushStyle = 1
obj.BrushColor = "black"
call DrawArrow(x0,y0-400,1)
call DrawArrow(x0+(Width-120),y0,4)
'Draw the Bars
obj.FontName = "microsoft sans serif"
obj.FontSize = 10
for i=0 to
n-1
obj.BrushStyle = 1
obj.BrushColor = Colors(i)
obj.BrushColor = "Gold"
'obj.Rectangle x0 + (2*i+1)*BarWidth,
y0, x0+(2*i+2)*BarWidth, y0 - Datas(i,1)
obj.Rectangle x0 + (i+1)*BarWidth, y0, x0+(i+2)*BarWidth,
y0 - Datas(i,1)
obj.BrushStyle = 0
'obj.MoveTo x0 + (2*i+1+1/2)*BarWidth
- obj.TextWidth(Datas(i,0))*Sin(Radian*40), y0
+ 25
obj.MoveTo x0 + (i+1+1/2)*BarWidth - obj.TextWidth(Datas(i,0))*Sin(Radian*40),
y0 + 5 + obj.TextWidth(Datas(i,0)) * Sin(Radian*40)
obj.WriteRotatedText Datas(i,0), 45
'obj.Textout Datas(i,0)
next
Response.ContentType = "image/png"
Response.BinaryWrite obj.Png
' Drawing Arrow Function
Sub DrawArrow(xx,yy,direction)
Redim
Points(3,2)
select case Direction
case
1 'up
Points(0,0)
= xx+5
Points(0,1)
= yy
Points(1,0)
= xx
Points(1,1)
= yy-10
Points(2,0)
= xx-5
Points(2,1)
= yy
case
2 'down
Points(0,0)
= xx+5
Points(0,1)
= yy
Points(1,0)
= xx
Points(1,1)
= yy+10
Points(2,0)
= xx-5
Points(2,1)
= yy
case
3 'left
Points(0,0)
= xx
Points(0,1)
= yy+5
Points(1,0)
= xx
Points(1,1)
= yy-5
Points(2,0)
= xx-10
Points(2,1)
= yy
case
4 'right
Points(0,0)
= xx
Points(0,1)
= yy+5
Points(1,0)
= xx
Points(1,1)
= yy-5
Points(2,0)
= xx+10
Points(2,1)
= yy
end select
obj.Polygon Points
end sub
%>
|