Tom Molesworth > Tickit-Widget-SparkLine-0.002 > Tickit::Widget::SparkLine

Download:
Tickit-Widget-SparkLine-0.002.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.002   Source  

NAME ^

Tickit::Widget::SparkLine - minimal graph implementation for Tickit

VERSION ^

version 0.002

SYNOPSIS ^

 my $vbox = Tickit::Widget::VBox->new;
 my $widget = Tickit::Widget::SparkLine->new(
    data   => [ 0, 3, 2, 5, 1, 6, 0, 7 ]
 );
 $vbox->add($widget, expand => 1);

DESCRIPTION ^

Generates a mini ("sparkline") graph.

METHODS ^

new

Instantiate the widget. Takes the following named parameters:

data

Accessor for stored data.

With no parameters, returns the stored data as a list.

Pass either an array or an arrayref to set the data values and request display refresh.

data_chars

Returns the set of characters corresponding to the current data values. Each value is assigned a single character, so the string length is equal to the number of data items and represents the minimal string capable of representing all current data items.

push

Helper method to add one or more items to the end of the list.

 $widget->push(3,4,2);

pop

Helper method to remove one item from the end of the list, returns the item.

 my $item = $widget->pop;

shift

Helper method to remove one item from the start of the list, returns the item.

 my $item = $widget->shift;

unshift

Helper method to add items to the start of the list. Takes a list.

 $widget->unshift(0, 1, 3);

splice

Equivalent to the standard Perl splice function.

 # Insert 3,4,5 at position 2
 $widget->splice(2, 0, 3, 4, 5);

graph_steps

Returns an arrayref of characters in order of magnitude.

For example:

 [ ' ', qw(_ x X) ]

would yield a granularity of 4 steps.

Override this in subclasses to provide different visualisations - there's no limit to the number of characters you provide in this arrayref.

render

Rendering implementation. Uses "graph_steps" as the base character set.

char_for_value

Returns the character corresponding to the given data value.

AUTHOR ^

Tom Molesworth <cpan@entitymodel.com>

LICENSE ^

Same license and copyright as Tickit.

syntax highlighting: