StatusBoard::Graph - create JSON with graph data for Status Board iPad App
version 1.0.1
use StatusBoard::Graph; use StatusBoard::Graph::DataSeq; my $sg = StatusBoard::Graph->new(); $sg->set_title("Soft Drink Sales"); my $ds1 = StatusBoard::Graph::DataSeq->new(); $ds1->set_title("X-Cola"); $ds1->set_values( [ 2008 => 22, 2009 => 24, 2010 => 25.5, 2011 => 27.9, 2012 => 31, ] ); $sg->add_data_seq($ds1); my $ds2 = StatusBoard::Graph::DataSeq->new(); $ds2->set_title("Y-Cola"); $ds2->set_values( [ 2008 => 18.4, 2009 => 20.1, 2010 => 24.8, 2011 => 26.1, 2012 => 29, ] ); $sg->add_data_seq($ds2); $sg->write_json("cola.json");
Here is the screenshot of how this JSON file looks in the Status Board App.
There is a great iPad App called Status Board http://www.panic.com/statusboard/. It can show differect types of information. One type is a Graph. To create that Graph one can use CSV format, or use more powerfull JSON format.
This module simplifies the process of creation JSONs for Status Board App. Here is the specification of JSON format: http://www.panic.com/statusboard/docs/graph_tutorial.pdf
StatusBoard::Graph version numbers uses Semantic Versioning standart. Please visit http://semver.org/ to find out all about this great thing.
This a constuctor. It creates StatusBoard::Graph object. It don't need any parameters.
my $sg = StatusBoard::Graph->new();
Method generate and return JSON with Graph data that Status Board App can use.
my $json = $sg->get_json();
The same as get_json(), but it returs JSON with identation. This method is not recommened to use in production code, because JSON file with pretty JSON weights more thatn JSON written in one line.
my $json = $sg->get_pretty_json();
Writes JSON with Graph data to file. It writes JSON data that is generated with get_json() method. There is no write_pretty_json() method.
my $file_name = 'population.json'; $sg->write_json($file_name);
Sets title for the Graph. On the same Graph there can be several datasequences. To set the title for for special datasequences use method set_title() in StatusBoard::Graph::DataSeq object.
$sg->set_title("Soft Drink Sales");
Methods checks if the StatusBoard::Graph object has title (It has if the method set_title has been executed).
Returns the title of StatusBoard::Graph object or dies if there is no title.
Sets the type of Graph. In can be "bar" or "line". Setting the type is optional. If the type is not set then the Status Board will choose the type automaticly (depending on the graph size).
$sg->set_type("bar");
Returns bool value if the type is set.
Returns the Graph type or dies if the type is not set.
StatusBoard App can show several different datasequences on the same Graph. To show all that data you need to create StatusBoard::Graph::DataSeq object and to attach it to StatusBoard::Graph object.
my $ds1 = StatusBoard::Graph::DataSeq->new(); $ds1->set_title("X-Cola"); $ds1->set_values( [ 2008 => 22, 2009 => 24, ] ); $sg->add_data_seq($ds1);
StatusBoard gives the ability to scale the Graph. You can specify the Y-axis to start at a particular value.
$sg->set_min_y_value('78');
Returns bool value if the minimum Y-axis value is set.
Returns the mimimum Y-axis value or dies if it is not set.
You can specify the Y-axis to end at a particular value.
$sg->set_max_y_value('84');
Returns bool value if the maximum Y-axis value is set.
Returns the maximum Y-axis value or dies if it is not set.
Several move things should be implemented.
refreshEveryNSeconds
total
units
Hiding Axis Labels
showEveryLabel
Error Reporting
set_type() should recieve only "bar" or "line"
Ivan Bessarabov <ivan@bessarabov.ru>
This software is copyright (c) 2013 by Ivan Bessarabov.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install StatusBoard::Graph, copy and paste the appropriate command in to your terminal.
cpanm
cpanm StatusBoard::Graph
CPAN shell
perl -MCPAN -e shell install StatusBoard::Graph
For more information on module installation, please visit the detailed CPAN module installation guide.