W3Counter 4.0: HTML & CSS Bar Charts
I was at an early Christmas party with family most of the day so only accomplished one thing: bar charts. I’d like to finish this first report screen before moving on, as a lot of what I write will be reused, and it desperately needed a graph of some sort.
I went with the bar chart, as the original W3Counter provided for its daily overview. The current version uses a line chart that I’ve come to find doesn’t convey the trends as well as simple bars.
Rather than generate an image with the GD library, or using a Flash chart (which would mean paying royalties on every copy sold as all the decent-looking Flash chart components are commercial), I wrote an HTML-and-CSS chart class inspired by Feedburner’s subscriber count charts. You can see the results in the screenshots.
I tried to keep it flexible enough to be reused should I want to somewhere else (it takes width and height as parameters, and every bar has a set of properties including label, value, text to show in the bar, an array of options that get transformed into properties of the HTML tag representing the bar for adding classes or styles, etc).
I’m going to refactor the code a bit to clean up the rough spots and possibly share the class here should anyone else want to use it.
My next step will be refactoring the code for this screen since it’s become a bit messy changing the arrangement a few times and adding the chart. After that I’ll be putting together the tracking javascript so I can start collecting live data to use developing the rest of the reports.


