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

People
Owner: bwarfield [...] cpan.org
Requestors: michael [...] ndrix.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 1.4307
Fixed in: (no value)



Subject: line_width does not accept an array reference
When using lines and linespoints graphs, all the lines in the graph must have the same width. I've found it useful to be able to independently specify the width of each line in the graph. I've attached a patch which allows for code like this $graph->set( line_width => [1, 5, 10] ) which would make the first (fourth, seventh) line 1 pixel wide, the second line (fifth, eighth) 5 pixels wide and the third (sixth, ninth) 10 pixels wide. Of course, the current behavior is still supported. The patch also includes a sample graph.
Subject: line_width-multiple.patch
=== Graph/lines.pm ================================================================== --- Graph/lines.pm (revision 5) +++ Graph/lines.pm (patch - level 1) @@ -70,7 +70,7 @@ if (defined $xb) { - $self->draw_line($xb, $yb, $xe, $ye, $type, $dsci) + $self->draw_line($xb, $yb, $xe, $ye, $type, $dsci, $ds) if defined $dsci; $self->{_hotspots}->[$ds]->[$i] = ['line', $xb, $yb, $xe, $ye, $self->{line_width}]; @@ -91,12 +91,22 @@ $num % 4 ? $num % 4 : 4 } -sub draw_line # ($xs, $ys, $xe, $ye, $type, $colour_index) +sub pick_line_width { my $self = shift; - my ($xs, $ys, $xe, $ye, $type, $clr) = @_; + my $num = shift; my $lw = $self->{line_width}; + return $lw if !ref $lw; + return $lw->[ $num % ( 1 + $#$lw ) - 1 ]; +} + +sub draw_line # ($xs, $ys, $xe, $ye, $type, $colour_index, $ds) +{ + my $self = shift; + my ($xs, $ys, $xe, $ye, $type, $clr, $ds) = @_; + + my $lw = $self->pick_line_width($ds); my $lts = $self->{line_type_scale}; my $style = gdStyled; === samples/sample52-t.pl ================================================================== --- samples/sample52-t.pl (revision 5) +++ samples/sample52-t.pl (patch - level 1) @@ -0,0 +1,39 @@ +use GD::Graph::lines; +require 'save.pl'; + +print STDERR "Processing sample52-t\n"; + +@data = ( + [ qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec) ], + [ reverse(4, 3, 5, 6, 3, 1.5, -1, -3, -4, -6, -7, -8)], + [ (4, 3, 5, 6, 3, 1.5, -1, -3, -4, -6, -7, -8)], + [ (2, 2, 2, 5, 5, 4.5,1.5, 2, 3, 5, 4, 3)], +); + +$my_graph = new GD::Graph::lines(); + +$my_graph->set( + x_label => 'Month', + y_label => 'Measure of success', + title => 'A Line Graph with Varying Line Widths', + + y_max_value => 8, + y_min_value => -8, + y_tick_number => 16, + y_label_skip => 2, + box_axis => 0, + line_width => [ 1, 5, 3 ], + zero_axis_only => 1, + x_label_position => 1, + y_label_position => 1, + + x_label_skip => 3, + x_tick_offset => 2, + + transparent => 0, +); + +$my_graph->set_legend("Us", "Them", "Others"); +$my_graph->plot(\@data); +save_chart($my_graph, 'sample52-t'); + === samples/Makefile ================================================================== --- samples/Makefile (revision 5) +++ samples/Makefile (patch - level 1) @@ -30,7 +30,7 @@ sample21 sample22 sample23 \ sample31 \ sample41 sample42\ - sample51 sample52 sample53 sample54 sample55 sample56 \ + sample51 sample52 sample52-t sample53 sample54 sample55 sample56 \ sample57 \ sample61 sample62 sample63 sample64 \ sample71 \ Property changes on: samples ___________________________________________________________________ Name: svn:ignore +*.png + === Graph.pm ================================================================== --- Graph.pm (revision 5) +++ Graph.pm (patch - level 1) @@ -1306,8 +1306,16 @@ =item line_width The width of the line used in I<lines> and I<linespoints> graphs, in pixels. -Default: 1. +If C<line_width> is a scalar value, that width will be used for all lines. If +C<line_width> is a reference to an array, the contents of the array specify +the line widths for each line. If there are too few values in the array +reference, the values are "recycled". For example, to alternate between lines +one pixel wide and lines five pixels wide, one might do something like + $graph->set( line_width => [1, 5] ); + +Default: 1 (make all lines 1 pixel wide) + =item skip_undef For all other axes graph types, the default behaviour is (by their
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.