Skip to content

Commit 10d6836

Browse files
committed
adding tests for fancy vs non-fancy scattergl
1 parent 55157e5 commit 10d6836

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

test/jasmine/tests/axes_test.js

+79
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ var Plots = require('@src/plots/plots');
44
var Lib = require('@src/lib');
55
var Color = require('@src/components/color');
66
var tinycolor = require('tinycolor2');
7+
var hasWebGLSupport = require('../assets/has_webgl_support');
78

89
var handleTickValueDefaults = require('@src/plots/cartesian/tick_value_defaults');
910
var Axes = PlotlyInternal.Axes;
@@ -387,6 +388,84 @@ describe('Test axes', function() {
387388
});
388389
});
389390

391+
describe('date axis', function() {
392+
393+
if(!hasWebGLSupport('axes_test date axis')) return;
394+
395+
var gd;
396+
397+
beforeEach(function() {
398+
gd = createGraphDiv();
399+
});
400+
401+
afterEach(destroyGraphDiv);
402+
403+
it('should use the fancy gl-vis/gl-scatter2d', function() {
404+
PlotlyInternal.plot(gd, [{
405+
type: 'scattergl',
406+
'marker': {
407+
'color': 'rgb(31, 119, 180)',
408+
'size': 18,
409+
'symbol': [
410+
'diamond',
411+
'cross'
412+
]
413+
},
414+
x: [new Date('2016-10-10'), new Date('2016-10-12')],
415+
y: [15, 16]
416+
}]);
417+
418+
expect(gd._fullLayout.xaxis.type).toBe('date');
419+
expect(gd._fullLayout.yaxis.type).toBe('linear');
420+
expect(gd._fullData[0].type).toBe('scattergl');
421+
expect(gd._fullData[0]._module.basePlotModule.name).toBe('gl2d');
422+
423+
// one way of check which renderer - fancy vs not - we're using
424+
expect(gd._fullLayout._plots.xy._scene2d.glplot.objects[3].pointCount).toBe(0);
425+
});
426+
427+
it('should use the fancy gl-vis/gl-scatter2d once again', function() {
428+
PlotlyInternal.plot(gd, [{
429+
type: 'scattergl',
430+
'marker': {
431+
'color': 'rgb(31, 119, 180)',
432+
'size': 36,
433+
'symbol': [
434+
'circle',
435+
'cross'
436+
]
437+
},
438+
x: [new Date('2016-10-10'), new Date('2016-10-11')],
439+
y: [15, 16]
440+
}]);
441+
442+
expect(gd._fullLayout.xaxis.type).toBe('date');
443+
expect(gd._fullLayout.yaxis.type).toBe('linear');
444+
expect(gd._fullData[0].type).toBe('scattergl');
445+
expect(gd._fullData[0]._module.basePlotModule.name).toBe('gl2d');
446+
447+
// one way of check which renderer - fancy vs not - we're using
448+
expect(gd._fullLayout._plots.xy._scene2d.glplot.objects[3].pointCount).toBe(0);
449+
});
450+
451+
it('should now use the non-fancy gl-vis/gl-scatter2d', function() {
452+
PlotlyInternal.plot(gd, [{
453+
type: 'scattergl',
454+
mode: 'markers', // important, as otherwise lines are assumed (which needs fancy)
455+
x: [new Date('2016-10-10'), new Date('2016-10-11')],
456+
y: [15, 16]
457+
}]);
458+
459+
expect(gd._fullLayout.xaxis.type).toBe('date');
460+
expect(gd._fullLayout.yaxis.type).toBe('linear');
461+
expect(gd._fullData[0].type).toBe('scattergl');
462+
expect(gd._fullData[0]._module.basePlotModule.name).toBe('gl2d');
463+
464+
expect(gd._fullLayout._plots.xy._scene2d.glplot.objects[3].pointCount).toBe(2);
465+
});
466+
467+
});
468+
390469
describe('categoryorder', function() {
391470

392471
var gd;

0 commit comments

Comments
 (0)