Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old September 8th, 2008, 05:22 PM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default plotting graph using ASP or VB script ?

Does any one know how to plot this kind of graph ? Go to this kind to see the graph?

http://www.ekopower.nl/index.htm

Help...help me !
Reply
  #2  
Old September 9th, 2008, 08:07 AM
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 924
Default

Hi Ugene,

Welcome to Bytes.com! Any of these any good to you?

Dr B
Reply
  #3  
Old September 9th, 2008, 09:31 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

hey DrBunchman ...thanks alot...this is a great site..
Reply
  #4  
Old September 9th, 2008, 10:30 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

hey DrBunchman but i wanted to change my graph from histogram/bar graph to the zig-zag kind of graph...i find mostly is pie charts..how ?
Reply
  #5  
Old September 9th, 2008, 10:40 AM
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 924
Default

How about this line graph example? Is that what you wanted?

Dr B
Reply
  #6  
Old September 10th, 2008, 03:17 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

Yes ! but i want to hardcode my figure in ..can i ?
Reply
  #7  
Old September 10th, 2008, 03:28 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

I tried by copying the database and the source code into the server side so then from the client side i unable to process the graph i saw it on the link u gave me ...how come ? Is it i have to change to file name and path and so on ?
Reply
  #8  
Old September 10th, 2008, 09:00 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

after i tried changing the path and stuff i only can get the graph by hardcoding the data..so i cannot get the data thru connecting the database given ..

but now i want to let it read the data from a excel file..how to read it ?how to set the connection ?
Reply
  #9  
Old September 12th, 2008, 02:45 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

hey DrBunchman do u know how to set the connection to read the figures on microsoft excel?i am able to set the and see the graph only when i hardcode in the figure...help !
Reply
  #10  
Old September 12th, 2008, 07:57 AM
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 924
Default

Hi Ugene,

What code have you got so far? I presume that it is possible to use these graph objects with a connection so it's probably just a case of getting it set up correctly.

Dr B
Reply
  #11  
Old September 18th, 2008, 10:29 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

hi DrBunchman,i currently have these codes
---------------------------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
  2.  
  3. <%@ Language=VBScript %>
  4. <%
  5. ' Set Connection Params
  6. Set oConn = Server.CreateObject("ADODB.connection")
  7. oConn.Open "Driver={Microsoft Excel Driver (*.xls)}; DriverId=790;" &_
  8. "DBQ=C:\Inetpub\wwwroot\InfoWeb\14Apr08_NUS_hr_Data.xls;" &_
  9. "DefaultDir = C:\Inetpub\wwwroot\InfoWeb\"
  10.  
  11. Set RS=Server.CreateObject("ADODB.recordset")
  12.  
  13. ' Write the SQL Query
  14. RS.open "SELECT * FROM my_range", oConn
  15.  
  16. do until RS.EOF
  17. Response.Write ( RS("Item No") & " -- " & RS("Item Description") & "<br>")
  18. RS.movenext
  19. Loop
  20.  
  21. 'Close the recordset/connection
  22.  
  23. RS.Close
  24. oConn.Close
  25. Set RS = Nothing
  26. %>
  27.  
  28.  
  29.  
  30.  
  31. <html>
  32. <head>
  33.     <title>Pressure Chart</title>
  34. </head>
  35. <body>
  36.  
  37.  
  38. <applet codebase="new" code="linegraph.class" height=220 width=360>
  39.     <param name="title" value="Sales">
  40.     <param name="NumberOfVals" value="<%=sqlQuery.RecordCount%>">
  41.     <param name="NumberOfLabs" value="<%=sqlQuery.RecordCount%>">
  42.     <PARAM NAME=ymax VALUE=<%=(Fix(sqlQuery("M")/10000)+1)*10000%>>
  43.     <PARAM NAME=ymin VALUE=0>
  44.     <PARAM NAME=mode VALUE=0>
  45.     <PARAM NAME=border VALUE="20">    <PARAM NAME=Grid VALUE="true">
  46.     <PARAM NAME=LineColor_R_L1 VALUE=53>
  47.     <PARAM NAME=LineColor_G_L1 VALUE=153>
  48.     <PARAM NAME=LineColor_B_L1 VALUE=51>    
  49. <%
  50. i = 1
  51. while (not sqlQuery.EOF) %>
  52.     <param name="VAL<%=i%>_L1" value="<%=sqlQuery("SalesTotal")%>">
  53.     <param name="LAB<%=i%>" value="<%=MonthName(Month(sqlQuery("Date")))%>">
  54. <%
  55. i = i + 1
  56. sqlQuery.MoveNext
  57. wend %>
  58.  
  59. </APPLET><p>
  60.  
  61. </body>
  62. </html>
