File: ex5.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 (56 lines) | stat: -rw-r--r-- 1,082 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/local/bin/perl
# -*- perl -*-

use Chart::Strip;

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

my( @d1, @d2, @d3 );

for(my $t=10; $t<50; $t++){
    my $v = 3 * sin( $t/10 ) ;
    
    push @d1, {
	time  => $^T + $t * 15000,
	value => 3 * sin( $t/10 ) + $t / 50 + 1,
    };
    push @d2, {
	time  => $^T + $t * 15000,
	value => 2 * sin( $t/8 ) + sin($t/4) + sin($t/2)/2 + 3,
	width => 3000 + 2500 * sin( $t / 7 ), # wacky-width
    };
    push @d3, {
	time  => $^T + $t * 15000,
	value => ($t/5)%2 ? 2 * cos($t/10) + rand() + 4 : undef,
    };

}

# box-graph auto-width, not-filled
$img->add_data( \@d1, {
    style => 'box',
    label => 'Successful',
    color => 'FF0000',
} );

# filled, varying width
$img->add_data( \@d2, {
    style  => 'box',
    label  => 'Lost in Mail',
    color  => '0000FF',
    filled => 1,
} );

# thick line, with gaps
$img->add_data( \@d3, {
    style => 'line',
    label => 'Processed',
    color => '448822',
    thickness => 4,
    skip_undefined => 1,
} );


print $img->png();