File: ex1.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 (30 lines) | stat: -rw-r--r-- 958 bytes parent folder | download | duplicates (8)
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
#!/usr/local/bin/perl
# -*- perl -*-

use Chart::Strip;
my $img = Chart::Strip->new(title   => 'Happiness of Club Members',
			    x_label => 'When',
			    y_label => 'Happiness Factor',
			    );

my( $t, $davey, $shelly, $harold );
my $dt = 3600;

for($t=$^T; $t<$^T+$dt; $t+=$dt/200){
    my $v = 10 + rand(5);
    push @$davey, {time => $t, value => $v};
}
for($t=$^T; $t<$^T+$dt; $t+=$dt/50){
    my $v = 9 + rand(5);
    my $x = 5 + rand(2);
    push @$harold, {time => $t, value => $v};
    push @$shelly, {time => $t, value => $x, min => $x - 1, max => $x + 1 + rand(1) };
}

$img->add_data( $davey,  { label => 'Davey',  style => 'filled', color => '8080FF' } );
$img->add_data( $shelly, { label => 'Shelly', style => 'range',  color => '008844' } );
$img->add_data( $shelly, {                    style => 'line',   color => '44CC44' } );
$img->add_data( $harold, { label => 'Harold', style => 'line',   color => '802000' } );

print $img->png();