|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/mguerinweb/Offline_Archive/ |
Upload File : |
<%
Sub ShowChart(ByRef aValues, ByRef bValues, ByRef cValues, ByRef aLabels, ByRef strTitle, ByRef strXAxisLabel, ByRef strYAxisLabel)
' Some user changable graph defining constants
' All units are in screen pixels
Const GRAPH_WIDTH = 450 ' The width of the body of the graph
Const GRAPH_HEIGHT = 250 ' The heigth of the body of the graph
Const GRAPH_BORDER = 2 ' The size of the black border
Const GRAPH_SPACER = 3 ' The size of the space between the bars
' Debugging constant so I can eaasily 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 iMaxa, iMaxb, iMaxc
Dim iBarWidth
Dim iBarHeighta
Dim iBarHeightb
Dim iBarHeightc
Dim iBarHeightTotal
Dim iValueTotal
iValueTotal=0
' Get the maximum value in the data set
iMaxValue = 0
iMaxa = 0
iMaxb = 0
iMaxc = 0
For I = 0 To UBound(aValues)
If iMaxa < aValues(I) Then iMaxa = aValues(I)
If iMaxb < bValues(I) Then iMaxb = bValues(I)
If iMaxc < cValues(I) Then iMaxc = cValues(I)
Next 'I
'iMaxValue = iMaxa + iMaxb + iMaxc
iMaxValue = 3.50
If iMaxValue = 0 then iMaxValue = 1
'Response.Write iMaxValue ' Debugging line
' 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 "<br>Bar Width: " & iBarWidth ' Debugging line
'response.write "<br>ubound(aValues): " & ubound(aValues)
' Start drawing the graph
%>
<TABLE BORDER="<%= TABLE_BORDER %>" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD COLSPAN="3" ALIGN="center"><H2><font color="#0066CC"><%= strTitle %></font></H2></TD>
<td rowspan=1 valign=top>
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td valign=middle style="padding-left: 12pt;">
<img src="images/spacer_yellow.gif" height=10 width=10 border=1> Materials/Other<br>
<img src="images/spacer_purple.gif" height=10 width=10 border=1> Contract Labor<br>
<img src="images/spacer_maroon.gif" height=10 width=10 border=1> In-House Labor</td>
</tr>
</table></td>
</TR>
<TR>
<TD VALIGN="center"><B><%= strYAxisLabel %></B></TD>
<TD VALIGN="top">
<TABLE height="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
<tr>
<td rowspan=7 height='250'><img src='images/spacer.gif' border=0 width=1></td>
<td valign=bottom align=right>$3.00 </td>
</tr>
<tr>
<td valign=bottom align=right>$2.50 </td>
</tr>
<tr>
<td valign=bottom align=right>$2.00 </td>
</tr>
<tr>
<td valign=bottom align=right>$1.50 </td>
</tr>
<tr>
<td valign=bottom align=right>$1.00 </td>
</tr>
<tr>
<td valign=bottom align=right>$0.50 </td>
</tr>
<tr>
<td valign=bottom align=right>$0.00 </td>
</tr>
<%
'dim total
'dim div
'dim x
'div = iMaxValue / 9
'For x = 0 To 9
' If x = 0 then
' response.write "<tr><td rowspan=10><img src='images/spacer.gif' border=0 width=1 height='" & GRAPH_HEIGHT & "'></td>"
' total = iMaxValue
' response.write "<td valing=bottom align=right>" & FormatCurrency(total) & "</td></tr>" & vbCrLf
' else
' total = total - div
' response.write "<tr><td valign=bottom align=right>" & FormatCurrency(abs(total)) & "</td></tr>" & vbCrLf
' end if
'Next
%>
</TABLE>
</TD>
<TD>
<TABLE BORDER="<%= TABLE_BORDER %>" CELLSPACING="0" CELLPADDING="0" style="background-image: url('images/chart_bg.gif')">
<TR>
<TD VALIGN="bottom"><IMG SRC="images/spacer_black.gif" BORDER="0" WIDTH="<%= GRAPH_BORDER %>" HEIGHT="<%= GRAPH_HEIGHT %>"></TD>
<%
' We're now in the body of the chart. Loop through the data showing the bars!
For I = 0 To UBound(aValues)
dim iOverFlow
iBarHeighta = abs(Int((aValues(I) / iMaxValue) * GRAPH_HEIGHT))
iBarHeightb = abs(Int((bValues(I) / iMaxValue) * GRAPH_HEIGHT))
iBarHeightc = abs(Int((cValues(I) / iMaxValue) * GRAPH_HEIGHT))
iValueTotal = (aValues(I) + bValues(I) + cValues(I))
'This stops bar from going over chart
iBarHeightTotal = iBarHeighta + iBarHeightb + iBarHeightc
if iBarHeightTotal > GRAPH_HEIGHT then
dim aPercent
dim bPercent
dim cPercent
aPercent = iBarHeighta/iBarHeightTotal
bPercent = iBarHeightb/iBarHeightTotal
cPercent = iBarHeightc/iBarHeightTotal
iBarHeighta = round(aPercent * GRAPH_HEIGHT)
iBarHeightb = round(bPercent * GRAPH_HEIGHT)
iBarHeightc = round(cPercent * GRAPH_HEIGHT) - 12
iOverFlow = FormatCurrency(abs(aValues(I)) + abs(bValues(I)) + abs(cValues(I)))
end if
' This is a hack since browsers ignore a 0 as an image dimension!
If iBarHeighta = 0 Then iBarHeighta = 1
If iBarHeightb = 0 Then iBarHeightb = 1
If iBarHeightc = 0 Then iBarHeightc = 1
%>
<TD VALIGN="bottom"><IMG SRC="images/spacer.gif" BORDER="0" WIDTH="<%= GRAPH_SPACER %>" HEIGHT="1"></TD>
<TD VALIGN="bottom">
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td align=center><small><b><u><% =iOverFlow %></u></b></small></td>
</tr>
<tr>
<td align=center>
<IMG SRC="images/spacer_yellow.gif" BORDER=0 WIDTH="<%= iBarWidth %>" HEIGHT="<%= iBarHeightc %>" ALT="<%
if I=UBound(aValues) then
response.write FormatCurrency(cValues(I))
end if
%>"><IMG SRC="images/spacer_yellow_dark.gif" BORDER=0 WIDTH=2 HEIGHT="<%= iBarHeightc - 2 %>"></td>
</tr>
<tr>
<td align=center>
<IMG SRC="images/spacer_purple.gif" BORDER=0 WIDTH="<%= iBarWidth %>" HEIGHT="<%= iBarHeightb %>" ALT="<%
if I=UBound(aValues) then
response.write FormatCurrency(bValues(I))
end if
%>"><IMG SRC="images/spacer_purple_dark.gif" BORDER=0 WIDTH=2 HEIGHT="<%= iBarHeightb %>"></td>
</tr>
<tr>
<td align=center>
<IMG SRC="images/spacer_maroon.gif" BORDER=0 WIDTH="<%= iBarWidth %>" HEIGHT="<%= iBarHeighta %>" ALT="<%
if I=UBound(aValues) then
response.write FormatCurrency(aValues(I))
end if
%>"><IMG SRC="images/spacer_maroon_dark.gif" BORDER=0 WIDTH=2 HEIGHT="<%= iBarHeighta %>"></td>
</tr>
</table>
</TD>
<%
Next 'I
%>
</TR>
<!-- I was using GRAPH_BORDER + GRAPH_WIDTH but it was moving the last x axis label <%= GRAPH_BORDER + ((UBound(aValues) + 1) * (iBarWidth + GRAPH_SPACER)) %>-->
<TR>
<TD COLSPAN="<%= (2 * (UBound(aValues) + 1)) + 1 %>"><IMG SRC="images/spacer_black.gif" BORDER="0" WIDTH="100%" 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 %>
<TR>
<TD><!-- Spacing for Left Border Column --></TD>
<% For I = 0 To UBound(aValues) %>
<TD><!-- Spacing for Spacer Column --></TD>
<TD ALIGN="center" bgcolor="#f4f5f7"><FONT SIZE="1"><%= aLabels(I) %></FONT></TD>
<% Next 'I %>
</TR>
<% End If %>
</TABLE>
</TD>
<TD rowspan=2 style="padding-left: 12pt;" valign=top>
<table cellspacing=0 cellpadding=3 width="100%" border=1>
<tr>
<td align="center">Lower costs usually indicate effective contracting, solid management practices and superior improvement programs.<p>
For information on how to improve your own operations by adapting BEST PRACTICES, contact Guerin Associates.<p>
<a href="mailto:[email protected]">[email protected]</a><p>
<i>"Opening a Window to<br>World Class Performance"</i></td>
</tr>
</table>
<table cellspacing=0 cellpadding=3 width="100%" border=0>
<tr>
<td>Your Company Total: <%=FormatCurrency(iValueTotal)%></td>
</tr>
</table>
</TD>
</TR>
<TR>
<TD COLSPAN=2><!-- Place holder for X Axis label centering--></TD>
<TD ALIGN="center"><BR><B><%= strXAxisLabel %></B></TD>
</TR>
</TABLE>
<%
End Sub
%>