<% @LANGUAGE="VBSCRIPT"
%>
<%
'***************** Example:
Line-Charts.asp **********************
'
' Use Active Server Image to Create Custom Charts
' ASP Charts --- Line
' Written by eMarkSoft Inc. on 2002.04.29
'
'*********************************************************
%>
<%
'Set midpoint coordinate
x0 = 120
y0 = 285
'Set Chart image size
Width = 900
Height = 320
dim temp()
Set obj = Server.CreateObject("emarkasi.painter")
obj.CreateImage Width, Height
dim x,y
obj.SetCanvasColor "#F9F9F9"
obj.BrushStyle = "bsClear"
GridHeight = obj.TextHeight("300") + 2
GridWidth = (Width - x0 - 10)/10
'Draw the X coordinate rule
obj.Textout "0.5HR","blue",,x0-10,y0+5
obj.Textout "2HR","blue",,x0-10+1*GridWidth,y0+5
obj.Textout "4HR","blue",,x0-10+2*GridWidth,y0+5
obj.Textout "8HR","blue",,x0-10+3*GridWidth,y0+5
obj.Textout "16HR","blue",,x0-10+4*GridWidth,y0+5
obj.Textout "24HR","blue",,x0-10+5*GridWidth,y0+5
obj.Textout "48HR","blue",,x0-10+6*GridWidth,y0+5
obj.Textout "72HR","blue",,x0-10+7*GridWidth,y0+5
obj.Textout "96HR","blue",,x0-10+8*GridWidth,y0+5
obj.Textout "120HR","blue",,x0-10+9*GridWidth,y0+5
obj.Textout "168HR","blue",,x0-25+10*GridWidth,y0+5
'Draw the Y coordinate rule
obj.PenColor = "#E0E0E0"
for i=0 to
18
obj.Textout 350-i*5,"blue",,95,(I)*GridHeight
+ 10
next
'Draw background grid
for i=0 to
18
obj.MoveTo x0,y0-i*GridHeight
obj.LineTo obj.Width - 10,
y0-i*GridHeight
next
for i=0 to
10
obj.MoveTo x0+i*GridWidth,10
+ 6
obj.LineTo x0+i*GridWidth,y0
next
obj.Rectangle 10,10,60,290
obj.PenColor = "black"
obj.MoveTo 15,50
obj.LineTo 58,50
call diam(35,50)
obj.MoveTo 15,100
obj.LineTo 55,100
call tri(35,100)
obj.MoveTo 15,150
obj.LineTo 55,150
call cross(35,150)
obj.PenColor = "black"
obj.MoveTo x0, y0
obj.LineTo x0, 10 + 6
obj.LineTo width - 10, 10 +6
obj.LineTo width - 10, y0
obj.LineTo x0, y0
'Draw the Line Chart with
random data
Randomize
dim points(10,2)
for j=0 to
9
points(j,0) = x0+j*GridWidth
points(j,1) = y0/2 - (0.5-rnd(timer))*y0/4
call
tri(points(j,0),points(j,1))
next
obj.Polyline points
for j=0 to
9
points(j,0) = x0+j*GridWidth
points(j,1) = y0/2 - (0.5-rnd(timer))*y0/4
call
cross(points(j,0),points(j,1))
next
obj.Polyline points
for j=0 to
9
points(j,0) = x0+j*GridWidth
points(j,1) = y0/2 - (0.5-rnd(timer))*y0/4
call
diam(points(j,0),points(j,1))
next
obj.Polyline points
Response.ContentType = "image/png"
Response.BinaryWrite obj.Png
' Drawing cross
function
sub cross(x,y)
obj.PenColor = "black"
obj.MoveTo x-3,y-3
obj.LineTo x+4,y+4
obj.MoveTo x-3,y+3
obj.LineTo x+4,y-4
end sub '
Drawing triangular shape
function
sub tri(x,y)
redim temp(3,2)
temp(0,0) = x
temp(0,1) = y-3
temp(1,0) = x-3
temp(1,1) = y+3
temp(2,0) = x+3
temp(2,1) = y+3
obj.BrushStyle = "bsSolid"
obj.BrushColor = "black"
obj.MoveTo x,y-3
obj.Polygon temp
end sub '
Drawing diamond shape function
sub diam(x,y)
redim temp(4,2)
temp(0,0) = x
temp(0,1) = y-3
temp(1,0) = x-3
temp(1,1) = y
temp(2,0) = x
temp(2,1) = y+3
temp(3,0) = x+3
temp(3,1) = y
obj.BrushStyle = "bsSolid"
obj.BrushColor = "black"
obj.MoveTo x,y-3
obj.Polygon temp
end sub
%>
|