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;
                    sprintf('%-.1f', $val),
                    ($val < 0) ? FL_RED : FL_GREEN);
    exit Fl::run();


Fl::Chart can display data in one of several formats. The following are imported from Fl with the :chart tag.


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);


    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.

The destructor also deletes all data.


    $chart->add(60, 'March 13, 2016', FL_RED);

Add the data value with optional label and color to the chart.


    my $resizing = $chart->autosize();

Get whether the chart will automatically adjust bounds of the chart. Returns non-zero if the chart will automatically resize.