.....
Source Code ASP
 

MkGraph Function 
purpose:
The MkGraph function creates a simple HTML graph. The graph only displays properly in Internet Explorer browsers. There are seven required arguments. 

Required Argument..

Expects.....

Description

arraytograph

array

(values should be double) array of data (numbers) to be graphed

arrayofnames

array

values should be strings) array of strings containing the name of each corresponding value from arraytograph.

bordersize

integer

integer representing the size of the border around the graph. Use 0 for no border.

alignment

string

("left", "center" or "right") alignment of the graph on the page. Acceptable values are: "left", "center" or "right".

width

integer

(1-100) integer 1 - 100 representing a percentage out of 100% the total width of the graph. The overall width of the graph is still dependent on the size of the bars. If the percentage declared in width is smaller than the longest bar, the longest bar is used as the width.

color

string

(hexadecimal) color of the bars in the graph. Color must be a html hexadecimal color starting with "#" - example: #0000FF for blue

title

string

Title of the graph


syntax:
string = MkGraph( arraytograph, arrayofnames, bordersize, alignment, width, color, title ) 

example usage:
<%
Dim input, names, border, align, width, color, title

' array of values to graph.
input = Array( 181, 2325, 2142, 3010, 416, 1124, 621, _
500, 1021, 1421, 2325, 1842, 1010, 1416, 1124, _
2621, 3500, 1121 )

' array of names for each item to graph.
names = Array( "Item 1", "Item 2", "Item 3", "Item 4", _
"Item 5", "Item 6", "Item 7", "Item 8", "Item 9", _
"Item 10", "Item 11", "Item 12", "Item 13", _
"Item 14", "Item 15", "Item 16", "Item 17", _
"Item 18" )

' graph border
border = 1

' graph alignment
align = "LEFT"

' width (out of 100%) of the graph
width = 50

' color of the bars
color = "#CF230F"

' title the graph
title = "Sample Graph"

' write the graph to the browser
response.write MkGraph( input, names, border, align, width, color, title ) 
%>
source code:
<%
Private Function MkGraph(byVal arraytograph, byVal arrayofnames, _
byVal bordersize, byVal alignment, _
byVal width, byVal color, byVal title)
Dim i, tmp
tmp = "<TABLE BORDER=" & bordersize & " ALIGN=""" & _
alignment & """ WIDTH=""" & width & "%""><TR><TD>" & vbCrLf
tmp = tmp & "<CENTER><B>" & title & "</B></CENTER>" & vbCrLf
tmp = tmp & "<TABLE WIDTH=""100%"" STYLE=""font-size:7pt;"" " & _
"ALIGN=CENTER>" & vbCrLf
for i = 0 to ubound( arraytograph )
tmp = tmp & "<TR><TD ALIGN=LEFT WIDTH=""5%"" " & _
"NOWRAP>" & CStr( arrayofnames( i ) ) & _
"</TD><TD ALIGN=CENTER " & _
"WIDTH=""5%"" NOWRAP>[ " & _
CDbl( arraytograph( i ) ) & " ]</TD><TD WIDTH" & _
"=""90%""><SPAN BGCOLOR=""" & color & _
""" STYLE=""width:" & _
CLng( 2 * (arraytograph( i ) / _
ubound( arraytograph ) + 4) ) & _
";background-color:" & color & _
";"" WIDTH=""" & CLng( 2 * (arraytograph( i ) / _
ubound( arraytograph ) + 4) ) & _
""">&nbsp;</SPAN></TD></TR>" & vbCrLf
next
tmp = tmp & "</TABLE>" & vbCrLf
tmp = tmp & "</TD></TR></TABLE>" & vbCrLf
MkGraph = tmp
End Function
%>