ASP 101 - Active Server Pages 101 - Web03
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 
3 20 6 11 39 29 49 35 26 1 37 22 26 25 6 0 38 17 11 7 23 7 16 32 43 29 21 15 3 29 40 13 15 39 36 20 21 50 31 12 25 15 21 43 41 3 4 9 8 19

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



JupiterOnlineMedia

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

Solutions
Whitepapers and eBooks
IBM eBook: Planning a Service Oriented Architecture
IBM eBook: Choosing the Right Architecture--What It Means for You and Your Business
Microsoft Article: Will Hyper-V Make VMware This Decade's Netscape?
Avaya Article: Using Intelligent Presence to Create Smarter Business Applications
Intel Go Parallel Article: Getting Started with TBB on Windows
Microsoft Article: 7.0, Microsoft's Lucky Version?
Avaya Article: How to Feed Data into the Avaya Event Processor
IBM Article: Developing a Software Policy for Your Organization
Microsoft Article: Managing Virtual Machines with Microsoft System Center
Intel Go Parallel Article: Intel Threading Tools and OpenMP
HP eBook: Storage Networking , Part 1
Microsoft Article: Solving Data Center Complexity with Microsoft System Center Configuration Manager 2007
MORE WHITEPAPERS, EBOOKS, AND ARTICLES
Webcasts
HP Video: StorageWorks EVA4400 and Oracle
HP Webcast: Storage Is Changing Fast - Be Ready or Be Left Behind
Microsoft Silverlight Video: Creating Fading Controls with Expression Design and Expression Blend 2
MORE WEBCASTS, PODCASTS, AND VIDEOS
Downloads and eKits
Red Gate Download: SQL Toolbelt and free High-Performance SQL Code eBook
Iron Speed Designer Application Generator
MORE DOWNLOADS, EKITS, AND FREE TRIALS
Tutorials and Demos
Silverlight 2 App and Walkthrough: Leverage Silverlight 2 with SQL Server and XML
IBM Article: Enterprise Search--Do You Know What's Out There?
HP Demo: StorageWorks EVA4400
Microsoft Article: The Progress and Promise of Deep Zoom
Microsoft How-to Article: Get Going with Silverlight and Windows Live
MORE TUTORIALS, DEMOS AND STEP-BY-STEP GUIDES