Subject: | Pie 3d chart shape changes depending on size of legend |
Date: | Thu, 14 Aug 2008 22:00:37 +0200 (CEST) |
To: | bug-GD-Graph3d [...] rt.cpan.org |
From: | Wolfgang.Friebel [...] desy.de |
This applies to GD::Graph::pie3d version 0.63
(should be independent of perl version and OS used)
When producing pie charts with legends added at the bottom of the
chart then the shape of the chart is dependent on the space the legend
is occupying. For a single chart this may be adjusted by changing the
size of the picture. If several pie charts have to be presented in
parallel, it just looks ugly if one chart is almost a circle (1 entry in
the legend) and another one a flat disk (many entries in the legend).
With the very primitive patch (attached) the problem can be cured:
If the attribute lg_cols can be adjusted from the calling program
then it is possible to reserve a fixed number of rows for the legend
with the effect that the shape of the chart stays the same.
This can be seen by the following demo. Using the long names for
the days changes the shape of the chart in the unmodified version.
With the patched pie3d always two rows are reserved for the legend.
use GD::Graph::pie3d;
my @data = (
["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
[ 1203, 3500, 3973, 2859, 3012, 3423, 1230]
);
my $graph = new GD::Graph::pie3d( 400, 400 );
$graph->set_legend (@{$data[0]});
$graph->set_legend_font(GD::gdSmallFont);
$graph->set(
x_label => 'Day of the week',
y_label => 'Number of hits',
suppress_angle => 360,
lg_rows => 2, # <----
transparent => 0,
dclrs => [ qw(lred lgreen lblue lyellow lpurple cyan
lorange) ],
title => 'Daily Summary of Web Site',
);
my $gd = $graph->plot( \@data );
print $gd->png;
--
Wolfgang Friebel Deutsches Elektronen-Synchrotron DESY
Phone/Fax: +49 33762 77372/216 Platanenallee 6
Mail: Wolfgang.Friebel AT desy.de D-15738 Zeuthen Germany
Message body is not shown because sender requested not to inline it.