Hi,

I worked out cylinder support for GD::Graph a while ago. while it
requires some patches to modules provided by GD::Graph3d, which seems
not being maintained for a while. any suggestion about how i could
publish the cylinder module for people who need it?

Cheers,
CLK
--- Begin Message ---
hi Jeremy,

attached are patch to make the bars3d module friendly to the
rotate_chart option, and the module for drawing cylinder charts.

also the lines3d module around line 415 does not have boundary
condition checking and may cause divide by zero. i haven't got time to
fix it and just comment them out.

maybe things should eventually consolidate to the GD::Graph module
when the 3d option is enabled.

Cheers,
CLK
--- /usr/local/lib/perl5/site_perl/5.6.1/GD/Graph/bars3d.pm     Fri Dec  7 07:45:08 
2001
+++ bars3d.pm   Tue Aug 13 19:42:28 2002
@@ -89,18 +89,20 @@
        my $zero = $self->{zeropoint};
 
        my $i;
-       for $i (0 .. $self->{_data}->num_points()) {
+       my @iterate =  (0 .. $self->{_data}->num_points());
+       for $i ($self->{rotate_chart} ? reverse(@iterate) : @iterate) {
                my ($xp, $t);
                my $overwrite = 0;
                $overwrite = $self->{overwrite} if defined $self->{overwrite};
                
                my $j;
-               for $j (1 .. $self->{_data}->num_sets()) {
+               my @iterate = (1 .. $self->{_data}->num_sets());
+               for $j (($self->{rotate_chart} && $self->{cumulate} == 0) ? 
+reverse(@iterate) : @iterate) {
                        my $value = $self->{_data}->get_y( $j, $i );
                        next unless defined $value;
 
                        my $bottom = $self->_get_bottom($j, $i);
-                               $value = $self->{_data}->get_y_cumulative($j, $i)
+                       $value = $self->{_data}->get_y_cumulative($j, $i)
                                if ($self->{cumulate});
 
                        # Pick a data colour, calc shading colors too, if requested
@@ -128,7 +130,6 @@
 
                        # get coordinates of top and center of bar
                        ($xp, $t) = $self->val_to_pixel($i + 1, $value, $j);
-
                        # calculate offsets of this bar
                        my $x_offset = 0;
                        my $y_offset = 0;
@@ -141,23 +142,45 @@
 
                        # calculate left and right of bar
                        my ($l, $r);
+                       if ($self->{rotate_chart}) {
+                           $l = $bottom;
+                           ($r) = $self->val_to_pixel($i + 1, $value, $j);
+                       }
+
                        if( (ref $self eq 'GD::Graph::mixed') || ($overwrite >= 1) )
                        {
+                           if ($self->{rotate_chart}) {
+                               $bottom = $t + $self->{x_step}/2 - $bar_s + $x_offset;
+                               $t = $t - $self->{x_step}/2 + $bar_s + $x_offset;
+                           }
+                           else {
                                $l = $xp - $self->{x_step}/2 + $bar_s + $x_offset;
                                $r = $xp + $self->{x_step}/2 - $bar_s + $x_offset;
+                           }
                        }
                        else
                        {
+                           if ($self->{rotate_chart}) {
+                               warn "base is $t";
+                               $bottom = $t - $self->{x_step}/2
+                                   + ($j) * $self->{x_step}/$self->{_data}->num_sets()
+                                       + $bar_s + $x_offset;
+                               $t = $t - $self->{x_step}/2
+                                   + ($j-1) * 
+$self->{x_step}/$self->{_data}->num_sets()
+                                       - $bar_s + $x_offset;
+                               warn "top bottom is ($t, $bottom)";
+                           }
+                           else {
                                $l = $xp 
-                                       - $self->{x_step}/2
+                                   - $self->{x_step}/2
                                        + ($j - 1) * 
$self->{x_step}/$self->{_data}->num_sets()
-                                       + $bar_s + $x_offset;
+                                           + $bar_s + $x_offset;
                                $r = $xp 
-                                       - $self->{x_step}/2
+                                   - $self->{x_step}/2
                                        + $j * 
$self->{x_step}/$self->{_data}->num_sets()
-                                       - $bar_s + $x_offset;
+                                           - $bar_s + $x_offset;
+                           }
                        }
-
                        if ($value >= 0) {
                                # draw the positive bar
                                $self->draw_bar( $g, $l, $t, $r, $bottom-$y_offset, 
$dsci, $brci, 0 )

Attachment: cylinder.pm
Description: Perl program

Attachment: msg12258/pgp00000.pgp
Description: PGP signature

--- End Message ---

Attachment: msg12258/pgp00001.pgp
Description: PGP signature

Reply via email to