don't draw line markers for area charts by default
authorTony Cook <tony@develop-help.com>
Thu, 29 Jul 2010 14:00:37 +0000 (14:00 +0000)
committerTony Cook <tony@develop-help.com>
Thu, 29 Jul 2010 14:00:37 +0000 (14:00 +0000)
lib/Imager/Graph/Vertical.pm
t/t40area.t
testimg/t40area1.png
testimg/t40area2.png [new file with mode: 0644]

index f06f7ead00843662c4d14ab84fb2dd68f8f38d35..b91dd4bc5aa62920cd5d8a6183124fc799e1dd10 100644 (file)
@@ -744,9 +744,11 @@ sub _draw_area {
     my @fill = $self->_area_data_fill($series_counter, [$left, $bottom, $right, $top]);
     $img->polygon(points => [@polygon_points], @fill);
 
-    push @marker_positions, [$x2, $y2];
-    foreach my $position (@marker_positions) {
-      $self->_draw_line_marker($position->[0], $position->[1], $series_counter);
+    if ($self->_feature_enabled("areamarkers")) {
+      push @marker_positions, [$x2, $y2];
+      foreach my $position (@marker_positions) {
+       $self->_draw_line_marker($position->[0], $position->[1], $series_counter);
+      }
     }
     $series_counter++;
   }
@@ -1053,6 +1055,23 @@ sub set_graph_fill_style {
   return 1;
 }
 
+=item show_area_markers()
+
+Feature: areamarkers.
+
+Draw line markers along the top of area data series.
+
+=cut
+
+sub show_area_markers {
+  my ($self) = @_;
+
+  $self->{custom_style}{features}{areamarkers} = 1;
+
+  return 1;
+}
+
+
 =item use_automatic_axis()
 
 Automatically scale the Y axis, based on L<Chart::Math::Axis>.  If
@@ -1070,7 +1089,6 @@ sub use_automatic_axis {
   return 1;
 }
 
-
 =item set_y_tics($count)
 
 Set the number of Y tics to use.  Their value and position will be
index b443bcb6c781a5518180d730c58daf608a5875f6..64ca0e18d2ec790b53c60029ec696c88ed740277 100644 (file)
@@ -29,7 +29,7 @@ my @data2 =
   );
 my @labels = qw(alpha beta gamma delta epsilon phi gi);
 
-plan tests => 7;
+plan tests => 8;
 
 {
   my $area = Imager::Graph::Area->new;
@@ -79,7 +79,7 @@ plan tests => 7;
   $area->use_automatic_axis();
   my $img2 = $area->draw
     (
-     features => [ "horizontal_gridlines" ],
+     features => [ "horizontal_gridlines", "areamarkers" ],
      labels => \@labels,
      font => $font,
      hgrid => { style => "dashed", color => "#888" },
@@ -91,6 +91,8 @@ plan tests => 7;
   ok($img2, "made second area chart image");
   ok($img2->write(file => "testout/t40area2.ppm"),
      "save to file");
+
+  cmpimg($img2, "testimg/t40area2.png");
 }
 
 END {
index 7d916910154976f3afad0642d3abe0634fd3a0e5..797ea1f2294bcd01d9154d075b44a29371482d77 100644 (file)
Binary files a/testimg/t40area1.png and b/testimg/t40area1.png differ
diff --git a/testimg/t40area2.png b/testimg/t40area2.png
new file mode 100644 (file)
index 0000000..3eb4909
Binary files /dev/null and b/testimg/t40area2.png differ