File Coverage

samples/sample95.pl
Criterion Covered Total %
statement 4 6 66.6
branch n/a
condition n/a
subroutine 2 2 100.0
pod n/a
total 6 8 75.0


line stmt bran cond sub pod time code
1 1     1   1673 use strict;
  1         2  
  1         31  
2 1     1   26 use GD::Graph::bars;
  0            
  0            
3             use GD::Graph::hbars;
4             use GD::Graph::Data;
5             require 'save.pl';
6              
7             $GD::Graph::Error::Debug = 5;
8              
9             my $data = GD::Graph::Data->new(
10             [
11             ["1st","2nd","3rd","4th","5th","6th","7th", "8th", "9th"],
12             [ 5, 12, 24, 33, 19, 8, 6, 15, 21],
13             [ 1, 2, 5, 6, 3, 1.5, 1, 3, 4],
14             [ 2, 4, 4.5, 5, 2.5, 0.5, 1, 2, 3],
15             ]
16             ) or die GD::Graph::Data->error;
17              
18             my $values = $data->copy();
19             $values->set_y(1, 7, undef) or warn $data->error;
20             $values->set_y(2, 7, undef) or warn $data->error;
21             $values->set_y(3, 7, undef) or warn $data->error;
22              
23             my @names = qw/sample95 sample95-h/;
24              
25             my $path = $ENV{GDGRAPH_SAMPLES_PATH} ? $ENV{GDGRAPH_SAMPLES_PATH} : '';
26              
27             for my $my_graph (GD::Graph::bars->new(600,400),
28             GD::Graph::hbars->new(600,400))
29             {
30             my $name = shift @names;
31             print STDERR "Processing $name\n";
32              
33             $my_graph->set(
34             x_label => 'x label',
35             y1_label => 'y1 label',
36             y2_label => 'y2 label',
37             title => 'Using two axes with three datasets',
38             y1_max_value => 40,
39             y2_max_value => 8,
40             y_tick_number => 8,
41             y_label_skip => 2,
42             long_ticks => 1,
43             two_axes => 1,
44             use_axis => [1, 2, 2],
45             legend_placement => 'RT',
46             x_label_position => 1/2,
47              
48             bgclr => 'white',
49             fgclr => 'white',
50             boxclr => 'dblue',
51             accentclr => 'dblue',
52             valuesclr => '#ffff77',
53             dclrs => [qw(lgreen lred lred)],
54              
55             bar_spacing => 1,
56              
57             logo => "${path}logo." . GD::Graph->export_format,
58             logo_position => 'BR',
59              
60             transparent => 0,
61              
62             l_margin => 10,
63             b_margin => 10,
64             r_margin => 10,
65             t_margin => 10,
66              
67             show_values => 1,
68             values_format => "%4.1f",
69              
70             ) or warn $my_graph->error;
71              
72             if ($name =~ /-h$/)
73             {
74             $my_graph->set(x_labels_vertical => 0, values_vertical => 0);
75             $my_graph->set_legend('bottom axis', 'top axis');
76             }
77             else
78             {
79             $my_graph->set(x_labels_vertical => 1, values_vertical => 1);
80             $my_graph->set_legend('left axis', 'right axis');
81             }
82              
83             my $font_spec = "../Dustismo_Sans";
84              
85             $my_graph->set_y_label_font($font_spec, 12);
86             $my_graph->set_x_label_font($font_spec, 12);
87             $my_graph->set_y_axis_font($font_spec, 10);
88             $my_graph->set_x_axis_font($font_spec, 10);
89             $my_graph->set_title_font($font_spec, 18);
90             $my_graph->set_legend_font($font_spec, 8);
91             $my_graph->set_values_font($font_spec, 8);
92              
93             $my_graph->plot($data) or die $my_graph->error;
94             save_chart($my_graph, $name);
95             }
96              
97             1;