Over Axis
Thursday, February 12th, 2009Just finished some new work that I wanted to show.

This is accomplished via the new OverAxis decoration that will be included in the next Clicker release.
Just finished some new work that I wanted to show.

This is accomplished via the new OverAxis decoration that will be included in the next Clicker release.
I’ve been reading Edward Tufte’s Visual Display of Quantitative Information and taking notes as I go. One of the things that stuck out was the use of a “white” grid, where the traditional background grid was rendered by erasing some of the data. Clicker was able to handle this after some small changes and tuning:

Expect more features in the future that stem from Tufte’s work.
Today I released version 1.99_01 to the CPAN. Version 2.0 is substantially different — API wise — from 1.x. I’ll cover a few of the ways here.
Firstly, I removed Chart::Clicker::Simple because the core module is more simple than Simple.pm was. Here’s an example of the new API.
use Chart::Clicker; use Chart::Clicker::Data::Series; use Chart::Clicker::Data::DataSet; use Chart::Clicker::Renderer::Point; my $cc = Chart::Clicker->new; my $series = Chart::Clicker::Data::Series->new( keys => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ], values => [ 42, 25, 86, 23, 2, 19, 103, 12, 54, 9 ], ); my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series ]); $cc->add_to_datasets($ds); $cc->prepare(); $cc->draw(); $cc->write('/Users/gphat/foo.png');
Aside from the à la carte creation of charts, the major complication in Clicker’s API has always been the handling of multiple axes. My solution to this has been the introduction of contexts. A context is a domain axis, a range axis and a renderer. By default there is a single context called ‘default’. All datasets added to a chart are associated with the default context unless you specify otherwise, like so:
$dataset->context('sales');
You can create new contexts easily.
my $ctx = Chart::Clicker::Context->new( name => 'sales', renderer => Chart::Clicker::Renderer::Area->new ); $clicker->add_to_contexts($ctx);
Each context will be charted on unique axes and with whatever renderer it is set to. The upcoming cookbook will details advanced ways to change this behavior, but the default will over most people’s use cases.
Clicker previously required you to ‘add’ all the components of the chart manually. No longer! In removing Simple.pm I had Clicker simply add a set of default components. I’ll be working on a Cookbook for various customizations soon.
The first major contribution to the 2.0 codebase was a patch from Ash Berlin that used Cairo’s clipping to replace the multiple-surface method that I had been using the past.
During YAPC::NA I added PDF and PostScript support and had a discussions with Guillermo and Stevan that pushed me to create a new stack underneath Clicker to facilitate some future features. I detailed these modules in a post on my personal blog.
In addition to the above Clicker is now Moose through-and-through, making extensive use of MooseX::AttributeHelpers.
I intend to release 2.0 soon, but there are still a few small bugs and missing features I want to complete. I also want to get started on the aforementioned Cookbook so that users can easily find out how to do advanced rendering. Stay tuned!
As a test tonight I generated new example images for the examples page. I found quite a few bugs to fix and ultimately generated some nice examples to drool over.
I’ve mentioned all the cool stuff in posts already, but here’s the list:
The Bar renderer has always been the red-headed stepchild of Clicker, but lately I’ve been paying it a lot more attention. Tonight I’ve added the ability to set the baseline of an Axis (at say, 0) so that Renderers can choose to display values differently if they fall above or below the baseline. Here’s the results for the Bar renderer:

I need to update the StackedBar renderer and get the axes ticks to take the baseline into effect before I can release the feature.
Some fixes came out of my time at PPW over the weekend. I also finally figured out how to do ‘real’ svg output!
In the pending release:

It wasn’t so hard once I realized I was calling cairo’s rectangle function all wrong…
A flurry of releases have brought us to 1.2.2. The single largest change has been the conversion to Moose. What originally began as an excuse to play with Moose turned into a desire to convert the whole of Clicker. Thanks to Stevan and friends for a great package.
The other exciting feature is the addition of a Pie renderer:

1.2.2 fixed a few bugs that reared there heads after the Moose change. I’ve got a few changes that will give me a 1.2.3 in the near future.
Happy Charting!
It’s been a long time. I shouldn’t of left you. Without some dope code to chart to.
I skipped a couple of releases here, so we’ll cover them first.
* Version 1.1.6 removed some Mac OS X files from the tarball.
* Version 1.1.7 added a time_zone to Axis::DateTime via help from Johannes Hoerburger.
Version 1.1.8 began with a small bugfix from Johannes again, fixing a misnamed accessor. The hacking bug got me an in addition to that fix I made some speed improvments and added Shape support to the Line renderer.

I’ve just uploaded it to CPAN, happy charting!