Skip to content

Commit 42805c2

Browse files
committed
test histogram changing data type
closes plotly/streambed#8975 (but the fix was earlier in this PR)
1 parent a107466 commit 42805c2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/jasmine/tests/histogram_test.js

+17
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,10 @@ describe('Test histogram', function() {
463463
describe('plot / restyle', function() {
464464
var gd;
465465

466+
beforeAll(function() {
467+
jasmine.addMatchers(customMatchers);
468+
});
469+
466470
beforeEach(function() {
467471
gd = createGraphDiv();
468472
});
@@ -513,5 +517,18 @@ describe('Test histogram', function() {
513517
expect(gd._fullData[0].xbins).toEqual({start: 1, end: 6, size: 1});
514518
expect(gd._fullData[0].autobinx).toBe(false);
515519
});
520+
521+
it('allows changing axis type with new x data', function() {
522+
var x1 = [1, 1, 1, 1, 2, 2, 2, 3, 3, 4];
523+
var x2 = ['2017-01-01', '2017-01-01', '2017-01-01', '2017-01-02', '2017-01-02', '2017-01-03'];
524+
525+
Plotly.newPlot(gd, [{x: x1, type: 'histogram'}]);
526+
expect(gd._fullLayout.xaxis.type).toBe('linear');
527+
expect(gd._fullLayout.xaxis.range).toBeCloseToArray([0.5, 4.5], 3);
528+
529+
Plotly.restyle(gd, {x: [x2]});
530+
expect(gd._fullLayout.xaxis.type).toBe('date');
531+
expect(gd._fullLayout.xaxis.range).toEqual(['2016-12-31 12:00', '2017-01-03 12:00']);
532+
});
516533
});
517534
});

0 commit comments

Comments
 (0)