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:
62665
Status:
resolved
Priority:
Low/Low
Queue:

People
Owner:
RUZ [...] cpan.org
Requestors:
patermanns [...] gmail.com
Cc:
AdminCc:



Subject: Min/Max y values do not work for two axes
I am trying to produce a plot with two lines on different scales. I have set the two_axes option to 1 and set y1_min_value = 0, y1_max_value = 250, y2_min_value = 400, y2_max_value = 1200. Despite the fact that the data for the two lines fit within the min/max values, the two scales are shown as 0-350 for y1 and 0-1200 for y2. I have attached a simple program showing the bug and the output produced by it as a PNG file. Using GD::Graph version 1.44 with ActiveState Perl version 5.8.9 on Windows XP.
Subject: test_chartg.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 => 1, x_label_skip => 4, 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_chart2.png") or die "Cannot open output file\n"; binmode(IMAGE); print IMAGE $gd->png; close(IMAGE);
Subject: test_chart2.png
test_chart2.png
From: patermanns@gmail.com
After further investigation, I have found that this is caused by a section of code in axestype.pm which attempts to adjust the two axes to make the zero point appear in the same place on both. I do not want this so I attach a patch which does not adjust the axes if "two_axes" is 2 (i.e. I want two separate axes!). If two_axes has any other value, the adjustment is performed as now. I also found a bug which prevented the "minimum range" option from working (i.e. setting y_min_range, y1_min_range, y2_min_range) for two axes. I have attached a second patch for this. Note that this patch should be applied after the above patch for the line numbers to be correct.
Subject: adjust_axes.diff
*** axestype-orig.pm Wed Apr 25 20:16:10 2007 --- axestype.pm Mon Nov 08 16:59:41 2010 *************** *** 661,666 **** --- 661,667 ---- my $s = shift; # Do some sanity checks + $s->{adjust_axes} = ($s->{two_axes} == 2)? 0: 1; $s->{two_axes} = 0 if $s->{_data}->num_sets < 2 || $s->{two_axes} < 0; $s->{two_axes} = 1 if $s->{two_axes} > 1; *************** *** 1600,1606 **** $self->{x_min} = $self->{x_min_value} if defined $self->{x_min_value}; $self->{x_max} = $self->{x_max_value} if defined $self->{x_max_value}; ! if ($self->{two_axes}) { # If we have two axes, we need to make sure that the zero is at # the same spot. --- 1601,1607 ---- $self->{x_min} = $self->{x_min_value} if defined $self->{x_min_value}; $self->{x_max} = $self->{x_max_value} if defined $self->{x_max_value}; ! if ($self->{two_axes} && $self->{adjust_axes}) { # If we have two axes, we need to make sure that the zero is at # the same spot.
Subject: min_range_fix.diff
*** axestype-orig.pm Wed Apr 25 20:16:10 2007 --- axestype.pm Mon Nov 08 16:59:41 2010 *************** *** 1515,1526 **** # First, calculate some decent values if ( $self->{two_axes} ) { # XXX this is almost certainly a bug: this key is not set anywhere ! my $min_range_1 = defined($self->{min_range_1}) ! ? $self->{min_range_1} ! : $self->{min_range}; ! my $min_range_2 = defined($self->{min_range_2}) ! ? $self->{min_range_2} ! : $self->{min_range}; my(@y_min, @y_max); for my $nd (1 .. $self->{_data}->num_sets) --- 1515,1526 ---- # First, calculate some decent values if ( $self->{two_axes} ) { # XXX this is almost certainly a bug: this key is not set anywhere ! my $min_range_1 = defined($self->{y1_min_range}) ! ? $self->{y1_min_range} ! : $self->{y_min_range}; ! my $min_range_2 = defined($self->{y2_min_range}) ! ? $self->{y2_min_range} ! : $self->{y_min_range}; my(@y_min, @y_max); for my $nd (1 .. $self->{_data}->num_sets)
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.
From: bitcard.org.asc@schwarzes.net
I run into the same problem with my two axes graph and found this older bug report. Both scales are aligned at 0, regardless of setting y1_min_value, y2_min_value or not. Is there any plan to fix this? The solution, provided with one patch, to use "two_axes=2" for disabling the "alignment" seems ok, this will not touch the old behavior (or use an extra option "two_axes_align=0" (default 1)). -asc
Hi, Decided to go with https://github.com/ruz/GDGraph/commit/1367697fdee4f2852b4d197cf83121e5fc90b1c7 1.54 on its way to the CPAN On Sun Nov 20 20:04:19 2016, bitcard.org.asc@schwarzes.net wrote:
Show quoted text
> > I run into the same problem with my two axes graph and found this > older bug report. Both scales are aligned at 0, regardless of setting > y1_min_value, y2_min_value or not. Is there any plan to fix this? The > solution, provided with one patch, to use "two_axes=2" for disabling > the "alignment" seems ok, this will not touch the old behavior (or use > an extra option "two_axes_align=0" (default 1)). > > -asc
-- Best regards, Ruslan.
From: bitcard.org.asc@schwarzes.net
On Mon Nov 21 07:28:49 2016, RUZ wrote:
Show quoted text
> Hi, > > Decided to go with > https://github.com/ruz/GDGraph/commit/1367697fdee4f2852b4d197cf83121e5fc90b1c7 > > 1.54 on its way to the CPAN
Ok, thank you. -asc


This service runs on Request Tracker, is sponsored by The Perl Foundation, and maintained by Best Practical Solutions.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.