gphat/chart-clicker — Issue #3: Croaks on chart with single data point
Author: xover
Created: 2012-03-06 10:19:31+00:00
State: open

[Chart::Clicker 2.79 off CPAN]

When given a Data::Series that only contains a single data point, C::C::Axis croaks with the message:

This axis has a span of 0, that's fatal! at […]/Chart/Clicker/Axis.pm line 186

Code to reproduce (modulo some boilerplate pre- and post-), based on the bar.pl example but tested with both Bar and Line renderers:

```$cc->add_to_datasets(
Chart::Clicker::Data::DataSet->new(series => [
Chart::Clicker::Data::Series->new(
keys => [1],
values => [5.8],
)
])
);
```

Adding one extra data point (key and value) avoids it. Off-by-one somewhere perhaps? Just looking quickly at the relevant if() it looks like the range of the axis doesn't get calculated properly (i.e. it's 0) when there's just one data point.