The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Fl::Chart - Display Simple Chart Data

Synopsis

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

Description

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

Methods

Fl::Chart is a subclass of Fl::Widget but also supports these methods:

new(...)

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.

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.