-------------------------------------------------------------------------------------------------------
So how do i set my range which i underline? there are error in the codes could you point out to me ?

this is the error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e37'

[Microsoft][ODBC Excel Driver] The Microsoft Jet database engine could not find the object 'my_range'. Make sure the object exists and that you spell its name and the path name correctly.

/Infoweb/pressure.asp, line 15

Last edited by DrBunchman; September 18th, 2008 at 03:05 PM. Reason: Added [Code] Tags - Please use the '#' button
Reply
  #12  
Old September 23rd, 2008, 04:14 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

hey DrBunchman..

Now i have got the connection correct..and now its able to display the data in the excel file on a browser in a table form..so now i have to plot it i alraedy got the applet working but now is how to get the connect between the applet with the data ?

below is the correct data for the connection between excel and ASP..so if any 1 need it can play around with it..


This is the working code between my ASP and excel..
------------------------------------------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. <% Option Explicit %>
  2. <html>
  3. <body>
  4.  
  5. <%
  6. Dim objConn, objRS, strSQL
  7. Dim x, curValue
  8.  
  9. Set objConn = Server.CreateObject("ADODB.Connection")
  10. objConn.Open "DRIVER={Microsoft Excel Driver (*.xls)}; IMEX=1; HDR=NO; "&_
  11.     "DBQ=C:\Inetpub\wwwroot\InfoWeb\14Apr08_NUS_hr_Data.xls;"
  12.  
  13. strSQL = "SELECT * FROM D1:D170"
  14. Set objRS=objConn.Execute(strSQL)
  15. Response.Write("<table border=""1"">")
  16. Response.Write("<tr>")
  17. For x=0 To objRS.Fields.Count-1
  18.    Response.Write("<th>" & objRS.Fields(x).Name & "</th>")
  19. Next
  20. Response.Write("</tr>")
  21. Do Until objRS.EOF
  22.     Response.Write("<tr>")
  23.     For x=0 To objRS.Fields.Count-1
  24.         curValue = objRS.Fields(x).Value
  25.         If IsNull(curValue) Then
  26.             curValue="N/A"
  27.         End If
  28.         curValue = CStr(curValue)
  29.         Response.Write("<td>" & curValue & "</td>")
  30.     Next
  31.     Response.Write("</tr>")
  32.     objRS.MoveNext
  33. Loop
  34. objRS.Close
  35. Response.Write("</table>")
  36.  
  37. objConn.Close
  38. Set objRS=Nothing
  39. Set objConn=Nothing
  40. %>
  41.  
  42. </body>
  43. </html>
--------------------------------------------------------------------------

