Skip to content

Commit

Permalink
die with a better error message for degenerate values
Browse files Browse the repository at this point in the history
  • Loading branch information
moritz committed Jun 20, 2010
1 parent a581e28 commit fc147e9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/SVG/Plot.pm
Expand Up @@ -212,9 +212,17 @@ multi method plot(:$full = True, :$xy-lines!) {
my $max_x = [max] @.x;
my $min_x = [min] @.x;

if $max_x == $min_x {
die "There's just one x value ($max_x), refusing to plot\n";
}

my $max_y = [max] @.values.map: { [max] @($_) };
my $min_y = [min] @.values.map: { [min] @($_) };

if $max_y == $min_y {
die "There's just one y value ($max_x), refusing to plot\n";
}

my $datasets = +@.values;

my $step_x = $.plot-width / ($max_x - $min_x);
Expand Down

0 comments on commit fc147e9

Please sign in to comment.