Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Croaks on chart with single data point #3

xover opened this Issue Mar 6, 2012 · 4 comments


None yet
5 participants

xover commented Mar 6, 2012

[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:

  Chart::Clicker::Data::DataSet->new(series => [
      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.

aavang commented Jun 13, 2012

The range of a axis is the variance between the minimum and maximum values. Since there is only one point, the range is correctly calculated as zero. Now, this being said, this corner case should be handled

Also if there are more values say keys => [1,2,3,4,5] and values => [6,6,6,6,6] even at this point of time the same error message is thrown. In real time values can be same most of the time


gphat commented Dec 13, 2012

Sorry, but I really think this is something you should fix when the data is sent. I'm not even sure how clicker would deal with this happening, as many renderers would be useless with a single point. What would a line renderer draw in that case?

@gphat gphat closed this Dec 13, 2012

koknat commented Oct 7, 2013

I'm seeing the same problem as aavang and HemanthKumarR
I have many data points, and occasionally all points have the same value.
The code croaks with "This axis has a span of 0, that's fatal!"
As a workaround for this corner case, I subtract a small amount from my first value, but that's ugly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment