Skip Menu |

This queue is for tickets about the GDGraph CPAN distribution.

Maintainer(s)' notes

There are plenty of good ideas of what people can do published here on the queue. Turning a patch from the tracker into a pull request is not one of them. In order to get maintainers' attention way more quickier, PR should have at least a sample included. We know it's hard to test images generating software, but it doesn't mean we can not test numbers produced by intermediate algorithms used to generate these images, so either a test or a sample.

Report information
The Basics
Id: 4384
Status: resolved
Priority: 0/
Queue: GDGraph

People
Owner: bwarfield [...] cpan.org
Requestors: slaven [...] rezic.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.43
Fixed in: 1.4305



Subject: [PATCH] undefined x values
Hello Martien, GD::Graph does not handle undefined x values correctly. If an x value is undefined, then the previous label will be rendered in the x axis, but instead nothing should be rendered. This problem is due to a missing defined() test in GD::Graph::axestype. The attached patch fixes the problem. Regards, Slaven
--- /usr/local/dist/cpan/build/GDGraph-1.43/Graph/axestype.pm 2003-07-01 07:04:10.000000000 +0200 +++ Graph/axestype.pm 2003-11-13 16:07:56.000000000 +0100 @@ -1136,19 +1136,23 @@ sub draw_x_ticks_h ($i - $self->{x_tick_offset}) % ($self->{x_label_skip}) and $i != $self->{_data}->num_points - 1; - $self->{gdta_x_axis}->set_text($self->{_data}->get_x($i)); - - my $angle = 0; - if ($self->{x_labels_vertical}) - { - $self->{gdta_x_axis}->set_align('bottom', 'center'); - $angle = PI/2; - } - else - { - $self->{gdta_x_axis}->set_align('center', 'right'); - } - $self->{gdta_x_axis}->draw($x - $self->{axis_space}, $y, $angle); + my $text = $self->{_data}->get_x($i); + if (defined $text) + { + $self->{gdta_x_axis}->set_text($text); + + my $angle = 0; + if ($self->{x_labels_vertical}) + { + $self->{gdta_x_axis}->set_align('bottom', 'center'); + $angle = PI/2; + } + else + { + $self->{gdta_x_axis}->set_align('center', 'right'); + } + $self->{gdta_x_axis}->draw($x - $self->{axis_space}, $y, $angle); + } } return $self; @@ -1189,19 +1193,23 @@ sub draw_x_ticks_v ($i - $self->{x_tick_offset}) % ($self->{x_label_skip}) and $i != $self->{_data}->num_points - 1; - $self->{gdta_x_axis}->set_text($self->{_data}->get_x($i)); - - my $angle = 0; - if ($self->{x_labels_vertical}) - { - $self->{gdta_x_axis}->set_align('center', 'right'); - $angle = PI/2; - } - else - { - $self->{gdta_x_axis}->set_align('top', 'center'); - } - $self->{gdta_x_axis}->draw($x, $y + $self->{axis_space}, $angle); + my $text = $self->{_data}->get_x($i); + if (defined $text) + { + $self->{gdta_x_axis}->set_text($text); + + my $angle = 0; + if ($self->{x_labels_vertical}) + { + $self->{gdta_x_axis}->set_align('center', 'right'); + $angle = PI/2; + } + else + { + $self->{gdta_x_axis}->set_align('top', 'center'); + } + $self->{gdta_x_axis}->draw($x, $y + $self->{axis_space}, $angle); + } } return $self;