Below is the code of applet to plot the graph how to connect it?
that is a hardcoded in the applet.how to use this graph with the data displayed?
hope u could help me .
-------------------------------------------------------------------------
Expand|Select|Wrap|Line Numbers
  1. <APPLET CODE="linegraph.class" HEIGHT=220 WIDTH=360>
  2. <PARAM NAME=NumberOfVals VALUE=36>
  3. <PARAM NAME=NumberOfLabs VALUE=4>
  4. <PARAM NAME=KeyWidth VALUE=70>
  5.  
  6. <PARAM NAME=LineColor_R_L1 VALUE=0>
  7. <PARAM NAME=LineColor_G_L1 VALUE=0>
  8. <PARAM NAME=LineColor_B_L1 VALUE=200>
  9.  
  10. <PARAM NAME=LineColor_R_L2 VALUE=200>
  11. <PARAM NAME=LineColor_G_L2 VALUE=0>
  12. <PARAM NAME=LineColor_B_L2 VALUE=0>
  13.  
  14. <PARAM NAME=yMax VALUE=30>
  15. <PARAM NAME=yMin VALUE=-10>
  16. <PARAM NAME=Mode VALUE=0>
  17. <PARAM NAME=Lines VALUE=2>
  18. <PARAM NAME=Title VALUE="NET PROFIT (K$)">
  19. <PARAM NAME=Border VALUE="30">
  20. <PARAM NAME=Grid VALUE="true">
  21.  
  22. <PARAM NAME=VAL1_L1 VALUE=10.3>
  23. <PARAM NAME=VAL2_L1 VALUE=11.0>
  24. <PARAM NAME=VAL3_L1 VALUE=14.5>
  25. <PARAM NAME=VAL4_L1 VALUE=12.20>
  26. <PARAM NAME=VAL5_L1 VALUE=15.0>
  27. <PARAM NAME=VAL6_L1 VALUE=12.5>
  28. <PARAM NAME=VAL7_L1 VALUE=20.5>
  29. <PARAM NAME=VAL8_L1 VALUE=22.5>
  30. <PARAM NAME=VAL9_L1 VALUE=18.8>
  31. <PARAM NAME=VAL10_L1 VALUE=24>
  32. <PARAM NAME=VAL11_L1 VALUE=27.8>
  33. <PARAM NAME=VAL12_L1 VALUE=29>
  34. <PARAM NAME=VAL13_L1 VALUE=26.9>
  35. <PARAM NAME=VAL14_L1 VALUE=22.4>
  36. <PARAM NAME=VAL15_L1 VALUE=18.0>
  37. <PARAM NAME=VAL16_L1 VALUE=14.8>
  38. <PARAM NAME=VAL17_L1 VALUE=7.5>
  39. <PARAM NAME=VAL18_L1 VALUE=3.2>
  40. <PARAM NAME=VAL19_L1 VALUE=-4.6>
  41. <PARAM NAME=VAL20_L1 VALUE=-2.0>
  42. <PARAM NAME=VAL21_L1 VALUE=1.8>
  43. <PARAM NAME=VAL22_L1 VALUE=2.5>
  44. <PARAM NAME=VAL23_L1 VALUE=-1.1>
  45. <PARAM NAME=VAL24_L1 VALUE=2.5>
  46. <PARAM NAME=VAL25_L1 VALUE=11.9>
  47. <PARAM NAME=VAL26_L1 VALUE=16.6>
  48. <PARAM NAME=VAL27_L1 VALUE=12.6>
  49. <PARAM NAME=VAL28_L1 VALUE=18.7>
  50. <PARAM NAME=VAL29_L1 VALUE=23.9>
  51. <PARAM NAME=VAL30_L1 VALUE=19.9>
  52. <PARAM NAME=VAL31_L1 VALUE=19.5>
  53. <PARAM NAME=VAL32_L1 VALUE=23.5>
  54. <PARAM NAME=VAL33_L1 VALUE=19.0>
  55. <PARAM NAME=VAL34_L1 VALUE=22.5>
  56. <PARAM NAME=VAL35_L1 VALUE=22.9>
  57. <PARAM NAME=VAL36_L1 VALUE=24.6>
  58.  
  59. <PARAM NAME=VAL1_L2 VALUE=14.3>
  60. <PARAM NAME=VAL2_L2 VALUE=12.0>
  61. <PARAM NAME=VAL3_L2 VALUE=11.5>
  62. <PARAM NAME=VAL4_L2 VALUE=17.20>
  63. <PARAM NAME=VAL5_L2 VALUE=12.0>
  64. <PARAM NAME=VAL6_L2 VALUE=13.5>
  65. <PARAM NAME=VAL7_L2 VALUE=25.5>
  66. <PARAM NAME=VAL8_L2 VALUE=21.5>
  67. <PARAM NAME=VAL9_L2 VALUE=11.8>
  68. <PARAM NAME=VAL10_L2 VALUE=14>
  69. <PARAM NAME=VAL11_L2 VALUE=17.8>
  70. <PARAM NAME=VAL12_L2 VALUE=19>
  71. <PARAM NAME=VAL13_L2 VALUE=16.9>
  72. <PARAM NAME=VAL14_L2 VALUE=22.4>
  73. <PARAM NAME=VAL15_L2 VALUE=28.0>
  74. <PARAM NAME=VAL16_L2 VALUE=24.8>
  75. <PARAM NAME=VAL17_L2 VALUE=9.5>
  76. <PARAM NAME=VAL18_L2 VALUE=6.2>
  77. <PARAM NAME=VAL19_L2 VALUE=4.6>
  78. <PARAM NAME=VAL20_L2 VALUE=12.0>
  79. <PARAM NAME=VAL21_L2 VALUE=8.8>
  80. <PARAM NAME=VAL22_L2 VALUE=9.5>
  81. <PARAM NAME=VAL23_L2 VALUE=11.1>
  82. <PARAM NAME=VAL24_L2 VALUE=7.5>
  83. <PARAM NAME=VAL25_L2 VALUE=14.9>
  84. <PARAM NAME=VAL26_L2 VALUE=15.6>
  85. <PARAM NAME=VAL27_L2 VALUE=16.6>
  86. <PARAM NAME=VAL28_L2 VALUE=11.7>
  87. <PARAM NAME=VAL29_L2 VALUE=21.9>
  88. <PARAM NAME=VAL30_L2 VALUE=16.9>
  89. <PARAM NAME=VAL31_L2 VALUE=13.5>
  90. <PARAM NAME=VAL32_L2 VALUE=25.5>
  91. <PARAM NAME=VAL33_L2 VALUE=19.9>
  92. <PARAM NAME=VAL34_L2 VALUE=22.9>
  93. <PARAM NAME=VAL35_L2 VALUE=22.1>
  94. <PARAM NAME=VAL36_L2 VALUE=24.1>
  95.  
  96. <PARAM NAME=LAB1 VALUE="1999">
  97. <PARAM NAME=LAB2 VALUE="2000">
  98. <PARAM NAME=LAB3 VALUE="2001">
  99. <PARAM NAME=LAB4 VALUE="2002">
  100.  
  101. <PARAM NAME=Key_L1 VALUE="ABC Corp">
  102. <PARAM NAME=Key_L2 VALUE="XYZ Corp">
  103.  
  104. </APPLET>
