NAME

StatusBoard::Graph - create JSON with graph data for Status Board iPad App

VERSION

version 1.0.1

SYNOPSIS

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.

DESCRIPTION

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.

METHODS

new

This a constuctor. It creates StatusBoard::Graph object. It don't need any parameters.

my $sg = StatusBoard::Graph->new();

get_json

Method generate and return JSON with Graph data that Status Board App can use.

my $json = $sg->get_json();

get_pretty_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();

write_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);

set_title

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");

has_title

Methods checks if the StatusBoard::Graph object has title (It has if the method set_title has been executed).

get_title

Returns the title of StatusBoard::Graph object or dies if there is no title.

set_type

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");

has_type

Returns bool value if the type is set.

get_type

Returns the Graph type or dies if the type is not set.

add_data_seq

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);

set_min_y_value

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');

has_min_y_value

Returns bool value if the minimum Y-axis value is set.

get_min_y_value

Returns the mimimum Y-axis value or dies if it is not set.

set_max_y_value

You can specify the Y-axis to end at a particular value.

$sg->set_max_y_value('84');

has_max_y_value

Returns bool value if the maximum Y-axis value is set.

get_max_y_value

Returns the maximum Y-axis value or dies if it is not set.

TODO

Several move things should be implemented.

  • refreshEveryNSeconds

  • total

  • units

  • Hiding Axis Labels

  • showEveryLabel

  • Error Reporting

  • set_type() should recieve only "bar" or "line"

AUTHOR

Ivan Bessarabov <ivan@bessarabov.ru>

COPYRIGHT AND LICENSE

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.