473,326 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

chart using asp and html

hii...i am creating a chart using html and asp
the code for it is :
Expand|Select|Wrap|Line Numbers
  1.  
  2. <%@ LANGUAGE="VBSCRIPT" %>
  3. <% Option Explicit %>
  4.  
  5. <%
  6. Dim data1Array(3)
  7. data1Array(0) = 5
  8. data1Array(1) = 15
  9. data1Array(2) = 25
  10. data1Array(3) = 50
  11.  
  12.  
  13. Dim data2Array(3)
  14. data2Array(0) = 5
  15. data2Array(1) = 10
  16. data2Array(2) = 20
  17. data2Array(3) = 25
  18.  
  19.  
  20. Dim labelArray(15)
  21. labelArray(0) = "1"
  22. labelArray(1) = "2"
  23. labelArray(2) = "2"
  24. labelArray(3) = "2"
  25. labelArray(4) = "2"
  26. labelArray(5) = "2"
  27. labelArray(6) = "7"
  28. labelArray(7) = "8"
  29. labelArray(8) = "9"
  30. labelArray(9) = "1"
  31. labelArray(10) = "11"
  32. labelArray(11) = "12"
  33. labelArray(12) = "13"
  34. labelArray(13) = "14"
  35. labelArray(14) = "15"
  36. labelArray(15) = "16"
  37.  
  38. %> 
  39.  
  40. <%
  41. 'How many pixels high we want our bar graph
  42. Const graphHeight = 300
  43. Const graphWidth = 450
  44. Const barImage = "bluebar.gif"
  45. Const barImage1 = "redbar.gif"
  46. 'h 300 , w 450
  47.  
  48. sub BarChart(data1 , data2, labels, title, axislabel)
  49.     'Print heading
  50.     Response.Write("<TABLE CELLSPACING=0 CELLPADDING=2 BORDER=1 WIDTH=" & graphWidth & ">" & chr(13))
  51.     Response.Write("<TR><TH COLSPAN=" & UBound(data1) - LBound(data1) + 2 & ">" & chr(13))
  52.     Response.Write("<FONT SIZE=+2>" & title & "</FONT></TH></TR>" & chr(13))
  53.     Response.Write("<TR><TD VALIGN=TOP ALIGN=RIGHT>" & chr(13))
  54.  
  55.     'Find the highest value
  56.     Dim hi
  57.     hi = data1(LBound(data1))
  58.  
  59.     Dim i
  60.     for i = LBound(data1) to UBound(data1)
  61.         if data1(i) > hi then hi = data1(i)
  62.     next
  63.  
  64.  
  65. 'calculating  highest value for the second array
  66.     Dim hi1
  67.     hi1 = data2(LBound(data2))
  68.  
  69.     Dim j
  70.     for j = LBound(data2) to UBound(data2)
  71.         if data2(j) > hi1 then hi1 = data2(j)
  72.     next
  73.  
  74. 'Response.Write("the hightest value")
  75. 'Response.Write(hi1)
  76.  
  77.  
  78.     'Print out the highest value at the top of the chart
  79.     'Response.Write(hi & "</TD>")
  80.  
  81.     Dim widthpercent
  82.     widthpercent = CInt((1 / (UBound(data1) - LBound(data1) + 1)) * 100)
  83.     'response.Write(widthpercent)
  84.  
  85.     'Response.Write(data2(0))
  86.     'Response.Write(hi1)
  87.     'Response.Write(graphHeight)
  88.     'Response.Write(cint(data2(0)/hi1 * graphHeight))
  89.     'Response.End
  90.  
  91.     For i = LBound(data1) to UBound(data1) 
  92.         Response.Write("<td> </td>")
  93.         Response.Write(" <TD VALIGN=BASELINE ROWSPAN=2 WIDTH=" & widthpercent & "% >" & chr(13))
  94.         Response.Write(" <IMG SRC=""" & barImage & """ WIDTH=100% align= bottom HEIGHT=" & CInt(data1(i)/hi * graphHeight)  & "/>" & chr(13))
  95.         response.Write(Cint(data1(i)/hi*graphHeight))
  96.         Response.Write(" <TD VALIGN=BASELINE ROWSPAN=2 WIDTH=" & widthpercent & "% >" & chr(13))
  97.  
  98.         'response.end
  99.         Response.Write(" <IMG SRC=""" & barImage1& """ WIDTH=100% align= bottom  HEIGHT=" & CInt(data2(i)/hi1 * graphHeight)  & "/>" & chr(13))
  100.         response.Write(Cint(data2(i)/hi*graphHeight))
  101.         Response.Write(" </TD>" & chr(13))
  102.         'Response.Write("<td> </td>")
  103.         'Response.Write("<td> </td>")
  104.          'response.Write("<br>")
  105.          '
  106.          'response.Write("<br>")    
  107.     Next
  108.     'response.end
  109.  
  110.  
  111.     Response.Write("</TR>")
  112.     Response.Write("<TR><TD VALIGN=BOTTOM ALIGN=RIGHT>0</TD></TR>")
  113.  
  114.     'Write footer
  115.     Response.Write("<TR><TD ALIGN=RIGHT VALIGN=BOTTOM>" & axislabel & "</TD>" & chr(13))
  116.     for i = LBound(labels) to UBound(labels)
  117.         Response.Write("<TD VALIGN=BOTTOM ALIGN=CENTER>" & labels(i) & "</TD>" & chr(13))
  118.     next
  119.     Response.Write("</TR>" & chr(13))
  120.     Response.Write("</TABLE>")
  121. end sub
  122.  
  123.  
  124. %>
  125.  
  126. <HTML>
  127. <BODY>
  128. <CENTER>
  129. <% Call BarChart(data1Array,data2Array,labelArray,"Telephone Sales","Date") %>
  130. </CENTER>
  131. </BODY>
  132. </HTML>
  133.  
now the problem is even tough in the following lines, i pass same value for the HEIGHT ATTRIBUTE with data1(0) and data2(0) ARRAYS the displayed height of the image is not same.
SIMILARLY THE HEIGHT SHOWN WITH OTHER ELEMENTS IS ALSO NOT PROPER
Expand|Select|Wrap|Line Numbers
  1. Response.Write(" <TD VALIGN=BASELINE ROWSPAN=2 WIDTH=" & widthpercent & "% >" & chr(13))
  2. Response.Write(" <IMG SRC=""" & barImage & """ WIDTH=100% align= bottom HEIGHT=" & CInt(data1(i)/hi * graphHeight)  & "/>" & chr(13))
  3. Response.Write(" <TD VALIGN=BASELINE ROWSPAN=2 WIDTH=" & widthpercent & "% >" & chr(13))
  4. Response.Write(" <IMG SRC=""" & barImage1& """ WIDTH=100% align= bottom  HEIGHT=" & CInt(data2(i)/hi1 * graphHeight)  & "/>" & chr(13))
  5.  
i am attatching a image file to make my problem more clear..
thank's..
Attached Images
File Type: jpg results.jpg (13.2 KB, 203 views)
Mar 25 '09 #1
1 2034
jhardman
3,406 Expert 2GB
why is one divided by hi1, and the other is divided by hi? What do you get when you print out CInt(data2(i)/hi1 * graphHeight) and CInt(data1(i)/hi*graphHeight)?
Mar 27 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mick Turner | last post by:
I have connected to SQL Server database (server-side vbscript) and read some data from the tables. This works correctly. I now have the data in an array (server-side). I have to draw a...
3
by: StBond | last post by:
Hi everyone, I am new to Access and Visual Basic so things my be getting across a bit cloudy. I only started using VB for one week. I am having a little problem with the database that I am...
9
by: Patrick.O.Ige | last post by:
I have a code below and its a PIE & BAR CHART. The values now are all static but I want to be able to pull the values from a database. Can you guys give me some ideas to do this? Thanks ...
8
by: LB | last post by:
Hello everybody I'm learning how to create pie chart using OWC. I'm able now to create a pie. But I can not figure out how to do the following : - for each pie, when mousing over, I would like...
18
by: Marcel Saucier | last post by:
Hello, I want to use the above characters codes chart but I dont know how to set the typeface (documentation: The characters that appear in Windows above 127 depend on the selected typeface). ...
3
by: C Did | last post by:
What's the best cheapest way to get pie charts on the web with my setup? Thanks!!
2
by: RoseW | last post by:
I suggested to a friend that a css controlled table would be preferrable to the existing chart produced in Excel stored at http://www.delmarcottages.ca/cottages/bookings/cottagebookings.htm They...
1
by: cubekid | last post by:
I am using OWC 11 in my new web application for displaying charts. Is it possible in OWC 11 to combine and display a column and a line graph (Looking like they overlap each other)? I tried it using...
2
by: aashishn86 | last post by:
hii...i am creating a chart using html and asp the code for it is : <%@ LANGUAGE="VBSCRIPT" %> <% Option Explicit %> <% Dim data1Array(3) data1Array(0) = 5
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.