-----------------------------------------------------------------------

Last edited by DrBunchman; September 30th, 2008 at 08:09 AM. Reason: Added [Code] Tags - Please use the '#' button
Reply
  #13  
Old September 29th, 2008, 02:23 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

hey DrBunchman,

did u miss my post?
Reply
  #14  
Old September 29th, 2008, 08:14 AM
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 924
Default

Hi Ugene,

I've not used an applet like this before but I presume that you can build the applet dynamically using your asp code the same way that you have built a table from quering the excel spreadsheet.

Does this make sense?

Dr B
Reply
  #15  
Old September 30th, 2008, 02:55 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

DrBunchman ,

It sounds logical..to display in a table form is via <tr> & <td>. So what are the tags to display it into a line graph? It would be much easier as i don't have to pass it to another method. But do u konw how to go about doing this way ?
Reply
  #16  
Old September 30th, 2008, 08:11 AM
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 924
Default

You have the tags already in your applet example.....rather than using <tr> & <td> you could maybe build the applet tags (e.g. <param />) using the server side code.

I don't know if this is actually possible - any other experts got any experience with this?

Dr B
Reply
  #17  
Old October 2nd, 2008, 01:53 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

hey DrBunchman ,
i manage to get the code out after playing around with it..thanks so much for the help and advise you gave me ! you have been a great help..
Reply
  #18  
Old October 3rd, 2008, 08:56 AM
DrBunchman's Avatar
Moderator
 
Join Date: Jan 2008
Location: Winchester, UK
Posts: 924
Default

Hey Ugene, I'm really pleased to hear you got it working. Perhaps you could let us know how you did it in case anyone else has a similar problem?

Thanks

Dr B
Reply
  #19  
Old October 7th, 2008, 09:28 AM
Newbie
 
Join Date: Sep 2008
Posts: 14
Default

This is the final code which able to let user retrieve data from selected range of the excel file and plot it on a line graph. its here for any 1 that need :)


