Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can I use ASP to generate a graph based on the data 2

Status
Not open for further replies.

d1004

Programmer
May 9, 2002
78
US
I want to generate a histogram graph based from the data I got from the recordset and the calculation. If that is the case, can I use ASP to do that. If not, do you know any good method to get the graph populated dynamically?
 
Hi ...
There are some objects which do thid but they are not free and you have to buy them.
but if your clients use IE and not Netscape, you can use
VML.
it's very powerfull but only IE supports it.

TNX.
E.T.
 
It depends on how exact you want the data. I created a graph function using a combination of ASP, HTML, and CSS that was relatively accurate on a 200x200 resolution (within 3 pixels if I remember correctly). Basically the way it worked was that I created a table with a standard MAXHEIGHT value using the CSS attribute height. It had a preset maximum number of rows with which it used to decide on the column width. Then I created div's inside each column tag that were aligned to the bottom of the graph and set their height according to the MAXHEIGHT times each data value divided by the total of the data values:ie barheight = MAXHEIGHT * val/totalVal
The only problem I ran into was padding and spacing. For it to work properly I had to set cell spacing to 0, cell padding to 0 and padding on the div's to 0. Then I just set the bar colors using CSS.
The entire thing was inside an absolutely positioned box because the bars needed to overlay some horizantal lines with percentages. Those were simply a table the other way with fixed height rows, border-bottom set, width about 20 px greater than the table with the bars, and numbers aligned to the left.
If you'd like I'll dig it up to give a better set of examples, it's been a while since I have played with it.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
I heard that can use Java Applet for it, but I am not familiar with it. But Tarwin... you said that I can do it with HTML and CSS. If I can understand correctly, you said to build a table using pixel & css color for bar. So I need to set a certain percentage for certain amount of pixel. You are right, it is confusing.
 
Well, hate to give stuff away for free, but here you go. The first file is the script behind the graph, the second file and third file is a sample implementation I used for playing with the settings.
Pseudo_Graph_Object.asp
Code:
<%

