File: ex6.pl

package info (click to toggle)
libchart-strip-perl 1.08-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 216 kB
  • ctags: 39
  • sloc: perl: 1,105; makefile: 6
file content (36 lines) | stat: -rwxr-xr-x 659 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/local/bin/perl
# -*- perl -*-

use Chart::Strip;
use strict;

my $img = Chart::Strip->new(
    title => 'Bee Population',
    data_label_style => 'box',
);

my $data = [];
for(my $t=0; $t<40; $t++){
    my $v = (.15,0,0,-.15,1,0,-.3,0,0,0,.15,.30,.15)[$t % 25] || 0;

    push @$data, {
        time  => $^T + $t * 1000,
        value => $v + .1,
    };
}

# smooth graph with shadow
$img->add_data(
    $data, {
        label     => 'Bees',
        color     => 'FF0000',
        thickness => 2,
        style     => 'line',
        smooth    => 1,
        shadow    => { dx => 3, dy => 3, dw => 2, color => 'ccdddd' },
    }
);


print $img->png();