Expand|Select|Wrap|Line Numbers
  1. <% Option Explicit %>
  2. <html>
  3. <HEAD><TITLE>Line Graph Of Wind Speed</TITLE></HEAD>
  4. <body>
  5.  
  6. <APPLET CODE="linegraph.class" HEIGHT=400 WIDTH=900>
  7.  
  8.  
  9. <%
  10. Dim objConn, objRS, strSQL
  11. Dim x, i, curValue
  12.  
  13. Set objConn = Server.CreateObject("ADODB.Connection")
  14. objConn.Open "DRIVER={Microsoft Excel Driver (*.xls)}; IMEX=1; HDR=NO; "&_
  15.     "DBQ=C:\Inetpub\wwwroot\InfoWeb\14Apr08_NUS_hr_Data.xls;"
  16.  
  17. %>
  18.  
  19.  
  20. <PARAM NAME=NumberOfVals VALUE="24">
  21. <PARAM NAME=NumberOfLabs VALUE="24">
  22.  
  23.  
  24. <PARAM NAME=LineColor_R_L1 VALUE=0>
  25. <PARAM NAME=LineColor_G_L1 VALUE=0>
  26. <PARAM NAME=LineColor_B_L1 VALUE=255>
  27.  
  28. <PARAM NAME=ymax VALUE=4>
  29. <PARAM NAME=ymin VALUE=0>
  30. <PARAM NAME="lines" VALUE=10>
  31. <PARAM NAME="borderright" VALUE=20>
  32. <PARAM NAME="borderleft" VALUE=30>
  33. <PARAM NAME="bordertop" VALUE=20>
  34. <PARAM NAME="borderbase" VALUE=20>
  35. <PARAM NAME="bg_r" VALUE=220>
  36. <PARAM NAME="bg_g" VALUE=240>
  37. <PARAM NAME="bg_b" VALUE=255>
  38. <PARAM NAME="border_r" VALUE=100>
  39. <PARAM NAME="border_g" VALUE=100>
  40. <PARAM NAME="border_b" VALUE=250>
  41. <PARAM NAME="linewidth" VALUE=2>
  42. <PARAM NAME="showpoints" VALUE=1>
  43. <PARAM NAME=fontsize VALUE=13>
  44. <PARAM NAME=Title VALUE="Wind Speed (m/s)">
  45. <PARAM NAME=Border VALUE="30">
  46. <PARAM NAME=Grid VALUE="true">
  47.  
  48. <PARAM NAME=LAB1 VALUE="0100">
  49. <PARAM NAME=LAB2 VALUE="0200">
  50. <PARAM NAME=LAB3 VALUE="0300">
  51. <PARAM NAME=LAB4 VALUE="0400">
  52. <PARAM NAME=LAB5 VALUE="0500">
  53. <PARAM NAME=LAB6 VALUE="0600">
  54. <PARAM NAME=LAB7 VALUE="0700">
  55. <PARAM NAME=LAB8 VALUE="0800">
  56. <PARAM NAME=LAB9 VALUE="0900">
  57. <PARAM NAME=LAB10 VALUE="1000">
  58. <PARAM NAME=LAB11 VALUE="1100">
  59. <PARAM NAME=LAB12 VALUE="1200">
  60. <PARAM NAME=LAB13 VALUE="1300">
  61. <PARAM NAME=LAB14 VALUE="1400">
  62. <PARAM NAME=LAB15 VALUE="1500">
  63. <PARAM NAME=LAB16 VALUE="1600">
  64. <PARAM NAME=LAB17 VALUE="1700">
  65. <PARAM NAME=LAB18 VALUE="1800">
  66. <PARAM NAME=LAB19 VALUE="1900">
  67. <PARAM NAME=LAB20 VALUE="2000">
  68. <PARAM NAME=LAB21 VALUE="2100">
  69. <PARAM NAME=LAB22 VALUE="2200">
  70. <PARAM NAME=LAB23 VALUE="2300">
  71. <PARAM NAME=LAB24 VALUE="0000">
  72.  
  73.  
  74. <%
  75. strSQL = "SELECT * FROM G2:G26"
  76. Set objRS=objConn.Execute(strSQL)
  77.  
  78. i=1
  79. Do Until objRS.EOF
  80.  
  81.     For x=0 To objRS.Fields.Count-1
  82. %>        
  83.     <PARAM NAME="VAL<%=i%>_L1" VALUE="<%=objRS.Fields(x).Value%>">
  84. <%    Next
  85.     i = i + 1
  86.     objRS.MoveNext
  87. Loop
  88. objRS.Close
  89. %>
  90.  
  91. <%
  92. objConn.Close
  93. Set objRS=Nothing
  94. Set objConn=Nothing
  95. %>
  96.  
  97.  
  98.  
  99.  
  100.  
  101. </APPLET>
  102.  
  103. </body>
  104. </html>
Reply
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles