-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix support for typed arrays in bar 'width' and 'offset' #3169
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
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 |
---|---|---|
|
@@ -397,6 +397,46 @@ describe('Bar.crossTraceCalc (formerly known as setPositions)', function() { | |
assertArrayField(cd[2][0], 't.poffset', [-0.4]); | ||
}); | ||
|
||
it('should work with *width* typed arrays', function() { | ||
var w = [0.1, 0.4, 0.7]; | ||
|
||
var gd = mockBarPlot([{ | ||
width: w, | ||
y: [1, 2, 3] | ||
}, { | ||
width: new Float32Array(w), | ||
y: [1, 2, 3] | ||
}]); | ||
|
||
var cd = gd.calcdata; | ||
assertArrayField(cd[0][0], 't.barwidth', w); | ||
assertArrayField(cd[1][0], 't.barwidth', w); | ||
assertPointField(cd, 'x', [ | ||
[-0.2, 0.8, 1.8], | ||
[0.2, 1.2, 2.2] | ||
]); | ||
}); | ||
|
||
it('should work with *offset* typed arrays', function() { | ||
var o = [0.1, 0.4, 0.7]; | ||
|
||
var gd = mockBarPlot([{ | ||
offset: o, | ||
y: [1, 2, 3] | ||
}, { | ||
offset: new Float32Array(o), | ||
y: [1, 2, 3] | ||
}]); | ||
|
||
var cd = gd.calcdata; | ||
assertArrayField(cd[0][0], 't.poffset', o); | ||
assertArrayField(cd[1][0], 't.poffset', o); | ||
assertPointField(cd, 'x', [ | ||
[0.5, 1.8, 3.1], | ||
[0.5, 1.8, 3.099] | ||
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. Huh, took me a while to figure out where these numbers came from... surprised I had never noticed this before but it seems weird that 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. I'm not sure. With a regular array, we get:
with a typed array, we get:
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. ah ok, that's just because it's a |
||
]); | ||
}); | ||
|
||
it('should guard against invalid width items', function() { | ||
var gd = mockBarPlot([{ | ||
width: [null, 1, 0.8], | ||
|
Uh oh!
There was an error while loading. Please reload this page.