"Jose M Hernandez" <Jose M
He*******@discu ssions.microsof t.com> wrote in
message news:C9******** *************** ***********@mic rosoft.com...
Does anybody know of techniques (or websites) where a graph is generated
based on data of an array?
Any advice on graphs and ASP is greatly appreciated...
yes I made a scripting component to make charts, it works on a record set
being passed to it and has some percific code to my needs in it, but you
could alter it to use a array for your own needs
here is a example
http://wanews.org/economic/unemployment.asp
copy code into notepad
save as chart.wsc
then call like this
set chart = Server.CreateOb ject("chart.WSC ")
chart.chartLine ("Australian Interest
Rates","Interes tRates",300,200 ,rs1("minx"),rs 1("maxx"),rs2,0 ,7,"%","right", "")
and here is the code
<?xml version="1.0"?>
<component>
<registration
description="Ch art"
progid="Chart.W SC"
version="1.00"
classid="{bf770 420-5a73-4e1b-b5ce-f4f8a5448ee5}"
</registration>
<public>
<method name="chartLine ">
<PARAMETER name="heada"/>
<PARAMETER name="table"/>
<PARAMETER name="widthx"/>
<PARAMETER name="heightx"/>
<PARAMETER name="rangeLow"/>
<PARAMETER name="rangeHigh "/>
<PARAMETER name="recordSet "/>
<PARAMETER name="xCol"/>
<PARAMETER name="dCol"/>
<PARAMETER name="symbol"/>
<PARAMETER name="alignent"/>
</method>
</public>
<implements type="ASP" id="ASP"/>
<script language="VBScr ipt">
<![CDATA[
function
chartLine(heada ,table,widthx,h eightx,rangeLow ,rangeHigh,reco rdSet,xCol,dCol ,symbol,alignen t,bgColor)
Session.LCID = 3081
set bttt = server.CreateOb ject("MSWC.Brow serType")
dim ratio, rCount ,points ,counta ,leftx ,lefty ,spacex ,range ,line1
,line2 ,line3 ,test ,datex,color,di tString,datStri ng
test = true
color = "Blue"
line1 = ""
line2 = ""
line3 = ""
counta = 0
leftx = 50
lefty = 50
dateWhitlam = "December 2, 1972"
dateFraser = "november 11, 1975"
dateHawk = "march 11, 1983"
dateHoward = "march 2, 1996"
rCount = recordSet.Recor dCount
points = rCount / (widthx/25)
spacex = widthx / rCount
range = rangeHigh-rangeLow
ratio = heightx / range
line1 = "<TABLE style=""margin: 5"" BORDER=0 CELLSPACING=0 CELLPADDING=5
align=" & alignent & " height=" & heightx + 40 & " width=" & widthx + 80 & "
bgcolor=" & bgColor & ">"
line1 = line1 & "<TR><TD><S PAN
style=""font-family:arial;fo nt-weight:900"">" & heada & "</SPAN><DIV
STYLE=""positio n:relative;heig ht:" & heightx +85 & ";margin-top:20"">"
do until recordSet.EOF
'response.write recordSet(xCol)
if DateValue( recordSet(xCol) ) > DateValue(dateW hitlam) then
if DateValue( recordSet(xCol) ) > DateValue(dateF raser) then
if DateValue( recordSet(xCol) ) > DateValue(dateH awk) then
if DateValue( recordSet(xCol) ) > DateValue(dateH oward) then
color = "Blue"
else
color = "Red"
end if
else
color = "Blue"
end if
else
color = "Red"
end if
end if
line22 = "<v:line strokecolor=""" & color & """ from=""" & leftx & "," &
heightx - ((recordSet(dCo l) - rangeLow) * ratio) & """"
if bttt.browser = "IE" AND bttt.version => 6 then
line33 = "<DIV
style=""font-size:10;writing-mode:tb-rl;position:abs olute;top:" & heightx +
20 & ";left:" & leftx-5 & """>" & getAUSDate(reco rdSet(xCol)) & "</DIV>"
else
line33 = "<DIV
style=""font-size:9;writing-mode:tb-rl;position:abs olute;top:" & heightx +
20 & ";left:" & leftx-5 & """>" & Year(recordSet( xCol)) & "</DIV>"
end if
recordSet.MoveN ext
if not recordSet.EOF then
line22 = line22 & " to=""" & leftx + spacex & "," & heightx -
((recordSet(dCo l) - rangeLow) * ratio) & """ TITLE="""& recordSet(dCol)
&"""></v:line>"
else
line22 = ""
line3 = line3 & line33
end if
line2 = line2 & line22
leftx = leftx + spacex
if counta => pointsx and pointsx < (rCount - (points / 2)) then
pointsx = pointsx + points
if bttt.browser = "IE" AND bttt.version => 6 then
line3 = line3 & "<DIV
style=""font-size:10;writing-mode:tb-rl;position:abs olute;top:" & heightx +
20 & ";left:" & leftx-5 & """>" & getAUSDate(reco rdSet(xCol)) & "</DIV>"
else
datString = Year( recordSet(xCol) )
line3 = line3 & "<DIV
style=""font-size:9;writing-mode:tb-rl;position:abs olute;top:" & heightx +
20 & ";left:" & leftx-5 & """>" & datString & "</DIV>"
datString = ""
end if
end if
counta = counta + 1
loop
line3 = line3 & "<DIV style=""font-size:12;positio n:relative;top:-5"">" &
FormatNumber( rangeHigh,2) & symbol & "</DIV><v:line strokecolor=""b lack""
from=""" & lefty+10 & "," & -15 & """ to=""" & lefty + widthx & "," & -15 &
"""></v:line>"
line3 = line3 & "<DIV style=""font-size:12;positio n:relative;top: " &
heightx/2-25 & """>" & FormatNumber((( rangeHigh-rangeLow)/2)+rangeLow,2) &
symbol & "</DIV><v:line strokecolor=""b lack"" from=""" & lefty+10 & "," &
heightx/2-32 & """ to=""" & lefty + widthx & "," & heightx/2-32 &
"""></v:line>"
line3 = line3 & "<DIV style=""font-size:12;positio n:relative;top: " &
heightx-50 & """>" & FormatNumber( rangeLow,2) & symbol & "</DIV><v:line
strokecolor=""b lack"" from=""" & lefty & "," & heightx - 45 & """ to=""" &
lefty + widthx & "," & heightx - 45 & """></v:line>"
line3 = line3 & "</DIV><A HREF=""/pub/economic/xl/data.asp?tab=" & table &
""">Chart Data</A></TD></TR></TABLE>"
line = line1 & line2 & line3
chartLine = line
end function
function getAUSDate(dDat e)
dim d,m,y
d = Day(dDate)
m = Month(dDate)
y = Year(dDate)
getAUSDate = d &"/"& m &"/"& y
end function
]]>
</script>
</component>