Skip to content

Commit 8d9feaf

Browse files
committed
fix #2020 - editing plots with multiple histograms
1 parent 42805c2 commit 8d9feaf

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/traces/histogram/calc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ function calcAllAutoBins(gd, trace, pa, mainData) {
232232
maxEnd = Math.max(maxEnd, pa.r2c(binSpec.end, 0, calendar));
233233

234234
// add the flag that lets us abort autobin on later traces
235-
if(i) trace._autoBinFinished = 1;
235+
if(i) tracei._autoBinFinished = 1;
236236
}
237237

238238
// do what we can to match the auto bins to the first manual bins

test/jasmine/tests/histogram_test.js

+33
Original file line numberDiff line numberDiff line change
@@ -530,5 +530,38 @@ describe('Test histogram', function() {
530530
expect(gd._fullLayout.xaxis.type).toBe('date');
531531
expect(gd._fullLayout.xaxis.range).toEqual(['2016-12-31 12:00', '2017-01-03 12:00']);
532532
});
533+
534+
it('can resize a plot with several histograms', function(done) {
535+
Plotly.newPlot(gd, [{
536+
type: 'histogram',
537+
x: [1, 1, 1, 1, 2, 2, 2, 3, 3, 4]
538+
}, {
539+
type: 'histogram',
540+
x: [1, 1, 1, 1, 2, 2, 2, 3, 3, 4]
541+
}], {
542+
width: 400,
543+
height: 400
544+
})
545+
.then(function() {
546+
expect(gd._fullLayout.width).toBe(400);
547+
expect(gd._fullLayout.height).toBe(400);
548+
549+
gd._fullData.forEach(function(trace, i) {
550+
expect(trace._autoBinFinished).toBeUndefined(i);
551+
});
552+
553+
return Plotly.relayout(gd, {width: 500, height: 500});
554+
})
555+
.then(function() {
556+
expect(gd._fullLayout.width).toBe(500);
557+
expect(gd._fullLayout.height).toBe(500);
558+
559+
gd._fullData.forEach(function(trace, i) {
560+
expect(trace._autoBinFinished).toBeUndefined(i);
561+
});
562+
})
563+
.catch(fail)
564+
.then(done);
565+
});
533566
});
534567
});

0 commit comments

Comments
 (0)