Text::BarGraph - Text Bar graph generator


Text-BarGraph documentation  | view source Contained in the Text-BarGraph distribution.

Index


NAME

Top

Text::BarGraph - Text Bar graph generator

SYNOPSIS

Top

  use Text::BarGraph;

  $graph = Text::BarGraph->new();

ABSTRACT

Top

A module to create text bar graphs

DESCRIPTION

Top

This module takes as input a hash, where the keys are labels for bars on a graph and the values are the magnitudes of those bars.

EXAMPLE

Top

  $graph = Text::BarGraph->new();

  %hash = (
    alpha => 30,
    beta  => 40,
    gamma => 25
  );

  print $g->graph(\%hash);

METHODS

Top

new
  $graph = Text::BarGraph->new();

The constructor.

graph
  $graph_text = $graph->graph(\%data);

Return a graph of the data in the supplied hash. The keys in the hash are labels, and the values are the magnitudes.

dot
  $graph->dot('.')

Set the character used in the graph.

Default: #

num
  $graph->num(0);

Whether to display the numerical value of each bar

Default: 1

sortvalue
  $graph->sortvalue("data");

Set what to use to sort the graph. Valid values are "data" and "key". Key sorts by the bar's label, data sorts by the bar's magnitude.

Default: key

sorttype
  $graph->sorttype("string");

Whether to sort bar labels as strings or numerically. Valid values are "string" and "numeric". This option is ignored when sorting by 'data'

Default: string

zero
  $graph->zero(20);

Sets the initial value (far left) of the graph. Ignored if autozero is set. When zero is non-zero, an extra row will be printed to identify the minimum value.

Default: 0

autozero
  $graph->autozero(1);

Automatically choose the initial value (far left) of the graph. Overrides any value set with zero.

Default: 0

max_data
  $graph->max_data(1000);

Forces the end of the graph (right side) to be larger than the maximum value in the graph. If the supplied value is less than the maximum value, it will be ignored.

Default: 0

columns
  $graph->columns(120);

Set the number of columns to use when displaying the graph. This value is ignored if autosize is used.

Default: 80

autosize
  $graph->autosize(0);

Automatically determine the size of the display. Only works if Term::ReadKey is installed and a terminal is detected. Otherwise, the value set by columns is used.

Default: 1

enable_color
  $graph->enable_color(1);

Whether to use ANSI color on the bargraph. Uses Term::ANSIColor if it is present.

Default: 0

AUTHOR

Top

Kirk Baucom <kbaucom@schizoid.com>

COPYRIGHT

Top


Text-BarGraph documentation  | view source Contained in the Text-BarGraph distribution.