'**************************************************************************************************
'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 &quot;#A9FFA9&quot;,&quot;#000000&quot;,&quot;#FFFFFF&quot;,&quot;#000000&quot;
	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 &quot;#A9FFA9&quot;,&quot;#000000&quot;,&quot;#FFFFFF&quot;,&quot;#000000&quot;
	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 &quot;<b>Error, Graph was not initialized.</b>&quot;
	Else
		beginFlag = true
		bar_counter = 0
		%>
		<table STYLE=&quot;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%>;&quot; valign=bottom border=&quot;0&quot;>
		<%
		Dim num_vertical_steps, vertical_count
		num_vertical_steps = cInt(100/VERTICAL_STEPS)
		For vertical_count = 1 to num_vertical_steps
			%>
			<tr style=&quot;height:<%=(MAX_BAR_HEIGHT/num_vertical_steps)-5%>px;font-size:<%=FONT_SIZE%>;color:<%=TEXT_COLOR%>;&quot;>
				<td style=&quot;<%
						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%>;&quot; valign=top><%=(num_vertical_steps - vertical_count + 1)*VERTICAL_STEPS%>%</td>
			</tr>
			<%
		Next	
		%>
		</table>
		<table STYLE=&quot;position:absolute;top:38px;left:30px;width:<%=((BAR_WIDTH + DEAD_SPACE_WIDTH) * MAX_NUM_BARS)%>;&quot; valign=bottom border=&quot;0&quot;>
			<tr>
				<td width=&quot;1&quot; 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 &quot;<b>Error, Total Number of Bars in Graph Exceeded.</b>&quot;
		End If
	Else
		Response.Write &quot;<b>Error, You have either failed to initialize the graph, or not set the total count.</b>&quot;
	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=&quot;bar_area&quot; valign=bottom style=&quot;height:<%=MAX_BAR_HEIGHT%>px;width:<%=BAR_WIDTH%>px;font-size:<%=FONT_SIZE%>px;color:<%=TEXT_COLOR%>;&quot;>
				<%
				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=&quot;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%>;&quot; />
					<%
				Else
					%>
					<div style=&quot;width:<%=BAR_WIDTH%>px;height:10px; background-color:<%=BACKGROUND_COLOR%>;font-size:1px;border:0px solid <%=BAR_BORDER_COLOR%>;&quot; />
					<%
				End If
				%>
			</td>
			<td style=&quot;height:<%=MAX_BAR_HEIGHT%>px;width:<%=DEAD_SPACE_WIDTH%>px;font-size:1px;color:<%=TEXT_COLOR%>;&quot;></td>
			<%
		Next
		
		If bar_counter-1 < MAX_NUM_BARS Then
			For i = bar_counter - 1 To MAX_NUM_BARS
				%>
				<td class=&quot;bar_area&quot; valign=bottom style=&quot;height:<%=MAX_BAR_HEIGHT%>px;width:<%=BAR_WIDTH%>px;font-size:<%=FONT_SIZE%>px;color:<%=TEXT_COLOR%>;&quot;></td>
				<td style=&quot;height:<%=MAX_BAR_HEIGHT%>px;width:<%=DEAD_SPACE_WIDTH%>px;font-size:1px;color:<%=TEXT_COLOR%>;&quot;></td>
				<%
			Next
		End If

		%>
		</tr>
		<tr>
			<td />
		<%
		For i = 0 to bar_counter-1
			%>
			<td class=&quot;label_area&quot; valign=bottom style=&quot;width:<%=BAR_WIDTH%>px;font-size:<%=FONT_SIZE%>px;color:<%=TEXT_COLOR%>;text-align:center&quot;>
				<%=labels(i)%>
			</td>
			<td />
			<%
		Next
		%>
		</tr>
	</table>
	<%
	Else
		If NOT addFlag Then
			Response.Write &quot;<span style='z-index:100;position:absolute;left:45px;top:55;padding:10px;border:1px solid #000000;background:#eeeeee;'><b>No Data.</b></span>&quot;
		Else
			Response.Write &quot;<span style='z-index:100;position:absolute;'><b>Error Displaying Graph: &quot;
			IF NOT initFlag Then
				Response.Write &quot;Not Initialized.&quot;
			ElseIf NOT totalFlag Then
				Response.Write &quot;No Total Set.&quot;		
			ElseIf NOT beginFlag Then
				Response.Write &quot;No Begin Called.&quot;
			Else
				Response.Write &quot;Unknown Error. Contact Administrator.&quot;
			End If
			Response.Write &quot;</b></span>&quot;
		End If
	End If
End Function

%>

Graph_Test.asp
Code:
<%
Option Explicit

