Tickit::Widget::SparkLine - minimal graph implementation for Tickit
version 0.100
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:
data - graph 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.
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.
$widget->push(3,4,2);
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.
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.
Given a width $w, resamples the data (remaining list of parameters) to fit, using the current "resample_method".
Used internally.
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:
average - takes the average of combined values for this bucket
min - lowest value for this bucket
median - highest value for this bucket
max - largest value for this bucket
peak - alias for 'max'
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, reshape, resized, set_parent, set_pen, set_style, set_style_tag, set_window, style_classes, take_focus, window, window_gained, window_lost
Tom Molesworth <cpan@entitymodel.com>
Same license and copyright as Tickit.
To install Tickit::Widget::SparkLine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tickit::Widget::SparkLine
CPAN shell
perl -MCPAN -e shell install Tickit::Widget::SparkLine
For more information on module installation, please visit the detailed CPAN module installation guide.