File: lines_5.t

package info (click to toggle)
libchart-perl 2.4.10ds1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,900 kB
  • ctags: 245
  • sloc: perl: 11,697; makefile: 6
file content (54 lines) | stat: -rw-r--r-- 1,079 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl -w

use Chart::Lines;
print "1..1\n";

$g = Chart::Lines->new( 600, 300 );

@x_values = ();
@y_values = ();
for ( $i = 0 ; $i <= 16 ; $i += 0.05 )
{
    $j  = sin($i);
    $j2 = cos($i);
    push( @x_values,  $i );
    push( @y_values,  $j );
    push( @y2_values, $j2 );
}

$g->add_dataset(@x_values);
$g->add_dataset(@y_values);
$g->add_dataset(@y2_values);

%hash = (
    'title'              => 'The trigonometric functions sinus and cosinus',
    'grid_lines'         => 'true',
    'legend'             => 'left',
    'xy_plot'            => 'true',
    'skip_x_ticks'       => 20,
    'legend_labels'      => [ 'y = sin x', 'y = cos x' ],
    'precision'          => 2,
    'integer_ticks_only' => 'true',

    #'custom_x_ticks' => [0,3],
    'colors' => {
        'title'    => 'plum',
        'dataset0' => 'mauve',
    },
    'f_x_tick' => \&formatter,
);

$g->set(%hash);

$g->png("samples/lines_5.png");

sub formatter
{
    my $d = shift;
    $d = sprintf "%1.2f", $d;
    if ( $d =~ /^0.00/ ) { return 0 }
    return $d;
}
print "ok 1\n";

exit(0);