Here's an example script to chart a two-dimensional array. This script is helpful as it does not require images or a database. All data is derived from an array and preset colors. There are multiple values allowed for each dimension and these can be of any limit.
<HTML> <HEAD> <META NAME="GENERATOR" Content="Visual N++"> <TITLE>Paging Through a Recordset</TITLE> </HEAD> <BODY bgColor=White text=Black>
<%
'------------------------------------------------------------------- 'For this article the array is set up manually 'It could also be passed to the page '-------------------------------------------------------------------
'------------------------------------------------------------------- 'This is just to generate some sample values '-------------------------------------------------------------------
randomize
for x=1 to Ubound(Arr,1) for y = 1 to Ubound(Arr,2) Arr(x,y)=int(rnd*30)+1 next next
call chart(Arr,400,200)
sub chart(Arr,width,height)
'------------------------------------------------------------------- 'Set the dimension of the color array equal to number of 'parameters for the y axis 'then define a color for each parameter '-------------------------------------------------------------------
redim col(2) col(1)="red" col(2)="blue"
'------------------------------------------------------------------- 'Get the limits of the array dimensions '-------------------------------------------------------------------
y=ubound(Arr,2) x=ubound(Arr,1)
'------------------------------------------------------------------- 'calulate the total number of rows required for ouput 'this will be used to generate table dimensions later '-------------------------------------------------------------------
totalrows = 2*y
'------------------------------------------------------------------- 'Get the maximum value to be plotted in the x dimension '-------------------------------------------------------------------
hi=0 for i=1 to x for j=1 to y if cint(Arr(i,j))>hi then hi=cint(Arr(i,j)) next next
'------------------------------------------------------------------- 'Apportion the dimensions of the plot to fit the requested chart size '-------------------------------------------------------------------
coeffy=hi/height dimx=(width-(x*y)-1)/(x*(y+1))
'------------------------------------------------------------------- 'Finally, let's generate the chart! first set up a table '-------------------------------------------------------------------
'------------------------------------------------------------------- 'Generate the legend '-------------------------------------------------------------------
'------------------------------------------------------------------- 'Generate the parameters of the y axis and values to be plotted '-------------------------------------------------------------------
'------------------------------------------------------------------- 'set up some temporary values to which we can assign the selected 'colors. these will be used by subroutine. 'This will need to be done manually -- continue sequence to 'match number of parameters '-------------------------------------------------------------------
colt1=col(1) colt2=col(2)
response.write("<tr><TD>") & vbcrlf for j = 1 to y-1
'------------------------------------------------------------------- 'Rotate the color to next in sequence 'This will need to be set manually -- continue sequence to match 'the number of parameters '-------------------------------------------------------------------
temp=colt1 colt1=colt2 colt2=temp
next response.write("</TD></tr>") & vbcrlf
next
'------------------------------------------------------------------- 'Generate footer for the chart '-------------------------------------------------------------------