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.
Set the base style background/foreground to determine the graph colours. Note that reverse video and bold don't work very well on some terminals, since the background+foreground colours won't match.
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.
Given a width $w, resamples the data (remaining list of parameters) to fit, using the current "resample_method".
Rendering implementation. Uses "graph_steps" as the base character set.
Returns the character code corresponding to the given data value.
Returns the maximum value seen so far, used for autoscaling.
Change method for resampling when we have more data than will fit on the graph.
Current values include:
The default is 'average'.
Returns $self if setting a value, or the current value.
get_style_pen, get_style_text, get_style_values, key_focus_next_after, key_focus_next_before, on_pen_changed, parent, pen, redraw, requested_cols, requested_lines, requested_size, reshape, resized, set_parent, set_pen, set_requested_size, set_style, set_style_tag, set_window, style_classes, take_focus, window, window_gained, window_lost
Tom Molesworth <firstname.lastname@example.org>
Copyright Tom Molesworth 2011-2014. Licensed under the same terms as Perl itself.