%>
<html>
<head>
<title> Testing Pseudo Graph Object </title>
<script language=&quot;JavaScript&quot;>
<!--
function do_changes(){
	document.all.g_display.src = &quot;graph_test2.asp?cust_bar_width=&quot; + frmGraphSettings.cust_bar_width.value + &quot;&cust_bar_height=&quot; + frmGraphSettings.cust_bar_height.value + &quot;&cust_dead_space=&quot; + frmGraphSettings.cust_dead_space.value + &quot;&cust_bar_color=&quot; + frmGraphSettings.cust_bar_color.value + &quot;&cust_bg_color=&quot; + frmGraphSettings.cust_bg_color.value + &quot;&cust_text_color=&quot; + frmGraphSettings.cust_text_color.value + &quot;&cust_bar_border_color=&quot; + frmGraphSettings.cust_bar_border_color.value + &quot;&cust_max_num_bars=&quot; + frmGraphSettings.cust_max_num_bars.value + &quot;&cust_vertical_steps=&quot; + frmGraphSettings.cust_vertical_steps.value + &quot;&cust_font_size=&quot; + frmGraphSettings.cust_font_size.value + &quot;&cust_show_flag=&quot; + frmGraphSettings.cust_show_flag.value + &quot;&total=&quot; +frmGraphSettings.total.value+ &quot;&label_1=&quot; +frmGraphSettings.label_1.value+ &quot;&count_1=&quot; +frmGraphSettings.count_1.value+ &quot;&label_2=&quot; +frmGraphSettings.label_2.value+ &quot;&count_2=&quot; +frmGraphSettings.count_2.value+ &quot;&label_3=&quot; +frmGraphSettings.label_3.value+ &quot;&count_3=&quot; +frmGraphSettings.count_3.value+ &quot;&label_4=&quot; +frmGraphSettings.label_4.value+ &quot;&count_4=&quot; +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=&quot;#&quot; onClick=&quot;do_changes();&quot;>Show Changes</a></center>
			<iframe id=g_display name=&quot;g_display&quot; src=&quot;&quot; width=400 height=400>test</iframe><br>
		</td>
		<td>
<form name=&quot;frmGraphSettings&quot;>
		<table>
		<tr>
			<td>
				Total Count:
			</td>
			<td>
				<input type=text name=&quot;total&quot; value=&quot;100&quot;>
			</td>
		</tr>
		<tr>
			<td>
				1) <input type=text name=&quot;label_1&quot; value=&quot;A&quot; size=&quot;4&quot;>
			</td>
			<td>
				#:<input type=text name=&quot;count_1&quot; value=&quot;50&quot; size=&quot;4&quot;>
			</td>
		</tr>
		<tr>
			<td>
				2) <input type=text name=&quot;label_2&quot; value=&quot;B&quot; size=&quot;4&quot;>
			</td>
			<td>
				#:<input type=text name=&quot;count_2&quot; value=&quot;40&quot; size=&quot;4&quot;>
			</td>
		</tr>
		<tr>
			<td>
				3) <input type=text name=&quot;label_3&quot; value=&quot;C&quot; size=&quot;4&quot;>
			</td>
			<td>
				#:<input type=text name=&quot;count_3&quot; value=&quot;30&quot; size=&quot;4&quot;>
			</td>
		</tr>
		<tr>
			<td>
				4) <input type=text name=&quot;label_4&quot; value=&quot;D&quot; size=&quot;4&quot;>
			</td>
			<td>
				#:<input type=text name=&quot;count_4&quot; value=&quot;20&quot; size=&quot;4&quot;>
			</td>
		</tr>
	<table>
	<br>
	<hr>
	<br>
	<table>
		<tr>
			<td>
				Bar Width: 
			</td>
			<td>
				<input type=text name=&quot;cust_bar_width&quot; value=&quot;35&quot;>
			</td>
		</tr>
		<tr>
			<td>
				Maximum Bar Height:
			</td>
			<td>
				<input type=text name=&quot;cust_bar_height&quot; value=&quot;200&quot;>
			</td>
		</tr>
		<tr>
			<td>
				Space Between Bars:
			</td>
			<td>
				<input type=text name=&quot;cust_dead_space&quot; value=&quot;10&quot;>
			</td>
		</tr>
		<tr>
			<td>
				Bar Color:
			</td>
			<td>
				<input type=text name=&quot;cust_bar_color&quot; value=&quot;FF0000&quot;>
			</td>
		</tr>
		<tr>
			<td>
				Background Color:
			</td>
			<td>
				<input type=text name=&quot;cust_bg_color&quot; value=&quot;FFFFFF&quot;>
			</td>
		</tr>
		<tr>
			<td>
				Text and Line Color:
			</td>
			<td>
				<input type=text name=&quot;cust_text_color&quot; value=&quot;000000&quot;>
			</td>
		</tr>
		<tr>
			<td>
				Bar Border Color:
			</td>
			<td>
				<input type=text name=&quot;cust_bar_border_color&quot; value=&quot;000000&quot;>
			</td>
		</tr>
		<tr>
			<td>
				Maximum Number Of Bars
			</td>
			<td>
				<input type=text name=&quot;cust_max_num_bars&quot; value=&quot;4&quot;>
			</td>
		</tr>
		<tr>
			<td>
				Vertical Steps (y-axis labels):
			</td>
			<td>
				<input type=text name=&quot;cust_vertical_steps&quot; value=&quot;20&quot;>
			</td>
		</tr>
		<tr>
			<td>
				Font Size:
			</td>
			<td>
				<input type=text name=&quot;cust_font_size&quot; value=&quot;10&quot;>
			</td>
		</tr>
		<tr>
			<td>
				Show Percentages in Bars?
			</td>
			<td>
				<select name=&quot;cust_show_flag&quot;>
					<option value=&quot;true&quot; selected>Yes</option>
					<option value=&quot;false&quot;>No</option>
				</select>
			</td>
		</tr>
	</table>
	</form>
		</td>
	</tr>
