ASP 101 - Active Server Pages 101 - Web04
The Place ASP Developers Go!

Please visit our partners


Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash




Script Output:

Chart Title

Y Label
55 
6 10 12 18 23 26 27 28 30 34 37 45 55
P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13

X Label



Chart of 50 Random Numbers

Value
50 
40 25 46 28 38 33 31 11 35 16 24 19 11 47 10 37 40 27 37 13 2 21 18 47 34 46 0 38 10 35 43 50 17 50 7 39 15 20 12 39 32 32 0 13 5 39 17 18 43 28

Index

ASP HTML Download            FAQ

ASP.NET Version

Okay so maybe it's technically a histogram, but whatever it is, this sample is an easy way to produce a useful graphical representation from a boring list of numbers. You can get these numbers from wherever you want, but it expects them to be in an array and simply won't tolerate it if they're not! It will even do labels for each bar, but this is limited since it can only handle them nicely with a very small set of data and even then you need very short labels!

To disable the labels, like in the second graph, just pass the Sub a non-array parameter for the labels array. It'll ignore anything that's not an array. If you do want to use the labels, remember to pass the right number of labels for your data. Too many shouldn't cause anything to break (except that your labels might not be attached to the right data if an extra value got inserted somewhere) but too few will definitely cause it to complain loudly!

Oh and one other thing... don't start passing it negative numbers unless you want to modify it to accept them! Use it for hit counts or number of sales or something like that. Browsers don't stretch images well when you give them negative numbers!

Update: So you want to graph negative numbers huh?

When I wrote the code above I neglected to add support for negative numbers. For those who are curious, I originally wrote the code to graph our web site page views for our sales guys and so negative numbers weren't a concern. Well one of our visitors who was feeling generous has donated the code that he wrote to show bar charts that include negative values.

The code in the attached zip file is a little more complex then the code above. I've left it pretty much as it was sent to me. As such there are some include files and functions which may not be used for this sample. Just ignore anything that you don't find useful. The values in the graph come from the included database. The data is just made up numbers I typed in. Oh well enough of my rambling... download the code (19 KB) and give it a look. In terms of giving it a look... here's a small screen shot:

Bar Chart (Negative) Screen Cap
Samples

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Microsoft PDF: Top 10 Reasons to Move to Server Virtualization with Hyper-V
Microsoft PDF: Six Reasons Why Microsoft's Hyper-V Will Overtake Vmware
Microsoft Step-by-Step Guide: Hyper-V and Failover Clustering
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Microsoft PDF: Top 11 Reasons to Upgrade to Windows Server 2008
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
  PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
HP eBook: Guide to Storage Networking
MORE WHITEPAPERS, EBOOKS, AND ARTICLES