NAME Text::Chart - Generate text-based chart VERSION This document describes version 0.01 of Text::Chart (from Perl distribution Text-Chart), released on 2014-08-16. SYNOPSIS use Text::Chart qw(gen_text_chart); Bar chart: my $res = gen_text_chart( data => [1, 5, 3, 9, 2], type => 'bar', ); will produce this: * ***** *** ********* ** Adding data labels and showing data values: my $res = gen_text_chart( data => [["Andi",1], ["Budi",5], ["Cinta",3], ["Dewi",9], ["Edi",2]], type => 'bar', show_data_label => 1, show_data_value => 1, ); Result: Andi |* (1) Budi |***** (5) Cinta|*** (3) Dewi |********* (9) Edi |** (2) "Column chart:" my $res = gen_text_chart( data => [["Andi",1], ["Budi",5], ["Cinta",3], ["Dewi",9], ["Edi",2]], type => 'column', show_data_label => 1, ); Result: * * * * * * * * * * * * * * * * * * * * * * Andi Budi Cinta Dewi Edi "Sparkline chart:" my $res = gen_text_chart( data => [["Andi",1], ["Budi",5], ["Cinta",3], ["Dewi",9], ["Edi",2]], type => 'column', show_data_label => 1, ); my $res = gen_text_chart( data => [1.5, 0.5, 3.5, 2.5, 5.5, 4.5, 7.5, 6.5], type => 'sparkline', ); Result: XXX "Plotting multiple data columns:" XXX DESCRIPTION THIS IS AN EARLY RELEASE, MANY FEATURES ARE NOT YET IMPLEMENTED. Currently only sparkline chart is implemented. Showing data labels and data values are not yet implemented. This module lets you generate text-based charts. FUNCTIONS gen_text_chart(%args) -> str Generate text-based chart. Arguments ('*' denotes required arguments): * chart_height => *float* * chart_width => *float* * data* => *array* (Table) data to chart. Either in the form of array of numbers, example: [1366,1248,319,252] or an array of arrays (there must be at least one number columns), example: [["China",1366],["India",1248],["United Status",319], ["Indonesia",252]] or an array of hashes (there must be at least one key which consistently contain numbers), example: [{country=>"China" , population=>1366}, {country=>"India" , population=>1248}, {country=>"United Status", population=> 319}, {country=>"Indonesia" , population=> 252}] All data needs to be in table form (where there are notions of rows and columns/fields). Array data is assumed to be a single-column table with the column named "data". Array of arrays will have columns named "column0", "column1" and so on. Array of hashes will have columns named according to the hash keys. * data_column => *array|str* Which column(s) contain data to plot. Multiple data columns are supported. * label_column => *str* Which column contains data labels. If not specified, the first non-numeric column will be selected. * spec => *hash* Table specification, according to TableDef. * type* => *str* Chart type. Return value: (str) FAQ Why am I getting 'Wide character in print/say' warning? You are probably printing Unicode characters to STDOUT without doing something like this beforehand: binmode(STDOUT, ":utf8"); TODO * More chart types * Colors * Resampling Reduce data points, for example I have 1000 numbers that I want to display in a 80-column chart or sparkline. * Formatting of data (or label) Using Data::Unixish (like in Text::ANSITable), and specifiable from an environment variable. * Option to switch column/row (like in Excel)? Probably not. I prefer that the data is adjusted instead. SEE ALSO Text::Graph, a mature CPAN module for doing text-based graphs. Before writing Text::Chart I used this module for a while, but ran into the problem of weird generated graphs. In addition, I don't like the way Text::Graph draws things, e.g. a data value of 1 is drawn as zero-width bar, or the label separator ":" is always drawn. So I decided to write an alternative charting module instead. Compared to Text::Graph, here are the things I want to add or do differently as well: functional (non-OO) interface, colors, Unicode, resampling, more chart types like sparkline, animation and some interactivity (perhaps). HOMEPAGE Please visit the project's homepage at . SOURCE Source repository is at . BUGS Please report any bugs or feature requests on the bugtracker website When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. AUTHOR Steven Haryanto COPYRIGHT AND LICENSE This software is copyright (c) 2014 by Steven Haryanto. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.