Skip to content

Commit

Permalink
Fix: don’t draw an axis if the data is empty.
Browse files Browse the repository at this point in the history
A very specific case was raising an error, for instance if data is

    {"organic_views"=>{}, "paid_views"=>{}}

or anything made of empty hashes, and the type is `:stack`.
  • Loading branch information
claudiob committed Oct 1, 2015
1 parent 75e841d commit c63beb9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ For more information about changelogs, check
[Keep a Changelog](http://keepachangelog.com) and
[Vandamme](http://tech-angels.github.io/vandamme).

## 1.0.1 - 2015.10.01

* [BUGFIX] Don’t try to draw an axis if the data is empty.

## 1.0.0 - 2015.08.31

* [FEATURE] Add `chart` method to Prawn::Document to draw graphs.
8 changes: 6 additions & 2 deletions lib/squid/axis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ def label_width(label)
end

def min
[values.first.min, 0].min if @data.any? && values.first.any?
if @data.any? && values.first && values.first.any?
[values.first.min, 0].min
end
end

def max
[values.last.max, @steps].max if @data.any? && values.last.any?
if @data.any? && values.last && values.last.any?
[values.last.max, @steps].max
end
end

def values
Expand Down
2 changes: 1 addition & 1 deletion lib/squid/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Squid
VERSION = '1.0.0'
VERSION = '1.0.1'
end

0 comments on commit c63beb9

Please sign in to comment.