=head1 NAME Term::Chart - Create attractive horizontal bar charts for the terminal interface. =head1 SYNOPSIS use Term::Chart; my $tc = Term::Chart->new(); for my $number ( 1 .. 10 ) { $tc->add_value( { value => $number } ); } $tc->print(), "\n"; =head3 HTML approximation of the output =begin html

═▸
═══▸
═════▸
════════▸
══════════▸
════════════▸
═══════════════▸
═════════════════▸
═══════════════════▸
══════════════════════▸
=end html =head1 SOMETHING ELABORATE use Term::Chart; my $tc = Term::Chart->new( { default_style => 11, color_range => [ 160 .. 195 ], } ); for ( 1 .. 10 ) { for my $n (qw( 1 2 3 4 5 6 5 4 3 2 )) { my %datum = ( value => $n, label => ( 'label ' . $n x $n ), ); $tc->add_value( \%datum ); } } $tc->print(), "\n"; =head3 HTML approximation of the output =begin html
         label :
        label 1:
       label 22:
      label 333:
     label 4444:
    label 55555:
   label 666666:
  label 7777777:
 label 88888888:
label 999999999:
=end html =head1 DESCRIPTION This module offers you a convenient way to create horizontal bar charts for your command line programs. The charts can include ANSI color markup and Unicode drawing characters. The characters used and the presence of ANSI color codes is configurable. =head1 METHODS =head2 new The constructor accepts a hash ref with two optional parameters. =over =item color_range Use this to offer a range of color values which will be used accross each horiontal bar. =item default_style This controls which characters are used to create the bars in your bar chart. Accepts an integer which is among: =over =item * '0' =begin html ═▸ =end html =item * '1' =begin html ═▹ =end html =item * '2' =begin html ═► =end html =item * '3' =begin html ═▻ =end html =item * '4' =begin html ◻▷ =end html =item * '5' =begin html ◻◻ =end html =item * '6' =begin html ◼▶ =end html =item * '7' =begin html ◼◗ =end html =item * '8' =begin html ◼◼ =end html =item * '9' =begin html ═◆ =end html =item * '10' =begin html ═◇ =end html =item * '11' =begin html ═● =end html =item * '12' =begin html ═○ =end html =back =back =head2 add_value Add a value to be graphed. Accepts a hash ref with: =over =item label Optional label will be rendered to the left of each bar. =item value The numeric value being graphed. =item color Optional ANSI foreground color. This will override any colors given in the color_range constructor parameter. =item bg_color Optional ANSI background color. =item char The character to use for the bar. This will override the character related to the style indicated in the default_style constructor parameter. =item last_char The last (right most) character of each bar can be different from the rest of the bar. This will override the last character related to the style indicated in the default_style constructor parameter. =back =head2 render This constructs the bar chart as a blob of text and returns it. =head2 print This will print the rendered chart to STDOUT. =head1 TODO Consider a vertical bar chart, and perhaps a crude pie chart? =head1 AUTHOR Dylan Doxey, Edylan@cpan.orgE =head1 COPYRIGHT AND LICENSE Copyright (C) 2012 by Dylan Doxey This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.2 or, at your option, any later version of Perl 5 you may have available. =cut