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: 62889
Status: open
Priority: 0/
Queue: GDGraph

People
Owner: Nobody in particular
Requestors: patermanns [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.44
Fixed in: (no value)



Subject: Allow ticks outside the axes with long_ticks
Using a negative value for tick length tells GD::Graph to put the ticks outside the axes; however, long_ticks currently overrides the tick_length setting and so ticks do not appear on the axes if long_ticks are used. Long ticks are effectively grid lines and it would be useful to use both options together so I have attached a patch to axestype.pm which draws both gridlines and ticks where tick_length is negative and long_ticks are used. Using ActiveState Perl 5.8.9 on Windows XP and Perl 5.8.8 on Red Hat Enterprise Linux 5.3 (64-bit). N.B. This patch should be applied after the previous patch (Min/Max y values do not work for two axes) for the line numbers to be correct.
Subject: long_tick.diff
*** axestype-patched.pm Mon Nov 08 17:24:08 2010 --- axestype.pm Tue Nov 09 17:24:35 2010 *************** *** 998,1003 **** --- 998,1008 ---- { my $self = shift; + # Get tick length - set to zero if greater than zero and using long ticks + # as the gridlines will overwrite the ticks + my $tick_length = $self->{y_tick_length}; + $tick_length = 0 if $self->{y_long_ticks} && ($self->{y_tick_length} > 0); + for my $t (0 .. $self->{y_tick_number}) { for my $axis (1 .. ($self->{two_axes} + 1)) *************** *** 1006,1030 **** my $label = $self->{y_labels}[$axis][$t]; my ($x, $y) = $self->val_to_pixel(0, $value, -$axis); $y = ($axis == 1) ? $self->{bottom} : $self->{top}; ! if ($self->{y_long_ticks}) { ! $self->{graph}->line( ! $x, $self->{bottom}, ! $x, $self->{top}, ! $self->{fgci} ! ) unless ($axis-1); ! } ! else ! { ! $self->{graph}->line( ! $x, $y, ! $x, $y - $self->{y_tick_length}, ! $self->{fgci} ! ); } ! next if $t % ($self->{y_label_skip}) || ! $self->{y_plot_values}; --- 1011,1028 ---- my $label = $self->{y_labels}[$axis][$t]; my ($x, $y) = $self->val_to_pixel(0, $value, -$axis); + my $y1 = ($axis == 1) ? $self->{bottom} : $self->{top}; + my $y2 = ($axis == 1) ? $self->{bottom} - $tick_length: + $self->{top} + $tick_length; $y = ($axis == 1) ? $self->{bottom} : $self->{top}; ! if ($self->{y_long_ticks} && $axis == 1) # draw the gridline { ! $y1 -= $tick_length; ! $y2 = $self->{top}; } ! $self->{graph}->line($x, $y1, $x, $y2, $self->{fgci}) if $y1 != $y2; ! next if $t % ($self->{y_label_skip}) || ! $self->{y_plot_values}; *************** *** 1050,1055 **** --- 1048,1058 ---- { my $self = shift; + # Get tick length - set to zero if greater than zero and using long ticks + # as the gridlines will overwrite the ticks + my $tick_length = $self->{y_tick_length}; + $tick_length = 0 if $self->{y_long_ticks} && ($self->{y_tick_length} > 0); + for my $t (0 .. $self->{y_tick_number}) { # XXX Ugh, why did I ever do it this way? How bloody obscure. *************** *** 1059,1082 **** my $label = $self->{y_labels}[$axis][$t]; my ($x, $y) = $self->val_to_pixel(0, $value, -$axis); $x = ($axis == 1) ? $self->{left} : $self->{right}; ! ! if ($self->{y_long_ticks}) { ! $self->{graph}->line( ! $x, $y, ! $x + $self->{right} - $self->{left}, $y, ! $self->{fgci} ! ) unless ($axis-1); ! } ! else ! { ! $self->{graph}->line( ! $x, $y, ! $x + (3 - 2 * $axis) * $self->{y_tick_length}, $y, ! $self->{fgci} ! ); } next if $t % ($self->{y_label_skip}) || ! $self->{y_plot_values}; --- 1062,1078 ---- my $label = $self->{y_labels}[$axis][$t]; my ($x, $y) = $self->val_to_pixel(0, $value, -$axis); + my $x1 = ($axis == 1) ? $self->{left} : $self->{right}; + my $x2 = ($axis == 1) ? $self->{left} + $tick_length: + $self->{right} - $tick_length; $x = ($axis == 1) ? $self->{left} : $self->{right}; ! ! if ($self->{y_long_ticks} && $axis == 1) # draw the gridline { ! $x1 += $tick_length; ! $x2 = $self->{right}; } + $self->{graph}->line($x1, $y, $x2, $y, $self->{fgci}) if $x1 != $x2; next if $t % ($self->{y_label_skip}) || ! $self->{y_plot_values}; *************** *** 1113,1118 **** --- 1109,1119 ---- { my $self = shift; + # Get tick length - set to zero if greater than zero and using long ticks + # as the gridlines will overwrite the ticks + my $tick_length = $self->{x_tick_length}; + $tick_length = 0 if $self->{x_long_ticks} && ($self->{x_tick_length} > 0); + for (my $i = 0; $i < $self->{_data}->num_points; $i++) { my ($x, $y) = $self->val_to_pixel($i + 1, 0, 1); *************** *** 1127,1142 **** if ($self->{x_ticks}) { ! if ($self->{x_long_ticks}) ! { ! $self->{graph}->line($self->{left}, $y, $self->{right}, $y, ! $self->{fgci}); ! } ! else { ! $self->{graph}->line( $x, $y, $x + $self->{x_tick_length}, $y, ! $self->{fgci}); } } # CONTRIB Damon Brodie for x_tick_offset --- 1128,1142 ---- if ($self->{x_ticks}) { ! my $x1 = $x; ! my $x2 = $x + $tick_length; ! ! if ($self->{x_long_ticks}) # draw the gridline { ! $x1 = $self->{left} + $tick_length; ! $x2 = $self->{right}; } + $self->{graph}->line($x1, $y, $x2, $y, $self->{fgci}) if $x1 != $x2; } # CONTRIB Damon Brodie for x_tick_offset *************** *** 1174,1179 **** --- 1174,1184 ---- { my $self = shift; + # Get tick length - set to zero if greater than zero and using long ticks + # as the gridlines will overwrite the ticks + my $tick_length = $self->{x_tick_length}; + $tick_length = 0 if $self->{x_long_ticks} && ($self->{x_tick_length} > 0); + for (my $i = 0; $i < $self->{_data}->num_points; $i++) { my ($x, $y) = $self->val_to_pixel($i + 1, 0, 1); *************** *** 1188,1203 **** if ($self->{x_ticks}) { ! if ($self->{x_long_ticks}) ! { ! $self->{graph}->line($x, $self->{bottom}, $x, $self->{top}, ! $self->{fgci}); ! } ! else { ! $self->{graph}->line($x, $y, $x, $y - $self->{x_tick_length}, ! $self->{fgci}); } } # CONTRIB Damon Brodie for x_tick_offset --- 1193,1207 ---- if ($self->{x_ticks}) { ! my $y1 = $y; ! my $y2 = $y - $tick_length; ! ! if ($self->{x_long_ticks}) # draw the gridline { ! $y1 = $self->{bottom} - $tick_length; ! $y2 = $self->{top}; } + $self->{graph}->line($x, $y1, $x, $y2, $self->{fgci}) if $y1 != $y2; } # CONTRIB Damon Brodie for x_tick_offset *************** *** 1274,1279 **** --- 1278,1288 ---- { my $self = shift; + # Get tick length - set to zero if greater than zero and using long ticks + # as the gridlines will overwrite the ticks + my $tick_length = $self->{x_tick_length}; + $tick_length = 0 if $self->{x_long_ticks} && ($self->{x_tick_length} > 0); + for my $i (0 .. $self->{x_tick_number}) { my ($value, $x, $y); *************** *** 1297,1323 **** if ($self->{x_ticks}) { ! if ($self->{x_long_ticks}) ! { ! # XXX This mod needs to be done everywhere ticks are ! # drawn ! if ( $self->{x_tick_length} >= 0 ) ! { ! $self->{graph}->line($x, $self->{bottom}, ! $x, $self->{top}, $self->{fgci}); ! } ! else ! { ! $self->{graph}->line( ! $x, $self->{bottom} - $self->{x_tick_length}, ! $x, $self->{top}, $self->{fgci}); ! } ! } ! else { ! $self->{graph}->line($x, $y, ! $x, $y - $self->{x_tick_length}, $self->{fgci} ); } } # If we have to skip labels, we'll do it here. --- 1306,1320 ---- if ($self->{x_ticks}) { ! my $y1 = $y; ! my $y2 = $y - $tick_length; ! ! if ($self->{x_long_ticks}) # draw the gridline { ! $y1 = $self->{bottom} - $tick_length; ! $y2 = $self->{top}; } + $self->{graph}->line($x, $y1, $x, $y2, $self->{fgci}) if $y1 != $y2; } # If we have to skip labels, we'll do it here.
Subject: Allow ticks outside the axes with long_ticks [PATCH]
From: patermanns [...] gmail.com
The subject should contain "[PATCH]" to show that a patch is supplied and the severity should be "Wishlist", not "Normal". However, I do not appear to have the necessary permissions to change these. It would be great if someone would do that for me.
From: patermanns [...] gmail.com
I attach a short test program that shows the issue.
Subject: test_chartg03.pl
#!/usr/bin/perl -w use strict; use GD::Graph::lines; my $data1 = '50,30,40,150,60,70,80,120,180,90,20,210'; my $data2 = '400,545,450,600,750,400,1200,800,1000,500,900,1100'; my @x_axis_data = qw(00:00 01:00 02:00 03:00 04:00 05:00 06:00 07:00 08:00 09:00 10:00 11:00 12:00 13:00 14:00 15:00 16:00 17:00 18:00 19:00 20:00 21:00 22:00 23:00 23:59 ); my @y1_axis_data = split(/,/, $data1); my @y2_axis_data = split(/,/, $data2); my @data = ( \@x_axis_data, \@y1_axis_data, \@y2_axis_data ); my $graph = GD::Graph::lines->new(240, 175); $graph->set( title => 'Test 2 Axes', transparent => 0, dclrs => [ qw(red blue) ], # bgclr => 'white', line_width => 2, two_axes => 2, x_label_skip => 4, y_long_ticks => 1, y1_min_value => 0, y1_max_value => 250, y2_min_value => 400, y2_max_value => 1200, tick_length => -4 ) or die $graph->error; $graph->set_legend(split(/,/, 'Line1,Line2')); my $gd = $graph->plot(\@data) or die $graph->error; open(IMAGE,">test_chart03.png") or die "Cannot open output file\n"; binmode(IMAGE); print IMAGE $gd->png; close(IMAGE);
Subject: New GD::Graph co-maintainer and new release on CPAN
Hello, You recieved this message as you filed a bug report or feature request against GD::Graph module on CPAN. My name is Ruslan and I'm new co-maintainer of the module. I've updated the module to 1.45 with doc changes and released it to CPAN. See distribution status [1]. I have TODO list for several releases, so if your ticket was a patch then turning it into a nice pull request may expedite inclusion :) [1] http://search.cpan.org/~ruz/GDGraph-1.45/Graph.pm#DISTRIBUTION_STATUS -- Best regards, Ruslan.