- for vertical and horizontal charts, allow the fill of the graph
area to be controlled separately from the base bg (graph.fill)
-
- tests
Bug fixes:
add_bar_data_series() and now adds the series as a "bar" series.
add_column_data_series() did nothing useful for a horizontal chart.
-TODO:
-
- - control of drawing markers for:
-
- - area
-
- - line
-
- - control of x/yaxis separate from graph area outline
-
- - test line markers
-
- - document:
-
- - features: horizontal_gridlines, graph_outline, graph_fill
-
- - graph outline and gridline styles
-
Imager-Graph 0.07 - 21 May 2009
=================
aa => 'lookup(aa)',
},
lineaa => 'lookup(aa)',
+
+ line_markers =>[
+ { shape => 'circle', radius => 4 },
+ { shape => 'square', radius => 4 },
+ { shape => 'diamond', radius => 4 },
+ { shape => 'triangle', radius => 4 },
+ { shape => 'x', radius => 4 },
+ { shape => 'plus', radius => 4 },
+ ],
);
=item _error($message)
colors => [
qw(FF0000 00FF00 0000FF C0C000 00C0C0 FF00FF)
],
- line_markers =>[
- { shape => 'circle', radius => 4 },
- { shape => 'square', radius => 4 },
- { shape => 'diamond', radius => 4 },
- { shape => 'triangle', radius => 4 },
- { shape => 'x', radius => 4 },
- { shape => 'plus', radius => 4 },
- ],
back=>{ fountain=>'linear',
xa_ratio=>0, ya_ratio=>0,
xb_ratio=>1.0, yb_ratio=>1.0,
};
-
=item $self->_style_setup(\%opts)
Uses the values from %opts, the custom style set by methods, the style
my $x2 = $left + ($value_range - $data[$data_size - 1] + $min_value)/$value_range * $graph_width;
- push @marker_positions, [$x2, $y2];
- foreach my $position (@marker_positions) {
- $self->_draw_line_marker($position->[0], $position->[1], $series_counter);
+ if ($self->_feature_enabled("linemarkers")) {
+ push @marker_positions, [$x2, $y2];
+ foreach my $position (@marker_positions) {
+ $self->_draw_line_marker($position->[0], $position->[1], $series_counter);
+ }
}
$series_counter++;
}
return 1;
}
+=item show_line_markers()
+
+=item show_line_markers($value)
+
+Feature: linemarkers.
+
+If $value is missing or true, draw markers on a line data series.
+
+Note: line markers are drawn by default.
+
+=cut
+
+sub show_line_markers {
+ my ($self, $value) = @_;
+
+ @_ > 1 or $value = 1;
+
+ $self->{custom_style}{features}{linemarkers} = $value;
+
+ return 1;
+}
+
=item use_automatic_axis()
Automatically scale the Y axis, based on L<Chart::Math::Axis>. If Chart::Math::Axis isn't installed, this sets an error and returns undef. Returns 1 if it is installed.
my ($self) = @_;
my %work = %{$self->SUPER::_style_defs()};
- push @{$work{features}}, qw/graph_outline graph_fill/;
+ push @{$work{features}}, qw/graph_outline graph_fill linemarkers/;
$work{vgrid} =
{
color => "lookup(fg)",
use vars qw(@ISA);
use Imager::Graph;
@ISA = qw(Imager::Graph);
+use Imager::Fill;
use constant STARTING_MIN_VALUE => 99999;
my $y2 = $bottom + ($value_range - $data[$data_size - 1] + $min_value)/$value_range * $graph_height;
- push @marker_positions, [$x2, $y2];
- foreach my $position (@marker_positions) {
- $self->_draw_line_marker($position->[0], $position->[1], $series_counter);
+ if ($self->_feature_enabled("linemarkers")) {
+ push @marker_positions, [$x2, $y2];
+ foreach my $position (@marker_positions) {
+ $self->_draw_line_marker($position->[0], $position->[1], $series_counter);
+ }
}
$series_counter++;
}
=item show_area_markers()
+=item show_area_markers($value)
+
Feature: areamarkers.
-Draw line markers along the top of area data series.
+If $value is missing or true, draw markers along the top of area data
+series.
+
+eg.
+
+ $chart->show_area_markers();
=cut
sub show_area_markers {
- my ($self) = @_;
+ my ($self, $value) = @_;
- $self->{custom_style}{features}{areamarkers} = 1;
+ @_ > 1 or $value = 1;
+
+ $self->{custom_style}{features}{areamarkers} = $value;
return 1;
}
+=item show_line_markers()
+
+=item show_line_markers($value)
+
+Feature: linemarkers.
+
+If $value is missing or true, draw markers on a line data series.
+
+Note: line markers are drawn by default.
+
+=cut
+
+sub show_line_markers {
+ my ($self, $value) = @_;
+
+ @_ > 1 or $value = 1;
+
+ $self->{custom_style}{features}{linemarkers} = $value;
+
+ return 1;
+}
=item use_automatic_axis()
{
opacity => 0.5,
};
- push @{$work{features}}, qw/graph_outline graph_fill/;
+ push @{$work{features}}, qw/graph_outline graph_fill linemarkers/;
$work{hgrid} =
{
color => "lookup(fg)",
use Imager qw(:handy);
-plan tests => 3;
+plan tests => 5;
my @warned;
local $SIG{__WARN__} =
my @data = ( 100, 180, 80, 20, 2, 1, 0.5 );
my @labels = qw(alpha beta gamma delta epsilon phi gi);
-my $column = Imager::Graph::Column->new();
-ok($column, "creating column chart object");
+{
+ my $column = Imager::Graph::Column->new();
+ ok($column, "creating column chart object");
-$column->add_data_series(\@data);
-$column->set_labels(\@labels);
+ $column->add_data_series(\@data);
+ $column->set_labels(\@labels);
-my $img1 = $column->draw();
-ok($img1, "drawing column chart");
+ my $img1 = $column->draw();
+ ok($img1, "drawing column chart");
-$img1->write(file=>'testout/t12_basic.ppm') or die "Can't save img1: ".$img1->errstr."\n";
+ $img1->write(file=>'testout/t12_column.ppm') or die "Can't save img1: ".$img1->errstr."\n";
+}
+
+{
+ my $column = Imager::Graph::Column->new();
+ ok($column, "creating column chart object");
+
+ $column->add_data_series(\@data);
+ $column->add_data_series([ -50, -30, 20, 10, -10, 25, 10 ]);
+ $column->set_labels(\@labels);
+
+ my $img1 = $column->draw(features => "outline");
+ ok($img1, "drawing column chart");
+
+ $img1->write(file=>'testout/t12_column2.ppm') or die "Can't save img1: ".$img1->errstr."\n";
+}
unless (is(@warned, 0, "should be no warnings")) {
diag($_) for @warned;
use Imager qw(:handy);
-plan tests => 3;
+plan tests => 5;
my @warned;
local $SIG{__WARN__} =
my @data = ( 100, 180, 80, 20, 2, 1, 0.5 );
my @labels = qw(alpha beta gamma delta epsilon phi gi);
-my $stacked_col = Imager::Graph::StackedColumn->new();
-ok($stacked_col, "creating stacked_col chart object");
+{
+ my $stacked_col = Imager::Graph::StackedColumn->new();
+ ok($stacked_col, "creating stacked_col chart object");
-$stacked_col->add_data_series(\@data);
-$stacked_col->set_labels(\@labels);
+ $stacked_col->add_data_series(\@data);
+ $stacked_col->set_labels(\@labels);
-my $img1 = $stacked_col->draw();
-ok($img1, "drawing stacked_col chart");
+ my $img1 = $stacked_col->draw();
+ ok($img1, "drawing stacked_col chart");
-$img1->write(file=>'testout/t13_basic.ppm') or die "Can't save img1: ".$img1->errstr."\n";
+ $img1->write(file=>'testout/t13_stacked.ppm') or die "Can't save img1: ".$img1->errstr."\n";
+}
+
+{
+ my $stacked_col = Imager::Graph::StackedColumn->new();
+ ok($stacked_col, "creating stacked_col chart object");
+
+ $stacked_col->add_data_series(\@data);
+ $stacked_col->add_data_series([ -50, -30, 20, 10, -10, 25, 10 ]);
+ $stacked_col->set_labels(\@labels);
+ my $img1 = $stacked_col->draw
+ (
+ features => "outline",
+ column_padding => 10,
+ );
+ ok($img1, "drawing stacked_col chart");
+
+ $img1->write(file=>'testout/t13_stacked2.ppm') or die "Can't save stacked2: ".$img1->errstr."\n";
+}
unless (is(@warned, 0, "should be no warnings")) {
diag($_) for @warned;