Create a Column Graph

This script will generate a Column Graph with the data indicated in the first part of the script

  • Tableheight will be the height of the table
  • Tablewidth will be the width of the table
  • We will include a list of values separated by commas. These values will be Y values. We will consider X values will start in 1 and the maximun X value will be the total number of values in the list.
In the same directory where this script is located we will need to save the figure bellow:

     red.gif  

You will find the resulting Column Graph bellow
 
<html><body>
<center>

<%
Tableheight=200
Tablewidth=300
DataArray=Array(1,2,3,4,5,6,5,4,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1,1,0)

' lets calculate maximun number of values for Y  
max=ubound(DataArray)

' lets calculate maximun value for Y  
Ymaxvalue=DataArray(0)
for i=1 to max
   if DataArray(i)>Ymaxvalue then 
       Ymaxvalue=DataArray(i)
   end if 
next

response.write("<table border=0 height=" & Tableheight & " cellspacing=0 cellpadding=0><tr><td  valign=top align=center>")

' next line will write minimun and maximun value for Y  
response.write("<table border=0 height=" & Tableheight & " bgcolor=8888FF cellspacing=0 cellpadding=0><tr><td valign=top>")
response.write("Ymaxvalue & "</td></tr><tr><td valign=bottom align=right>O</td></tr></table>")

response.write("</td><td width=" & Tablewidth & "valign=bottom>")

' next lines will create the columns
for x=0 to max
     response.write("<img src=red.gif width=" & Tablewidth/max)
     response.write(" height=" & int(DataArray(x)*Tableheight/Ymaxvalue) & ">")
next
 

response.write("</tr><tr><td></td><td>")
 

' next lines will write minimun and maximun value for X 
response.write("<table width=" & Tablewidth & " border=0 bgcolor=8888FF cellspacing=0 cellpadding=0>")
response.write("<tr><td>")
' this is the minimun value for X 
response.write("1")
response.write("</td><td align=right>")
' this is the maximun value for X
response.write(max+1)
response.write("</td></tr></table>")
 

response.write("</td></tr></table>")
response.write("</td></tr></table>")

%>
</center>
</body>
</html>
 


 

Tableheight=200
Tablewidth=300
DataArray=Array(1,2,3,4,5,6,5,4,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1,1,0)

10
O









   



MSN Nick Name



More Resources...





Most Viewed Services:
  1. HTML Tutorial
  2. XHTML Tutorial
  3. CSS Tutorial
  4. Javascript Tutorial
  5. DHTML Tutorial
  6. VB Script
  7. TCP/IP Tutorial
  8. ADO Tutorial
  9. MYSQL Tutorial
  10. ASP Tutorial
  11. AJAX Tutorial
  12. CFML Tutorial
  13. PHP Tutorial
  14. WML Tutorial
  15. FLASH Tutorial
  16. XML Tutorial
  17. RSS Tutorial
  18. SQL Tutorial
  19. HTML Articles
  1. Javascript Articles
  2. PHP Articles
  3. SEO Articles
  4. Web Design Articles
  5. SEO Tips
  6. Web Design Tips
  7. Articles
  8. CSS
  9. CSS Tips
  10. HTML Tips
  11. JAVASCRIPT Tips
  12. MYSQL Tips
  13. PHP Tips
  14. Money
  15. Tutorials
  16. Web Hosting



  • Home
  • Web Directory
  • Top Directoriers
  • Webmaster Directories
  • Contact
  • © Copyright 2006-2010 All Rights Reserved By CodeDcode.Com : HTML : RSS : TEXT : XML