Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 47068cf

Browse files
committed
fix and 🔒 histograms with TypedArrays
1 parent 2a9548d commit 47068cf

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/traces/histogram/calc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) {
252252
for(i = 0; i < traces.length; i++) {
253253
tracei = traces[i];
254254
pos0 = tracei._pos0 = pa.makeCalcdata(tracei, mainData);
255-
allPos = allPos.concat(pos0);
255+
allPos = Lib.concat(allPos, pos0);
256256
delete tracei._autoBinFinished;
257257
if(trace.visible === true) {
258258
if(isFirstVisible) {

test/jasmine/tests/histogram_test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,16 @@ describe('Test histogram', function() {
536536
expect(calcPositions(trace3)).toBeCloseToArray([1.1, 1.3], 5);
537537
});
538538

539+
it('can handle TypedArrays', function() {
540+
var trace1 = {x: new Float32Array([1, 2, 3, 4])};
541+
var trace2 = {x: new Float32Array([5, 5.5, 6, 6.5])};
542+
var trace3 = {x: new Float64Array([1, 1.1, 1.2, 1.3]), xaxis: 'x2'};
543+
var trace4 = {x: new Float64Array([1, 1.2, 1.4, 1.6]), yaxis: 'y2'};
544+
545+
expect(calcPositions(trace1, [trace2, trace3, trace4])).toEqual([1, 3, 5]);
546+
expect(calcPositions(trace3)).toBeCloseToArray([1.1, 1.3], 5);
547+
});
548+
539549
describe('cumulative distribution functions', function() {
540550
var base = {
541551
x: [0, 5, 10, 15, 5, 10, 15, 10, 15, 15],

0 commit comments

Comments
 (0)