Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
<%
'**************************************************************************************************
'Dynamic Graph Pseudo-Object
'
'This file acts as a pseudo graphing Object. It combines ASP, CSS, and HTML to create a vertical
' bar graph.
'
'©2002 Eli Weinstock-Herman
'**************************************************************************************************
'--- GRAPHING CONSTANTS --------------------------------------------------
Dim MAX_BAR_HEIGHT, BAR_WIDTH, DEAD_SPACE_WIDTH '-
Dim BAR_COLOR, BACKGROUND_COLOR, TEXT_COLOR, BAR_BORDER_COLOR '-
Dim MAX_NUM_BARS, VERTICAL_STEPS '-
Dim FONT_SIZE '-
DIM SHOW_PERCENTAGES '-
Dim SHOW_NUMBERS '-
'Const ABSOLUTE_MAX_NUM_BARS = 10 '-
'-
Dim initFlag, beginFlag, addFlag, totalFlag '-
initFlag = false '-
beginFlag = false '-
addFlag = false '-
totalFlag = false '-
'-------------------------------------------------------------------------
'********************************* Initialization Functions *****************************
'--- Use the default settings for the graph
Function InitializeGraphDefaults
InitializeGraphColors "#A9FFA9","#000000","#FFFFFF","#000000"
SHOW_PERCENTAGES = false
SHOW_NUMBERS = false
FONT_SIZE = 10
MAX_NUM_BARS = 6
VERTICAL_STEPS = 20
MAX_BAR_HEIGHT = 180
BAR_WIDTH = 20
DEAD_SPACE_WIDTH = 5
initFlag = true
End Function
'--- Create a custom sized graph
Function InitializeGraphCustom(i_max_height,i_bar_width,i_dead_space_width)
InitializeGraphColors "#A9FFA9","#000000","#FFFFFF","#000000"
SHOW_PERCENTAGES = false
SHOW_NUMBERS = false
FONT_SIZE = 10
MAX_NUM_BARS = 4
VERTICAL_STEPS = 20
MAX_BAR_HEIGHT = i_max_height
BAR_WIDTH = i_bar_width
DEAD_SPACE_WIDTH = i_dead_space_width
initFlag = true
End Function
'--- Initialize Colors for Graph
Function InitializeGraphColors(i_bar_color,i_bar_border_color, i_background_color, i_text_color)
BAR_COLOR = i_bar_color
BAR_BORDER_COLOR = i_bar_border_color
BACKGROUND_COLOR = i_background_color
TEXT_COLOR = i_text_color
End Function
'********************************* Individual Variable Change Functions *****************
'--- Set the Maximum Bar Height
Function SetMaximumBarHeight(new_height)
MAX_BAR_HEIGHT = new_height
End Function
'--- Set the Bar Width
Function SetBarWidth(new_width)
BAR_WIDTH = new_width
End Function
'--- Set the width of the Dead Space between Bars
Function SetDeadSpace(new_width)
DEAD_SPACE_WIDTH = new_width
End Function
'--- Set Maximum Number Of Bars
Function SetMaximumNumberOfBars(new_max)
MAX_NUM_BARS = new_max
End Function
'--- Set Vertical Steps ie the step size between the lines for the y-axis
'- For example, 20 would be a 20% step size, displaying 20, 40, 60, 80, and 100
Function SetVerticalSteps(new_percentage)
VERTICAL_STEPS = new_percentage
End Function
'--- Set Color of the Bars on Graph
Function SetBarColor(new_color)
BAR_COLOR = new_color
End Function
'--- Set the Color of the Bar's Border
Function SetBarBorderColor(new_color)
BAR_BORDER_COLOR = new_color
End Function
'--- Set the Background Color for the graph
Function SetBackgroundColor(new_color)
BACKGROUND_COLOR = new_color
End Function
'--- Set the Text Color for the Graph (also affects the horizantal percentage lines)
Function SetTextColor(new_color)
TEXT_COLOR = new_color
End Function
'--- Set Font Size for the percentages and such
Function SetFontSize(new_pixel_size)
FONT_SIZE = new_pixel_size
End Function
Function SetShowPercentages(bool)
SHOW_PERCENTAGES = bool
End Function
Function SetShowNumbers(bool)
SHOW_NUMBERS = bool
End Function
'********************************* Begin Using Pseudo-Object ****************************
Dim total_count
Dim bars(10)
Dim counts(10)
Dim labels(10)
Dim bar_counter
Function BeginGraph
If NOT initFlag Then
Response.Write "<b>Error, Graph was not initialized.</b>"
Else
beginFlag = true
bar_counter = 0
%>
<table STYLE="position:absolute;top:40px;left:5px;height:<%=MAX_BAR_HEIGHT+1%>px;width:<%=(50+(BAR_WIDTH + DEAD_SPACE_WIDTH) * MAX_NUM_BARS)%>;background-color:<%=BACKGROUND_COLOR%>;color:<%=TEXT_COLOR%>;font-size<%=FONT_SIZE%>;" valign=bottom border="0">
<%
Dim num_vertical_steps, vertical_count
num_vertical_steps = cInt(100/VERTICAL_STEPS)
For vertical_count = 1 to num_vertical_steps
%>
<tr style="height:<%=(MAX_BAR_HEIGHT/num_vertical_steps)-5%>px;font-size:<%=FONT_SIZE%>;color:<%=TEXT_COLOR%>;">
<td style="<%
If num_vertical_steps = vertical_count + 200 Then 'temp skip this stmt w the 200
%>border-bottom:1px <%=TEXT_COLOR%> solid;<%
End If
%>border-top:1px <%=TEXT_COLOR%> solid;border-left:1px <%=TEXT_COLOR%> solid;height:<%=(MAX_BAR_HEIGHT/num_vertical_steps)-5%>px;font-size:<%=FONT_SIZE%>;color:<%=TEXT_COLOR%>;" valign=top><%=(num_vertical_steps - vertical_count + 1)*VERTICAL_STEPS%>%</td>
</tr>
<%
Next
%>
</table>
<table STYLE="position:absolute;top:38px;left:30px;width:<%=((BAR_WIDTH + DEAD_SPACE_WIDTH) * MAX_NUM_BARS)%>;" valign=bottom border="0">
<tr>
<td width="1" height=<%=MAX_BAR_HEIGHT+2%>></td> <!-- spaceholder -->
<%
End If
End Function
Function SetTotal(total)
total_count = total
totalFlag = true
End Function
Function AddBar(number,label)
If initFlag AND totalFlag Then
If bar_counter < MAX_NUM_BARS Then
counts(bar_counter) = number
bars(bar_counter) = number/total_count
labels(bar_counter) = label
bar_counter = bar_counter+1
addFlag = true
Else
Response.Write "<b>Error, Total Number of Bars in Graph Exceeded.</b>"
End If
Else
Response.Write "<b>Error, You have either failed to initialize the graph, or not set the total count.</b>"
End If
End Function
Function DisplayGraph
If initFlag AND totalFlag AND addFlag AND beginFlag Then
Dim i
For i = 0 to bar_counter-1
%>
<td class="bar_area" valign=bottom style="height:<%=MAX_BAR_HEIGHT%>px;width:<%=BAR_WIDTH%>px;font-size:<%=FONT_SIZE%>px;color:<%=TEXT_COLOR%>;">
<%
If SHOW_PERCENTAGES Then
%><span style='position:absolute;width:<%=BAR_WIDTH%>px;text-align:center;font-size:<%=FONT_SIZE%>px;color:<%=TEXT_COLOR%>;'><%=FormatNumber(100 * bars(i),1)%>%</span><%
End If
If SHOW_NUMBERS Then
%><span style='position:absolute;width:<%=BAR_WIDTH%>px;text-align:center;font-size:<%=FONT_SIZE%>px;color:<%=TEXT_COLOR%>;'><%=counts(i)%></span><%
End If
If bars(i) > 0 Then
%>
<div style="width:<%=BAR_WIDTH%>px;height:<%=cInt(MAX_BAR_HEIGHT*bars(i))%>px; background-color:<%=BAR_COLOR%>;font-size:1px;border:1px solid <%=BAR_BORDER_COLOR%>;" />
<%
Else
%>
<div style="width:<%=BAR_WIDTH%>px;height:10px; background-color:<%=BACKGROUND_COLOR%>;font-size:1px;border:0px solid <%=BAR_BORDER_COLOR%>;" />
<%
End If
%>
</td>
<td style="height:<%=MAX_BAR_HEIGHT%>px;width:<%=DEAD_SPACE_WIDTH%>px;font-size:1px;color:<%=TEXT_COLOR%>;"></td>
<%
Next
If bar_counter-1 < MAX_NUM_BARS Then
For i = bar_counter - 1 To MAX_NUM_BARS
%>
<td class="bar_area" valign=bottom style="height:<%=MAX_BAR_HEIGHT%>px;width:<%=BAR_WIDTH%>px;font-size:<%=FONT_SIZE%>px;color:<%=TEXT_COLOR%>;"></td>
<td style="height:<%=MAX_BAR_HEIGHT%>px;width:<%=DEAD_SPACE_WIDTH%>px;font-size:1px;color:<%=TEXT_COLOR%>;"></td>
<%
Next
End If
%>
</tr>
<tr>
<td />
<%
For i = 0 to bar_counter-1
%>
<td class="label_area" valign=bottom style="width:<%=BAR_WIDTH%>px;font-size:<%=FONT_SIZE%>px;color:<%=TEXT_COLOR%>;text-align:center">
<%=labels(i)%>
</td>
<td />
<%
Next
%>
</tr>
</table>
<%
Else
If NOT addFlag Then
Response.Write "<span style='z-index:100;position:absolute;left:45px;top:55;padding:10px;border:1px solid #000000;background:#eeeeee;'><b>No Data.</b></span>"
Else
Response.Write "<span style='z-index:100;position:absolute;'><b>Error Displaying Graph: "
IF NOT initFlag Then
Response.Write "Not Initialized."
ElseIf NOT totalFlag Then
Response.Write "No Total Set."
ElseIf NOT beginFlag Then
Response.Write "No Begin Called."
Else
Response.Write "Unknown Error. Contact Administrator."
End If
Response.Write "</b></span>"
End If
End If
End Function
%>
<%
Option Explicit
%>
<html>
<head>
<title> Testing Pseudo Graph Object </title>
<script language="JavaScript">
<!--
function do_changes(){
document.all.g_display.src = "graph_test2.asp?cust_bar_width=" + frmGraphSettings.cust_bar_width.value + "&cust_bar_height=" + frmGraphSettings.cust_bar_height.value + "&cust_dead_space=" + frmGraphSettings.cust_dead_space.value + "&cust_bar_color=" + frmGraphSettings.cust_bar_color.value + "&cust_bg_color=" + frmGraphSettings.cust_bg_color.value + "&cust_text_color=" + frmGraphSettings.cust_text_color.value + "&cust_bar_border_color=" + frmGraphSettings.cust_bar_border_color.value + "&cust_max_num_bars=" + frmGraphSettings.cust_max_num_bars.value + "&cust_vertical_steps=" + frmGraphSettings.cust_vertical_steps.value + "&cust_font_size=" + frmGraphSettings.cust_font_size.value + "&cust_show_flag=" + frmGraphSettings.cust_show_flag.value + "&total=" +frmGraphSettings.total.value+ "&label_1=" +frmGraphSettings.label_1.value+ "&count_1=" +frmGraphSettings.count_1.value+ "&label_2=" +frmGraphSettings.label_2.value+ "&count_2=" +frmGraphSettings.count_2.value+ "&label_3=" +frmGraphSettings.label_3.value+ "&count_3=" +frmGraphSettings.count_3.value+ "&label_4=" +frmGraphSettings.label_4.value+ "&count_4=" +frmGraphSettings.count_4.value;
}
//-->
</script>
</head>
<body>
<center>
This utility allows you to change a lot of the variables for the graph. This is for testing the viewability on differant mediums. The total count should be the tyotal number of answers (numbers in a, b, c, d). Changing the number of bars is disabled for this utility because the number of answer boxes is fixed.
<br><i>NOTE: Leaving any of the text boxes blank is baaaaad.</i>
</center>
<table>
<tr>
<td>
<center><a href="#" onClick="do_changes();">Show Changes</a></center>
<iframe id=g_display name="g_display" src="" width=400 height=400>test</iframe><br>
</td>
<td>
<form name="frmGraphSettings">
<table>
<tr>
<td>
Total Count:
</td>
<td>
<input type=text name="total" value="100">
</td>
</tr>
<tr>
<td>
1) <input type=text name="label_1" value="A" size="4">
</td>
<td>
#:<input type=text name="count_1" value="50" size="4">
</td>
</tr>
<tr>
<td>
2) <input type=text name="label_2" value="B" size="4">
</td>
<td>
#:<input type=text name="count_2" value="40" size="4">
</td>
</tr>
<tr>
<td>
3) <input type=text name="label_3" value="C" size="4">
</td>
<td>
#:<input type=text name="count_3" value="30" size="4">
</td>
</tr>
<tr>
<td>
4) <input type=text name="label_4" value="D" size="4">
</td>
<td>
#:<input type=text name="count_4" value="20" size="4">
</td>
</tr>
<table>
<br>
<hr>
<br>
<table>
<tr>
<td>
Bar Width:
</td>
<td>
<input type=text name="cust_bar_width" value="35">
</td>
</tr>
<tr>
<td>
Maximum Bar Height:
</td>
<td>
<input type=text name="cust_bar_height" value="200">
</td>
</tr>
<tr>
<td>
Space Between Bars:
</td>
<td>
<input type=text name="cust_dead_space" value="10">
</td>
</tr>
<tr>
<td>
Bar Color:
</td>
<td>
<input type=text name="cust_bar_color" value="FF0000">
</td>
</tr>
<tr>
<td>
Background Color:
</td>
<td>
<input type=text name="cust_bg_color" value="FFFFFF">
</td>
</tr>
<tr>
<td>
Text and Line Color:
</td>
<td>
<input type=text name="cust_text_color" value="000000">
</td>
</tr>
<tr>
<td>
Bar Border Color:
</td>
<td>
<input type=text name="cust_bar_border_color" value="000000">
</td>
</tr>
<tr>
<td>
Maximum Number Of Bars
</td>
<td>
<input type=text name="cust_max_num_bars" value="4">
</td>
</tr>
<tr>
<td>
Vertical Steps (y-axis labels):
</td>
<td>
<input type=text name="cust_vertical_steps" value="20">
</td>
</tr>
<tr>
<td>
Font Size:
</td>
<td>
<input type=text name="cust_font_size" value="10">
</td>
</tr>
<tr>
<td>
Show Percentages in Bars?
</td>
<td>
<select name="cust_show_flag">
<option value="true" selected>Yes</option>
<option value="false">No</option>
</select>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
<%
Option Explicit
Dim cust_bar_width, cust_bar_height, cust_dead_space
Dim cust_bar_color, cust_bg_color, cust_text_color, cust_bar_border_color
Dim cust_max_num_bars, cust_vertical_steps
Dim cust_font_size
Dim cust_show_flag
cust_bar_width = cInt(Request.QueryString("cust_bar_width"))
cust_bar_height = cInt(Request.QueryString("cust_bar_height"))
cust_dead_space = cInt(Request.QueryString("cust_dead_space"))
cust_bar_color = "#"&Request.QueryString("cust_bar_color")
cust_bg_color = "#"&Request.QueryString("cust_bg_color")
cust_text_color = "#"&Request.QueryString("cust_text_color")
cust_bar_border_color = "#"&Request.QueryString("cust_bar_border_color")
cust_max_num_bars = cInt(Request.QueryString("cust_max_num_bars"))
cust_vertical_steps = cInt(Request.QueryString("cust_vertical_steps"))
cust_font_size = cInt(Request.QueryString("cust_font_size"))
cust_show_flag = Request.QueryString("cust_show_flag")
'Response.Write "cust_bar_width:"&cust_bar_width&"<br>"
'Response.Write "cust_bar_height:"&cust_bar_height&"<br>"
'Response.Write "cust_dead_space:"&cust_dead_space&"<br>"
'Response.Write "cust_bar_color:"&cust_bar_color&"<br>"
'Response.Write "cust_bg_color:"&cust_bg_color&"<br>"
'Response.Write "cust_text_color:"&cust_text_color&"<br>"
'Response.Write "cust_bar_border_color:"&cust_bar_border_color&"<br>"
'Response.Write "cust_max_num_bars:"&cust_max_num_bars&"<br>"
'Response.Write "cust_vertical_steps:"&cust_vertical_steps&"<br>"
'Response.Write "cust_font_size:"&cust_font_size&"<br>"
'Response.Write "cust_show_flag:"&cust_show_flag&"<br>"
Function DoTheGraph
InitializeGraphCustom cust_bar_height,cust_bar_width,cust_dead_space
InitializeGraphColors cust_bar_color,cust_bar_border_color, cust_bg_color, cust_text_color
SetMaximumNumberOfBars cust_max_num_bars
SetVerticalSteps cust_vertical_steps
SetFontSize cust_font_size
If cust_show_flag = "true" Then 'cBool could be used here
cust_show_flag = true
Else
cust_show_flag = false
End If
SetShowPercentages cust_show_flag
BeginGraph
SetTotal(Request.QueryString("total"))
AddBar cInt(Request.QueryString("count_1")),Request.QueryString("label_1")
AddBar cInt(Request.QueryString("count_2")),Request.QueryString("label_2")
AddBar cInt(Request.QueryString("count_3")),Request.QueryString("label_3")
AddBar cInt(Request.QueryString("count_4")),Request.QueryString("label_4")
DisplayGraph
End Function
%>
<html>
<head>
<!--#INCLUDE FILE="scripts/Pseudo_Graph_Object.asp" -->
</head>
<body>
<%
'Call My Graph Function
DoTheGraph
%>
</body>
</html>