</table>
</body>
</html>

graph.asp
Code:
<%
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(&quot;cust_bar_width&quot;))
cust_bar_height = cInt(Request.QueryString(&quot;cust_bar_height&quot;))
cust_dead_space = cInt(Request.QueryString(&quot;cust_dead_space&quot;))
cust_bar_color = &quot;#&quot;&Request.QueryString(&quot;cust_bar_color&quot;)
cust_bg_color = &quot;#&quot;&Request.QueryString(&quot;cust_bg_color&quot;)
cust_text_color = &quot;#&quot;&Request.QueryString(&quot;cust_text_color&quot;)
cust_bar_border_color = &quot;#&quot;&Request.QueryString(&quot;cust_bar_border_color&quot;)
cust_max_num_bars = cInt(Request.QueryString(&quot;cust_max_num_bars&quot;))
cust_vertical_steps = cInt(Request.QueryString(&quot;cust_vertical_steps&quot;))
cust_font_size = cInt(Request.QueryString(&quot;cust_font_size&quot;))
cust_show_flag = Request.QueryString(&quot;cust_show_flag&quot;)

'Response.Write &quot;cust_bar_width:&quot;&cust_bar_width&&quot;<br>&quot;
'Response.Write &quot;cust_bar_height:&quot;&cust_bar_height&&quot;<br>&quot;
'Response.Write &quot;cust_dead_space:&quot;&cust_dead_space&&quot;<br>&quot;
'Response.Write &quot;cust_bar_color:&quot;&cust_bar_color&&quot;<br>&quot;
'Response.Write &quot;cust_bg_color:&quot;&cust_bg_color&&quot;<br>&quot;
'Response.Write &quot;cust_text_color:&quot;&cust_text_color&&quot;<br>&quot;
'Response.Write &quot;cust_bar_border_color:&quot;&cust_bar_border_color&&quot;<br>&quot;
'Response.Write &quot;cust_max_num_bars:&quot;&cust_max_num_bars&&quot;<br>&quot;
'Response.Write &quot;cust_vertical_steps:&quot;&cust_vertical_steps&&quot;<br>&quot;
'Response.Write &quot;cust_font_size:&quot;&cust_font_size&&quot;<br>&quot;
'Response.Write &quot;cust_show_flag:&quot;&cust_show_flag&&quot;<br>&quot;

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 = &quot;true&quot; 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(&quot;total&quot;))
	AddBar cInt(Request.QueryString(&quot;count_1&quot;)),Request.QueryString(&quot;label_1&quot;)
	AddBar cInt(Request.QueryString(&quot;count_2&quot;)),Request.QueryString(&quot;label_2&quot;)
	AddBar cInt(Request.QueryString(&quot;count_3&quot;)),Request.QueryString(&quot;label_3&quot;)
	AddBar cInt(Request.QueryString(&quot;count_4&quot;)),Request.QueryString(&quot;label_4&quot;)
	DisplayGraph
End Function
%>

<html>
<head>
	<!--#INCLUDE FILE=&quot;scripts/Pseudo_Graph_Object.asp&quot; -->
</head>
<body>
	<% 
	'Call My Graph Function
	DoTheGraph
	%>
</body>
</html>

