-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Log bar autorange fix #1475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and 8000 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
Log bar autorange fix #1475
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,7 @@ describe('Bar.supplyDefaults', function() { | |
}); | ||
}); | ||
|
||
describe('heatmap calc / setPositions', function() { | ||
describe('bar calc / setPositions', function() { | ||
'use strict'; | ||
|
||
beforeAll(function() { | ||
|
@@ -697,6 +697,47 @@ describe('Bar.setPositions', function() { | |
expect(gd.calcdata[1][0].placeholder).toBe(true); | ||
expect(gd.calcdata[1][0].t.barwidth).toBeUndefined(); | ||
}); | ||
|
||
it('works with log axes (grouped bars)', function() { | ||
var gd = mockBarPlot([ | ||
{y: [1, 10, 1e10, -1]}, | ||
{y: [2, 20, 2e10, -2]} | ||
], { | ||
yaxis: {type: 'log'}, | ||
barmode: 'group' | ||
}); | ||
|
||
var ya = gd._fullLayout.yaxis; | ||
expect(Axes.getAutoRange(ya)).toBeCloseToArray([-0.572, 10.873], undefined, '(ya.range)'); | ||
}); | ||
|
||
it('works with log axes (stacked bars)', function() { | ||
var gd = mockBarPlot([ | ||
{y: [1, 10, 1e10, -1]}, | ||
{y: [2, 20, 2e10, -2]} | ||
], { | ||
yaxis: {type: 'log'}, | ||
barmode: 'stack' | ||
}); | ||
|
||
var ya = gd._fullLayout.yaxis; | ||
expect(Axes.getAutoRange(ya)).toBeCloseToArray([-0.582, 11.059], undefined, '(ya.range)'); | ||
}); | ||
|
||
it('works with log axes (normalized bars)', function() { | ||
// strange case... but it should work! | ||
var gd = mockBarPlot([ | ||
{y: [1, 10, 1e10, -1]}, | ||
{y: [2, 20, 2e10, -2]} | ||
], { | ||
yaxis: {type: 'log'}, | ||
barmode: 'stack', | ||
barnorm: 'percent' | ||
}); | ||
|
||
var ya = gd._fullLayout.yaxis; | ||
expect(Axes.getAutoRange(ya)).toBeCloseToArray([1.496, 2.027], undefined, '(ya.range)'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice tests! I wouldn't be opposed to adding a bar log image test too if you're up for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could be nice, but for now I think I'd better move on. |
||
}); | ||
}); | ||
|
||
describe('A bar plot', function() { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice simplification.