Tickit::Widget::SparkLine - minimal graph implementation for Tickit
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);
Generates a mini ("sparkline") graph.
Instantiate the widget. Takes the following named parameters:
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.
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.
Helper method to add one or more items to the end of the list.
Helper method to remove one item from the end of the list, returns the item.
my $item = $widget->pop;
Helper method to remove one item from the start of the list, returns the item.
my $item = $widget->shift;
Helper method to add items to the start of the list. Takes a list.
$widget->unshift(0, 1, 3);
Equivalent to the standard Perl splice function.
# Insert 3,4,5 at position 2 $widget->splice(2, 0, 3, 4, 5);
Returns an arrayref of characters in order of magnitude.
[ ' ', 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.
Rendering implementation. Uses "graph_steps" as the base character set.
Returns the character corresponding to the given data value.
Tom Molesworth <email@example.com>
Same license and copyright as Tickit.