As mentioned in the test file, the number of bars is fixed because I was to lazy to create new text inputs everytime it changed. Just about everything is configurable and soince this is not an actual component, only a set of included functions that spit out generated html, you do need to call the functions in the same order as they are called in the graph function. This is set up to run in an innerframe because I actually needed to be able to make changes to the graph without refreshing the entire page, ie with javascript and refreshing with querystrings. Let me know if it's useful.
It is not necessary to make all of the individual settings I did in the last file, I was only doing that because I needed the ability to change everything on the fly while I was working on color and design issues.

Also, may not be fully compatible with netscape as I wrote it for an IE application, but the basic concept should work and shouldn't be to difficult to fix for NS as well, I just didn't have the need at the time.

If nothing else, it's a good example to prove it can be done :)
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
I apologize, the last file is actually graph_test2.asp.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Beautifull job Tarwin!!!!!! I've tried your scripts. I get an error with graph_test2.asp though. If you are still feeling benevolent could you please try explain it to me? When I run the page it throws an error
Error Type:
Microsoft VBScript runtime (0x800A000B)
Division by zero
/scripts/Pseudo_Graph_Object.asp, line 144 I've given you a star for this one I am impressed &quot;O Great One&quot;
 
Odd. I apologize for not mentioning the the object was supposed to be in a sub folder called, scripts, I assume you figured it out though.

The error shouldn't be occurring...VERTICAL_STEPS was set in both of the initialization functions to a default value of 20. Is it possible you tried to change the vertical steps to 0? Try opening graph_Test.asp and click the Show Changes without actually making changes. The graph should appear, and that setup is nearly identical to calling the InitializeGraphDefaults function instead of doing all the custom stuff I did. If the Pseudo file is in a subfolder called scripts and you try the above and it still doesn't work, let me know. I am running IE6 and it works fine, I think I developed it on 5.5, so that shouldn't be the problem.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Hi I ran both files and graph_test.asp worked flawlessly. I never made any changes to the graph and when I ran graph_test2.asp it gave me the same error???? I'm also running IE 6 is it possible that the code you posted is different from the original. As per having the pseudo graph code in a folder called scripts Yes I figured that out when it gave me the can't find file error.I checked the pseudo file and vertical steps is set to 20. I'm at a loss it does seem to me that it should work in both files.
 
Ah Ha! figured it out. Don't run graph_test2.asp :)
graph_test is merely the front end to make the querystring that it sends to the inner frame. The innerframe displays graph_test2.asp?lots_of_stuff
graph_test2 actually depends on the information sent to it by graph_test, it was made that way because I was only trying to mess with values and didn't want to keep going into the code and changing them by hand, so I created graph_test to set values and graph_test2 to run in the innerframe, accept values, and do the whole graphing bit :)
So basically all of the work and magic and stuff happens in graph_test2 and you could hardcode values in (in fact that is the intention) it was only in this case that I wanted to pass those settings in to play with em. :p My mistake.

When running a page you would have to have a similar set up, with one main page and then something like graph_test2.asp running in an innerframe. The reason I did it that way is because my final graph.asp file that actually does everything that graph_test2.asp does (ie, build the graph) also had more error checking and stuff built in, as well as a bunch of database connections and so. That way I could update/refrsh the graph in it's little innerframe without refreshing my entire page.

Hope that wasn't to confusing. Basically, in a nutshell:
graph_test only lets you fill in form values, it doesn't actually do anything except pass a URL to the inner frame
graph_test2 does all the work, taking values from the querystring and creating a custom grapoh on the fly. It's not necessary to do it this way as in the real world you would have your users changing the colors and such, it would all be hard coded in your version of graph_test2.
I'm an oscar-meyer wiener...
Sorry, to long without coffee :)
-Tarwn ------------ My Little Dictionary ---------
Extreme Programming - (1)Trying to code before my second cup of coffee. (2) While(1){ Ctrl+C; Ctrl+V; }
FAQ - Web-ese for &quot;Forget Asking Questions, I am to busy&quot; :p
 
Well thatz all clear now. I appreciate your explanation. Thanx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top