Took a break from working on some game scripts & actually found it easier to script a basic object based on The "Bar Chart"
Sample code from ASP101. It's very rough. Put I've posted the script below.
Code: vbscript
- ShowChart Array(6, 10, 12, 18, 23), Array("P1", "P2", "P3", "P4", "P5"), "This is the Chart Title", "X Axis Label", "Y Axis Label"
- Sub ShowChart(ByRef aValues, ByRef aLabels, ByRef strTitle, ByRef strXAxisLabel, ByRef strYAxisLabel)
- ' Some user changable graph defining constants
- ' All units are in screen pixels
- Const GRAPH_WIDTH = 300 ' The width of the body of the graph
- Const GRAPH_HEIGHT = 200 ' The height of the body of the graph
- Const GRAPH_BORDER = 2 ' The size of the black border
- Const GRAPH_SPACER = 5 ' The size of the space between the bars
- ' Debugging constant so I can easily switch on borders in case
- ' the tables get messed up. Should be left at zero unless you're
- ' trying to figure out which table cells doing what.
- Const TABLE_BORDER = 0
- 'Const TABLE_BORDER = 10
- ' Declare our variables
- Dim I
- Dim iMaxValue
- Dim iBarWidth
- Dim iBarHeight
- ' Get the maximum value in the data set
- iMaxValue = 0
- For I = 0 To UBound(aValues)
- If iMaxValue < aValues(I) Then iMaxValue = aValues(I)
- Next 'I
- 'Response.Write iMaxValue ' Debugging line
- iBarWidth ="20"
- ' Calculate the width of the bars
- ' Take the overall width and divide by number of items and round down.
- ' I then reduce it by the size of the spacer so the end result
- ' should be GRAPH_WIDTH or less!
- 'iBarWidth = (GRAPH_WIDTH \ (UBound(aValues) + 1)) - GRAPH_SPACER
- 'Response.Write iBarWidth ' Debugging line
- ' Start drawing the graph
- DesktopX.Object("lbl.ChartTitle").Text = strTitle
- DesktopX.Object("lbl.Yaxis").Text = strYAxisLabel
- DesktopX.Object("lbl.Yaxis").Rotation = -90
- ' <TD ROWSPAN="2"><IMG SRC="./images/spacer.gif" BORDER="0" WIDTH="1" HEIGHT="<%= GRAPH_HEIGHT %>"></TD>
- ' <TD VALIGN="top" ALIGN="right"><%= iMaxValue %> </TD>
- DesktopX.Object("obj.Yline").Width = GRAPH_BORDER
- DesktopX.Object("obj.Yline").Height= GRAPH_HEIGHT
- ' We're now in the body of the chart. Loop through the data showing the bars!
- For I = 0 To UBound(aValues)
- iBarHeight = Int((aValues(I) / iMaxValue) * GRAPH_HEIGHT)
- '-Clones bars
- If b = False Then
- Dim z, strname
- z=0
- Do
- z = z+1
- strname = "bar" & z
- Loop until DesktopX.IsObject(strname)=False
- DesktopX.object("bar0").Clone strname, DesktopX.object("bar"&(z-1)).Left + iBarWidth + GRAPH_SPACER, DesktopX.object("bar0").Bottom-iBarHeight
- DesktopX.object("bar"&(z)).Width = iBarWidth
- DesktopX.object("bar"&(z)).Height =iBarHeight' %>" ALT="<%= aValues(I) %>"></TD>
- DesktopX.object("bar"&(z)).Visible = True
- End If
- Next 'I
- ' </TR>
- ' <!-- I was using GRAPH_BORDER + GRAPH_WIDTH but it was moving the last x axis label -->
- ' <TR>
- ' <TD COLSPAN="<%= (2 * (UBound(aValues) + 1)) + 1 %>"><IMG SRC="./images/spacer_black.gif" BORDER="0" WIDTH="<%= GRAPH_BORDER + ((UBound(aValues) + 1) * (iBarWidth + GRAPH_SPACER)) %>" HEIGHT="<%= GRAPH_BORDER %>"></TD>
- ' </TR>
- ' The label array is optional and is really only useful for small data sets with very short labels! %>;
- ' If IsArray(aLabels) Then
- ' For I = 0 To UBound(aValues)
- ' = aLabels(I)
- ' Next 'I
- DesktopX.Object("lbl.Xaxis").Text = strXAxisLabel
- End Sub
- '--Clears Chart
- Function dxNewChart
- Object.SetTimer 100, 100
- End Function
- Sub Object_OnTimer100
- Call clearChart
- End Sub
- Function clearChart
- Dim i, strname
- i=0
- Do
- i = i+1
- strname = "bar" & i
- Loop until DesktopX.IsObject(strname)=False
- If i > 1 Then
- DesktopX.object("bar" & (i-1)).delete
- Else
- Object.KillTimer 100
- End If
- End Function
- '--End Clears