view release on metacpan or search on metacpan
# for axes etc), the textcolour, the colour for labels, the colour
# for numbers on the axes, the colour for accents (extra lines, tick
# marks, etc..)
bgclr => 'white', # background colour
fgclr => 'dblue', # Axes and grid
boxclr => undef, # Fill colour for box axes, default: not used
accentclr => 'gray', # bar, area and pie outlines.
labelclr => 'dblue', # labels on axes
axislabelclr => 'dblue', # values on axes
legendclr => 'dblue', # Text for the legend
textclr => 'dblue', # All text, apart from the following 2
valuesclr => 'dblue', # values printed above the points
# data set colours
dclrs => [qw(lred lgreen lblue lyellow lpurple cyan lorange)],
# number of pixels to use as text spacing
text_space => 4,
{
my $self = shift;
$self->{bgci} = $self->set_clr(_rgb($self->{bgclr}));
$self->{fgci} = $self->set_clr(_rgb($self->{fgclr}));
$self->{tci} = $self->set_clr(_rgb($self->{textclr}));
$self->{lci} = $self->set_clr(_rgb($self->{labelclr}));
$self->{alci} = $self->set_clr(_rgb($self->{axislabelclr}));
$self->{acci} = $self->set_clr(_rgb($self->{accentclr}));
$self->{valuesci} = $self->set_clr(_rgb($self->{valuesclr}));
$self->{legendci} = $self->set_clr(_rgb($self->{legendclr}));
$self->{boxci} = $self->set_clr(_rgb($self->{boxclr}))
if $self->{boxclr};
$self->{graph}->transparent($self->{bgci}) if $self->{transparent};
$self->{graph}->interlaced( $self->{interlaced} || undef ); # required by GD.pm
# XXX yuck. This doesn't belong here.. or does it?
$self->put_logo();
return $self;
All colours should have a valid value as described in L<"COLOURS">,
except boxclr, which can be undefined, in which case the box will not be
filled.
=item shadow_depth
Depth of a shadow, positive for right/down shadow, negative for left/up
shadow, 0 for no shadow (default).
Also see the C<shadowclr> and C<bar_spacing> options.
=item labelclr, axislabelclr, legendclr, valuesclr, textclr
Text Colours used for the chart: label (labels for the axes or pie),
axis label (misnomer: values printed along the axes, or on a pie slice),
legend text, shown values text, and all other text.
All colours should have a valid value as described in L<"COLOURS">.
=item dclrs (short for datacolours)
This controls the colours for the bars, lines, markers, or pie slices.
This should be a reference to an array of colour names as defined in
L<GD::Graph::colour> (S<C<perldoc GD::Graph::colour>> for the names available).
$graph->set( dclrs => [ qw(green pink blue cyan) ] );
=item default_type
The type of graph to draw for data sets that either have no type set,
or that have an unknown type set.
Default: lines
=back
=head2 Graph legends (axestype graphs only)
At the moment legend support is minimal.
B<Methods>
=over 4
=item $graph-E<gt>set_legend(I<@legend_keys>);
Sets the keys for the legend. The elements of @legend_keys correspond
to the data sets as provided to I<plot()>.
If a key is I<undef> or an empty string, the legend entry will be skipped.
=item $graph-E<gt>set_legend_font(I<font name>);
Sets the font for the legend text (see L<"FONTS">).
Default: GD::gdTinyFont.
=back
B<Options>
=over 4
=item legend_placement
Where to put the legend. This should be a two letter key of the form:
'B[LCR]|R[TCB]'. The first letter indicates the placement (I<B>ottom or
I<R>ight), and the second letter the alignment (I<L>eft,
I<R>ight, I<C>enter, I<T>op, or I<B>ottom).
Default: 'BC'
If the legend is placed at the bottom, some calculations will be made
to ensure that there is some 'intelligent' wrapping going on. if the
legend is placed at the right, all entries will be placed below each
other.
=item legend_spacing
The number of pixels to place around a legend item, and between a
legend 'marker' and the text.
Default: 4
=item legend_marker_width, legend_marker_height
The width and height of a legend 'marker' in pixels.
Defaults: 12, 8
=item lg_cols
If you, for some reason, need to force the legend at the bottom to
have a specific number of columns, you can use this.
Default: computed
=back
=head2 Options for pie graphs
=over 4
=head1 FONTS
Depending on your version of GD, this accepts both GD builtin fonts or
the name of a TrueType font file. In the case of a TrueType font, you
must specify the font size. See L<GD::Text> for more details and other
things, since all font handling in GD::Graph is delegated to there.
Examples:
$graph->set_title_font('/fonts/arial.ttf', 18);
$graph->set_legend_font(gdTinyFont);
$graph->set_legend_font(
['verdana', 'arial', gdMediumBoldFont], 12)
(The above discussion is based on GD::Text 0.65. Older versions have
more restrictive behaviour).
=head1 HOTSPOTS
I<Note that this is an experimental feature, and its interface may, and
likely will, change in the future. It currently does not work for area
charts or pie charts.>
Graph/axestype.pm view on Meta::CPAN
# XXX The following two need to get better defaults. Maybe computed.
# Draw the zero axis in the graph in case there are negative values
zero_axis => 0,
# Draw the zero axis, but do not draw the bottom axis, in case
# box-axis == 0
# This also moves the x axis labels to the zero axis
zero_axis_only => 0,
# Size of the legend markers
legend_marker_height => 8,
legend_marker_width => 12,
legend_spacing => 4,
legend_placement => 'BC', # '[BR][LCR]'
lg_cols => undef,
# Display the y values above the bar or point in the graph.
show_values => undef,
hide_overlapping_values => 0,
values_vertical => undef, # vertical?
values_space => 4, # extra spacing
values_format => undef, # how to format the value
# Draw the X axis left and the y1 axis at the bottom (y2 at top)
Graph/axestype.pm view on Meta::CPAN
$self->SUPER::initialise();
while (my($key, $val) = each %Defaults)
{ $self->{$key} = $val }
$self->set_x_label_font(GD::gdSmallFont);
$self->set_y_label_font(GD::gdSmallFont);
$self->set_x_axis_font(GD::gdTinyFont);
$self->set_y_axis_font(GD::gdTinyFont);
$self->set_legend_font(GD::gdTinyFont);
$self->set_values_font(GD::gdTinyFont);
}
# PUBLIC
sub plot
{
my $self = shift;
my $data = shift;
$self->check_data($data) or return;
$self->init_graph() or return;
$self->setup_text() or return;
$self->setup_legend();
$self->setup_coords() or return;
$self->draw_text();
unless (defined $self->{no_axes})
{
$self->draw_axes();
$self->draw_ticks() or return;
}
$self->draw_data() or return;
$self->draw_values() or return;
$self->draw_legend();
return $self->{graph}
}
sub set
{
my $self = shift;
my %args = @_;
for (keys %args)
Graph/axestype.pm view on Meta::CPAN
$self->{gdta_x_axis}->set(colour => $self->{alci});
$self->{gdta_y_axis}->set(colour => $self->{alci});
$self->{xafh} = $self->{gdta_x_axis}->get('height');
$self->{yafh} = $self->{gdta_x_axis}->get('height');
$self->{gdta_title}->set(colour => $self->{tci});
$self->{gdta_title}->set_align('top', 'center');
$self->{tfh} = $self->{gdta_title}->get('height');
$self->{gdta_legend}->set(colour => $self->{legendci});
$self->{gdta_legend}->set_align('top', 'left');
$self->{lgfh} = $self->{gdta_legend}->get('height');
$self->{gdta_values}->set(colour => $self->{valuesci});
unless ($self->{rotate_chart})
{
if ($self->{values_vertical})
{
$self->{gdta_values}->set_align('center', 'left');
}
else
{
Graph/axestype.pm view on Meta::CPAN
my $self = shift;
$self->_set_font('gdta_y_axis', @_);
}
sub set_values_font
{
my $self = shift;
$self->_set_font('gdta_values', @_);
}
sub set_legend # List of legend keys
{
my $self = shift;
$self->{legend} = [@_];
}
sub set_legend_font # (font name)
{
my $self = shift;
$self->_set_font('gdta_legend', @_);
}
sub get_hotspot
{
my $self = shift;
my $ds = shift; # Which data set
my $np = shift; # Which data point?
if (defined $np && defined $ds)
{
Graph/axestype.pm view on Meta::CPAN
$self->{bottom} - ($y - $y_min) * $y_step;
return $self->{rotate_chart} ?
(_round($ret_y), _round($ret_x)) :
(_round($ret_x), _round($ret_y));
}
#
# Legend
#
sub setup_legend
{
my $self = shift;
return unless defined $self->{legend};
my $maxlen = 0;
my $num = 0;
# Save some variables
$self->{r_margin_abs} = $self->{r_margin};
$self->{b_margin_abs} = $self->{b_margin};
foreach my $legend (@{$self->{legend}})
{
if (defined($legend) and $legend ne "")
{
$self->{gdta_legend}->set_text($legend);
my $len = $self->{gdta_legend}->get('width');
$maxlen = ($maxlen > $len) ? $maxlen : $len;
$num++;
}
last if $num >= $self->{_data}->num_sets;
}
$self->{lg_num} = $num or return;
# not actually bug 20792 (unsure that this will ever get hit, but if it does..!)
# calculate the height and width of each element
my $legend_height = _max($self->{lgfh}, $self->{legend_marker_height});
$self->{lg_el_width} =
$maxlen + $self->{legend_marker_width} + 3 * $self->{legend_spacing};
$self->{lg_el_height} = $legend_height + 2 * $self->{legend_spacing};
my ($lg_pos, $lg_align) = split(//, $self->{legend_placement});
if ($lg_pos eq 'R')
{
# Always work in one column
$self->{lg_cols} = 1;
$self->{lg_rows} = $num;
# Just for completeness, might use this in later versions
$self->{lg_x_size} = $self->{lg_cols} * $self->{lg_el_width};
$self->{lg_y_size} = $self->{lg_rows} * $self->{lg_el_height};
Graph/axestype.pm view on Meta::CPAN
$self->{lg_xs} = $self->{l_margin};
}
else # default 'C'
{
$self->{lg_xs} =
int($self->{l_margin} + $width/2 - $self->{lg_x_size}/2);
}
}
}
sub draw_legend
{
my $self = shift;
return unless defined $self->{legend};
my $xl = $self->{lg_xs} + $self->{legend_spacing};
my $y = $self->{lg_ys} + $self->{legend_spacing} - 1;
my $i = 0;
my $row = 1;
my $x = $xl; # start position of current element
foreach my $legend (@{$self->{legend}})
{
$i++;
last if $i > $self->{_data}->num_sets;
my $xe = $x; # position within an element
next unless defined($legend) && $legend ne "";
$self->draw_legend_marker($i, $xe, $y);
$xe += $self->{legend_marker_width} + $self->{legend_spacing};
my $ys = int($y + $self->{lg_el_height}/2 - $self->{lgfh}/2);
$self->{gdta_legend}->set_text($legend);
$self->{gdta_legend}->draw($xe, $ys);
$x += $self->{lg_el_width};
if (++$row > $self->{lg_cols})
{
$row = 1;
$y += $self->{lg_el_height};
$x = $xl;
}
}
}
#
# This will be virtual; every sub class should define their own
# if this one doesn't suffice
#
sub draw_legend_marker # data_set_number, x, y
{
my $s = shift;
my $n = shift;
my $x = shift;
my $y = shift;
my $g = $s->{graph};
my $ci = $s->set_clr($s->pick_data_clr($n));
return unless defined $ci;
$y += int($s->{lg_el_height}/2 - $s->{legend_marker_height}/2);
$g->filledRectangle(
$x, $y,
$x + $s->{legend_marker_width}, $y + $s->{legend_marker_height},
$ci
);
$g->rectangle(
$x, $y,
$x + $s->{legend_marker_width}, $y + $s->{legend_marker_height},
$s->{acci}
);
}
"Just another true value";
Graph/lines.pm view on Meta::CPAN
{
my $yslw = $ys + int($lw/2) - $i;
my $yelw = $ye + int($lw/2) - $i;
# Need the setstyle to reset
$self->{graph}->setStyle(@pattern) if (@pattern);
$self->{graph}->line( $xs, $yslw, $xe, $yelw, $style );
}
}
sub draw_legend_marker # (data_set_number, x, y)
{
my $self = shift;
my ($n, $x, $y) = @_;
my $ci = $self->set_clr($self->pick_data_clr($n));
return unless defined $ci;
my $type = $self->pick_line_type($n);
$y += int($self->{lg_el_height}/2);
# Joe Smith <jms@tardis.Tymnet.COM>
local($self->{line_width}) = 2; # Make these show up better
$self->draw_line(
$x, $y,
$x + $self->{legend_marker_width}, $y,
$type, $ci
);
}
"Just another true value";
Graph/linespoints.pm view on Meta::CPAN
# PRIVATE
sub draw_data_set
{
my $self = shift;
$self->GD::Graph::points::draw_data_set(@_) or return;
$self->GD::Graph::lines::draw_data_set(@_);
}
sub draw_legend_marker
{
my $self = shift;
$self->GD::Graph::points::draw_legend_marker(@_);
$self->GD::Graph::lines::draw_legend_marker(@_);
}
"Just another true value";
Graph/mixed.pm view on Meta::CPAN
$rc = eval '$self->GD::Graph::'.
$self->{default_type}.'::draw_data_set(@_)';
}
# If even that fails, we bail out
croak "Set $ds: unknown default type $self->{default_type}" if $@;
return $rc;
}
sub draw_legend_marker
{
my $self = shift;
my $ds = $_[0];
my $type = $self->types($ds);
eval '$self->GD::Graph::'.$type.'::draw_legend_marker(@_)';
eval '$self->GD::Graph::'.
$self->{default_type}.'::draw_legend_marker(@_)' if $@;
}
# undocumented as can be: returns the type-list (with the default
# inserted as appropriate), or the type associated with a particular
# (1-indexed) dataset number (undef if there is no such dataset). The
# range check means that this cannot be called when there is no
# GD::Graph::Data object in $self->{_data}.
sub types
{
Graph/points.pm view on Meta::CPAN
last MARKER;
};
($mtype == 10) && do
{ # vertical line
$self->{graph}->line($xp, $t, $xp, $b, $mclr);
last MARKER;
};
}
}
sub draw_legend_marker
{
my $self = shift;
my $n = shift;
my $x = shift;
my $y = shift;
my $ci = $self->set_clr($self->pick_data_clr($n));
my $old_ms = $self->{marker_size};
my $ms = _min($self->{legend_marker_height}, $self->{legend_marker_width});
($self->{marker_size} > $ms/2) and $self->{marker_size} = $ms/2;
$x += int($self->{legend_marker_width}/2);
$y += int($self->{lg_el_height}/2);
$n = $self->pick_marker($n);
$self->marker($x, $y, $n, $ci);
$self->{marker_size} = $old_ms;
}
"Just another true value";
samples/sample12.pl view on Meta::CPAN
y_tick_number => 8,
y_label_skip => 2,
bar_spacing => 3,
shadow_depth => 4,
accent_treshold => 200,
transparent => 0,
);
$my_graph->set_legend('Data set 1', 'Data set 2');
$my_graph->plot(\@data);
save_chart($my_graph, $name);
}
1;
samples/sample14.pl view on Meta::CPAN
x_label => 'x label',
y1_label => 'y1 label',
y2_label => 'y2 label',
title => 'Using two axes',
y1_max_value => 40,
y2_max_value => 8,
y_tick_number => 8,
y_label_skip => 2,
long_ticks => 1,
two_axes => 1,
legend_placement => 'RT',
x_label_position => 1/2,
bgclr => 'white',
fgclr => 'white',
boxclr => 'dblue',
accentclr => 'dblue',
valuesclr => '#ffff77',
dclrs => [qw(lgreen lred)],
bar_spacing => 1,
samples/sample14.pl view on Meta::CPAN
t_margin => 10,
show_values => 1,
values_format => "%4.1f",
) or warn $my_graph->error;
if ($name =~ /-h$/)
{
$my_graph->set(x_labels_vertical => 0, values_vertical => 0);
$my_graph->set_legend('bottom axis', 'top axis');
}
else
{
$my_graph->set(x_labels_vertical => 1, values_vertical => 1);
$my_graph->set_legend('left axis', 'right axis');
}
my $font_spec = "../Dustismo_Sans";
$my_graph->set_y_label_font($font_spec, 12);
$my_graph->set_x_label_font($font_spec, 12);
$my_graph->set_y_axis_font($font_spec, 10);
$my_graph->set_x_axis_font($font_spec, 10);
$my_graph->set_title_font($font_spec, 18);
$my_graph->set_legend_font($font_spec, 8);
$my_graph->set_values_font($font_spec, 8);
$my_graph->plot($data) or die $my_graph->error;
save_chart($my_graph, $name);
}
1;
samples/sample15.pl view on Meta::CPAN
#y_label_skip => 2,
cumulate => 2,
borderclrs => $my_graph->{dclrs},
#cycle_clrs => 2,
bar_spacing => 4,
#shadow_depth => 4,
transparent => 0,
);
$my_graph->set_legend( qw(offset increment more));
$my_graph->plot(\@data);
save_chart($my_graph, $name);
}
1;
samples/sample16.pl view on Meta::CPAN
x_label => 'Day',
y_label => 'AUD',
title => 'Credits and Debits',
y_max_value => 35,
y_min_value => -15,
y_tick_number => 10,
y_label_skip => 2,
overwrite => 1,
dclrs => [ qw( green lred ) ],
axislabelclr => 'black',
legend_placement => 'RB',
zero_axis_only => 0,
y_number_format => \&y_format,
x_label_position => 1/2,
transparent => 0,
);
$my_graph->set_legend( 'credits', 'debets' );
$my_graph->plot(\@data);
save_chart($my_graph, $name);
}
1;
samples/sample17.pl view on Meta::CPAN
#y_tick_number => 10,
#y_label_skip => 2,
cumulate => 1,
dclrs => [ undef, qw(dgreen green) ],
borderclrs => [ undef, qw(black black) ],
bar_spacing => 4,
transparent => 0,
);
$my_graph->set_legend(undef, qw(low high));
$my_graph->plot(\@data) or die $my_graph->error;
save_chart($my_graph, $name);
}
1;
samples/sample18.pl view on Meta::CPAN
@cls = qw(0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0);
@sld = qw(0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 2 2 3 3 3 4);
# setup x data
push(@data,\@dat); # push x labels into plot data
push(@data,\@sub);
push(@data,\@def);
push(@data,\@rej);
push(@data,\@opn);
push(@data,\@ass); # push x values into plot data
push(@data,\@wrk); # (push order must match legend label order)
push(@data,\@fin);
push(@data,\@ver);
push(@data,\@con);
push(@data,\@tst);
push(@data,\@rev);
push(@data,\@cco);
push(@data,\@cls);
push(@data,\@sld);
# setup legend labels
@legend = qw(
Submitted Deferred Rejected Opened Assigned Work
Finished Verified Configured Tested Reviewed
Closed-CO Closed Sealed
);
my @names = qw/sample18 sample18-h/;
for my $graph (GD::Graph::bars->new(600, 400),
GD::Graph::hbars->new(600, 400))
{
my $name = shift @names;
print STDERR "Processing $name\n";
# set graph legend
$graph->set_legend(@legend);
# set graph options
$graph->set(
'dclrs' => [ qw(lblue lyellow blue yellow lgreen lred
green red purple orange pink dyellow) ],
'title' => "States by Time",
'x_label' => "Time",
'y_label' => "# OF thingies",
'long_ticks' => 1,
'tick_length' => 0,
samples/sample19.pl view on Meta::CPAN
y_label_skip => 2,
#y_number_format => '%d', ### <-- this will override y{1,2}_number_format
y1_number_format => sub { # from perlfaq5
local $_ = shift;
1 while s/^([-+]?\d+)(\d{3})/$1,$2/;
$_;
},
y2_number_format => sub { my $v = shift; sprintf("%.2f",$v/1024) },
long_ticks => 1,
two_axes => 1,
legend_placement => 'RT',
x_label_position => 1/2,
bgclr => 'white',
fgclr => 'white',
boxclr => 'dblue',
accentclr => 'dblue',
valuesclr => '#ffff77',
dclrs => [qw(lgreen lred)],
bar_spacing => 1,
samples/sample19.pl view on Meta::CPAN
t_margin => 10,
show_values => 1,
values_format => "%4.1f",
) or warn $my_graph->error;
if ($name =~ /-h$/)
{
$my_graph->set(x_labels_vertical => 0, values_vertical => 0);
$my_graph->set_legend('bottom axis', 'top axis');
}
else
{
$my_graph->set(x_labels_vertical => 1, values_vertical => 1);
$my_graph->set_legend('left axis', 'right axis');
}
my $font_spec = "../Dustismo_Sans";
$my_graph->set_y_label_font($font_spec, 12);
$my_graph->set_x_label_font($font_spec, 12);
$my_graph->set_y_axis_font($font_spec, 10);
$my_graph->set_x_axis_font($font_spec, 10);
$my_graph->set_title_font($font_spec, 18);
$my_graph->set_legend_font($font_spec, 8);
$my_graph->set_values_font($font_spec, 8);
$my_graph->plot($data) or die $my_graph->error;
save_chart($my_graph, $name);
}
1;
samples/sample1A.pl view on Meta::CPAN
y_tick_number => 8,
y_label_skip => 2,
bar_spacing => 2,
shadow_depth => 3,
bargroup_spacing => 4,
accent_treshold => 200,
transparent => 0,
);
$my_graph->set_legend(qw(Harry Ron Neville Hermione));
$my_graph->plot(\@data);
save_chart($my_graph, $name);
}
1;
samples/sample1B.pl view on Meta::CPAN
[ 1, 1.5, 3, 2, 3, 1.5, 3, 4, 4 ]
);
my @dim = (600,400);
my @names = qw/sample1B sample1B-h/;
for my $graph (GD::Graph::bars->new(@dim),GD::Graph::hbars->new(@dim)) {
my $name = shift @names;
print STDERR "Processing $name\n";
$graph->set_legend('Pass', 'Fail');
$graph->set(
x_label => 'X Label',
y_label => 'Y label',
title => 'Cumulated bar graph with labels',
y_max_value => 10,
y_tick_number => 10,
y_label_skip => 2,
bar_spacing => 8,
cumulate => 'true',
samples/sample21.pl view on Meta::CPAN
x_label => 'X Label',
y_label => 'Y label',
title => 'An Area Graph',
#y_max_value => 40,
#y_tick_number => 8,
#y_label_skip => 2,
#accent_treshold => 41,
transparent => 0,
);
$graph->set_legend( 'one', 'two' );
$graph->plot(\@data);
save_chart($graph, $name);
}
1;
samples/sample22.pl view on Meta::CPAN
$graph->set(
two_axes => 1,
zero_axis => 1,
transparent => 0,
);
$graph->set(rotate_chart => 1) if $name =~ /-h$/;
$graph->set_legend( 'left axis', 'right axis' );
$graph->plot(\@data);
save_chart($graph, $name);
1;
samples/sample23.pl view on Meta::CPAN
@cls = qw(0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0);
@sld = qw(0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 2 2 3 3 3 4);
# setup x data
push(@data,\@dat); # push x labels into plot data
push(@data,\@sub);
push(@data,\@def);
push(@data,\@rej);
push(@data,\@opn);
push(@data,\@ass); # push x values into plot data
push(@data,\@wrk); # (push order must match legend label order)
push(@data,\@fin);
push(@data,\@ver);
push(@data,\@con);
push(@data,\@tst);
push(@data,\@rev);
push(@data,\@cco);
push(@data,\@cls);
push(@data,\@sld);
# setup legend labels
@legend = qw(
Submitted Deferred Rejected Opened Assigned Work
Finished Verified Configured Tested Reviewed
Closed-CO Closed Sealed
);
# get graph object
$graph = GD::Graph::area->new(600, 400);
# set graph legend
$graph->set_legend(@legend);
# set graph options
$graph->set(
'dclrs' => [ qw(lblue lyellow blue yellow lgreen lred
green red purple orange pink dyellow) ],
'title' => "States by Time",
'x_label' => "Time",
'y_label' => "# OF thingies",
'long_ticks' => 1,
'tick_length' => 0,
samples/sample29.pl view on Meta::CPAN
title => 'An Weird Area Graph',
y_max_value => 40,
y_tick_number => 8,
y_label_skip => 2,
dclrs => ['white', 'blue'],
borderclrs => ['white', 'black'],
transparent => 0,
);
$my_graph->set_legend( 'empty', 'data' );
$my_graph->plot(\@data);
save_chart($my_graph, 'sample23');
1;
samples/sample31.pl view on Meta::CPAN
$my_graph = new GD::Graph::points();
$my_graph->set(
x_label => 'X Label',
y_label => 'Y label',
title => 'A Points Graph',
y_max_value => 40,
y_tick_number => 8,
y_label_skip => 2,
legend_placement => 'RC',
long_ticks => 1,
marker_size => 6,
markers => [ 9, 10, 1, 7, 5 ],
transparent => 0,
);
$my_graph->set_legend( qw( one two ) );
$my_graph->plot(\@data);
save_chart($my_graph, 'sample31');
1;
samples/sample41.pl view on Meta::CPAN
y_long_ticks => 1,
x_tick_length => 2,
markers => [ 1, 5 ],
skip_undef => 1,
transparent => 0,
) or warn $my_graph->error;
$my_graph->set_legend( 'data set 1', 'data set 2', 'data set 3' );
$my_graph->plot(\@data);
save_chart($my_graph, 'sample41');
1;
samples/sample42.pl view on Meta::CPAN
y_label => 'Y label',
title => 'A Lines and Points Graph, reading a CSV file',
y_max_value => 80,
y_tick_number => 6,
y_label_skip => 2,
markers => [ 1, 5 ],
transparent => 0,
);
$my_graph->set_legend( 'data set 1', 'data set 2' );
$my_graph->plot(\@data);
save_chart($my_graph, 'sample42');
sub read_data_from_csv
{
my $fn = shift;
my @d = ();
open(ZZZ, $fn) || return ();
samples/sample52.pl view on Meta::CPAN
x_label_position => 1,
y_label_position => 1,
x_label_skip => 3,
#x_last_label_skip => 1,
x_tick_offset => 2,
transparent => 0,
);
$my_graph->set_legend("Us", "Them", "Others");
$my_graph->plot(\@data);
save_chart($my_graph, 'sample52');
1;
samples/sample53.pl view on Meta::CPAN
y_max_value => 10,
y_min_value => -5,
y_tick_number => 3,
y_label_skip => 1,
zero_axis_only => 0,
long_ticks => 1,
x_ticks => 0,
dclrs => [ qw( darkorchid2 mediumvioletred deeppink darkturquoise ) ],
line_types => [ 1, 2, 3, 4 ],
line_type_scale => 8,
legend_marker_width => 24,
line_width => 3,
show_values => 1,
transparent => 0,
) or warn $my_graph->error;
$my_graph->set_legend( 'one', 'two', undef, 'four' );
$my_graph->plot($data) or die $my_graph->error;
save_chart($my_graph, 'sample53');
1;
samples/sample54.pl view on Meta::CPAN
box_axis => 0,
line_width => 2,
x_label_position => 1/2,
r_margin => 15,
x_labels_vertical => 1,
transparent => 0,
);
$my_graph->set_legend('Thanks to Scott Prahl');
$my_graph->plot(\@data);
save_chart($my_graph, 'sample54');
sub read_data
{
my $fn = shift;
my @d = ();
open(ZZZ, $fn) || return ();
samples/sample55.pl view on Meta::CPAN
x_tick_number => 'auto',
y_tick_number => 'auto',
title => 'Sine and Cosine',
line_width => 1,
x_label_position => 1/2,
r_margin => 15,
transparent => 0,
);
$my_graph->set_legend('Thanks to Scott Prahl');
$my_graph->plot(\@data);
save_chart($my_graph, 'sample55');
1;
samples/sample56.pl view on Meta::CPAN
x_tick_offset => 2,
no_axes => 1,
line_width => 2,
x_label_position => 1/2,
r_margin => 15,
transparent => 0,
);
$my_graph->set_legend('Thanks to Scott Prahl and Gary Deschaines');
$my_graph->plot(\@data);
save_chart($my_graph, 'sample56');
sub read_data
{
my $fn = shift;
local(*ZZZ);
my @d = ();
samples/sample57.pl view on Meta::CPAN
print STDERR "Processing $name\n";
$graph->set(
two_axes => 1,
zero_axis => 1,
title => 'Test of two_axes min/max calculation',
transparent => 0,
);
$graph->set_legend( 'left axis', 'right axis' );
$graph->plot(\@data);
save_chart($graph, $name);
1;
samples/sample61.pl view on Meta::CPAN
y_max_value => 10,
y_min_value => -5,
y_tick_number => 3,
y_label_skip => 1,
x_plot_values => 0,
y_plot_values => 0,
long_ticks => 1,
x_ticks => 0,
legend_marker_width => 24,
line_width => 3,
marker_size => 5,
bar_spacing => 8,
transparent => 0,
);
$my_graph->set_legend( qw( one two three four five six ) );
$my_graph->plot(\@data) or die $my_graph->error;
save_chart($my_graph, 'sample61');
1;
samples/sample62.pl view on Meta::CPAN
y1_label => 'Y1 label',
y2_label => 'Y2 label',
title => 'A Mixed Type Graph with Two Axes',
two_axes => 1,
y1_max_value => 10,
y2_max_value => 2.5,
y_min_value => 0,
y_tick_number => 5,
long_ticks => 1,
x_ticks => 0,
legend_marker_width => 24,
line_width => 5,
bar_spacing => 4,
types => [ qw( bars lines ) ],
transparent => 0,
);
$my_graph->set_legend( qw( one two three four five six ) );
$my_graph->plot(\@data);
save_chart($my_graph, 'sample62');
1;