Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support negative axes #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/squid/axis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def min

def max
if @data.any? && values.last && values.last.any?
return 0 if min < 0 && values.last.max <= 0
closest_step_to values.last.max
end
end
Expand Down
25 changes: 25 additions & 0 deletions spec/axis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,29 @@
it { expect(width).to eq 14 }
end
end

describe '#minmax' do
subject(:axis) { Squid::Axis.new series, options }
let(:minmax) { axis.minmax }

describe 'given all-zero series' do
let(:series) { [0, 0, 0] }
it { expect(minmax).to eq [0, steps] }
end

describe 'given positive series' do
let(:series) { [0, 10, 12] }
it { expect(minmax).to eq [0, 12] }
end

describe 'given negative series' do
let(:series) { [0, -10, -12] }
it { expect(minmax).to eq [-12, 0] }
end

describe 'given mixed series' do
let(:series) { [0, -10, 12] }
it { expect(minmax).to eq [-10, 12] }
end
end
end