Fl::Chart - Display Simple Chart Data
use Fl qw[:color]; my $win = Fl::Window->new(1000, 480); my $chart = Fl::Chart->new(20, 20, $win->w() - 40, $win->h() - 40, 'Chart'); $chart->bounds(-125, 125); for (my $t = 0; $t < 15; $t += 0.5) { my $val = sin($t) * 125.0; $chart->add($val, sprintf('%-.1f', $val), ($val < 0) ? FL_RED : FL_GREEN); } $win->resizable($win); $win->show(); exit Fl::run();
Fl::Chart can display data in one of several formats. The following are imported from Fl with the :chart tag.
:chart
Fl::Chart is a subclass of Fl::Widget but also supports these methods:
The constructor creates a chart of a given size and position on screen or within the parent.
my $chart_a = Fl::Chart->new(100, 150, 300, 500);
...or...
my $chart_b = Fl::Chart->new(100, 150, 300, 500, 'Daily Volume');
In these examples, the new chart is placed 100 pixels from the left and 150 pixels down from the top of either the display area or parent widget.
The default boxtyle is FL_NO_BOX.
FL_NO_BOX
The destructor also deletes all data.
add(...)
$chart->add(60, 'March 13, 2016', FL_RED); $chart->add(64.3);
Add the data value with optional label and color to the chart.
autosize(...)
$chart->autosize(1); my $resizing = $chart->autosize();
Get whether the chart will automatically adjust bounds of the chart. Returns non-zero if the chart will automatically resize.
To install Fl, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Fl
CPAN shell
perl -MCPAN -e shell install Fl
For more information on module installation, please visit the detailed CPAN module installation guide.