Monday, September 3, 2012

Hypatia Released!

It took longer than I would've liked--partially due to $work and partially due to other issues--but Hypatia has finally been released!

As explained in a previous post, Hypatia is an API layer that sits between DBI and data visualization modules. For the moment, only Chart::Clicker is supported as a visualization back-end, but work is underway on bindings for GraphViz2.*

There's a examples folder with the distribution of Hypatia::Chart::Clicker, but here's a possible (fictitious) example:
use strict;
use warnings;
use Hypatia;
my $hypatia=Hypatia->new({
 query=>"select DATE(time_of_sale) as date,sum(revenue) as daily_revenue
  from widget_sales
  group by DATE(time_of_sale)"
#grabs data from the query and puts it into a Chart::Clicker line graph
my $cc=$hypatia->chart;
#Since $cc is a Chart::Clicker object, we can now do whatever we want to it.
$cc->title->text("Total Daily Revenue for Widget Sales");

Oh, and in case you're wondering how the module got its name, Hypatia was one of the librarians of the Great Library of Alexandria and one of the first female names in mathematics.

Is it the best code that anyone's ever written? No. Does it have bugs? Quite possibly, although I did release it with some unit tests and tried to eliminate every bug I could find. Of course, bug reports and constructive criticism are more than welcome.

* - Yes, I'm aware that GraphViz2::DBI exists. However, I hope to make an interface that is a bit more "plug-and-play" with not just GraphViz2, but other data visualization modules.


  1. I tested your example script, but on creating CC-object i got:

    Attribute (keys) does not pass the type constraint because: Validation failed for 'ArrayRef[Num]' with value ARRAY(0xae1cae4) at constructor Chart::Clicker::Data::Series::new (defined at /home/wanradt/perl5/lib/perl5/Chart/Clicker/Data/ line 111) line 13.
    Chart::Clicker::Data::Series::new('Chart::Clicker::Data::Series', 'keys', 'ARRAY(0xae1cae4)', 'values', 'ARRAY(0xaebf080)', 'name', 'id_count') called at /home/wanradt/perl5/lib/perl5/Hypatia/Chart/Clicker/ line 78
    Hypatia::Chart::Clicker::XYDataSet::_build_data_set('Hypatia::Chart::Clicker::Line=HASH(0x9168be8)', 'HASH(0x8be4888)') called at /home/wanradt/perl5/lib/perl5/Hypatia/Chart/Clicker/ line 42
    Hypatia::Chart::Clicker::Line::chart('Hypatia::Chart::Clicker::Line=HASH(0x9168be8)') called at /home/wanradt/perl5/lib/perl5/i686-linux-gnu-thread-multi-64int/Moose/Meta/Method/ line 110
    Hypatia::chart('Hypatia=HASH(0x8a28694)') called at line 25

    I did not dig out, where is the problem. Do you have some hint here? TIA, WK

  2. wk,

    Sorry for not getting back to you sooner; I've spent the past few days with the flu.

    By "example script", I presume you're referring to one of the scripts in the examples folder that's part of Hypatia::Chart::Clicker? Which script, in particular, is giving you that error message?

  3. Sorry being a bit vague, i meant the same example you have above. I made trivial changes, but i got errors i posted in first comment. Whole script in pastebin:

    Hope you feel already better, have something hot!

  4. Sorry about the delay. It took me a bit of time to get MySQL set up, but now that It's up and going, I'll whip up a test table with some dummy data and try to recreate the error you mentioned above.

  5. *facepalm* I should've looked at your test snippet more closely; Hypatia currently only supports numeric data for x and y values. Just to make sure, I set up a simple example illustrating a workaround. I know that Chart::Clicker has the ability to use DateTimes for axis values. I'll add that feature to the to-do list.