-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathgl2d_date_axis_render_test.js
105 lines (89 loc) · 3.61 KB
/
gl2d_date_axis_render_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
var Plotly = require('@lib');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
describe('date axis', function() {
var gd;
beforeEach(function() {
gd = createGraphDiv();
});
afterEach(destroyGraphDiv);
it('@gl should use the fancy gl-vis/gl-scatter2d', function() {
Plotly.plot(gd, [{
type: 'scattergl',
'marker': {
'color': 'rgb(31, 119, 180)',
'size': 18,
'symbol': [
'diamond',
'cross'
]
},
x: [new Date('2016-10-10'), new Date('2016-10-12')],
y: [15, 16]
}]);
expect(gd._fullLayout.xaxis.type).toBe('date');
expect(gd._fullLayout.yaxis.type).toBe('linear');
expect(gd._fullData[0].type).toBe('scattergl');
expect(gd._fullData[0]._module.basePlotModule.name).toBe('cartesian');
// one way of check which renderer - fancy vs not - we're
var scene = gd._fullLayout._plots.xy._scene;
expect(scene.scatter2d).toBeDefined();
expect(scene.markerOptions[0].positions.length).toEqual(4);
expect(scene.line2d).not.toBeUndefined();
});
it('@gl should use the fancy gl-vis/gl-scatter2d once again', function() {
Plotly.plot(gd, [{
type: 'scattergl',
'marker': {
'color': 'rgb(31, 119, 180)',
'size': 36,
'symbol': [
'circle',
'cross'
]
},
x: [new Date('2016-10-10'), new Date('2016-10-11')],
y: [15, 16]
}]);
expect(gd._fullLayout.xaxis.type).toBe('date');
expect(gd._fullLayout.yaxis.type).toBe('linear');
expect(gd._fullData[0].type).toBe('scattergl');
expect(gd._fullData[0]._module.basePlotModule.name).toBe('cartesian');
var scene = gd._fullLayout._plots.xy._scene;
expect(scene.scatter2d).toBeDefined();
expect(scene.markerOptions[0].positions.length).toEqual(4);
expect(scene.line2d).toBeDefined();
});
it('@gl should now use the non-fancy gl-vis/gl-scatter2d', function() {
Plotly.plot(gd, [{
type: 'scattergl',
mode: 'markers',
x: [new Date('2016-10-10'), new Date('2016-10-11')],
y: [15, 16]
}]);
expect(gd._fullLayout.xaxis.type).toBe('date');
expect(gd._fullLayout.yaxis.type).toBe('linear');
expect(gd._fullData[0].type).toBe('scattergl');
expect(gd._fullData[0]._module.basePlotModule.name).toBe('cartesian');
var scene = gd._fullLayout._plots.xy._scene;
expect(scene.scatter2d).toBeDefined();
expect(scene.markerOptions[0].positions.length).toEqual(4);
expect(scene.line2d).toBeDefined();
});
it('@gl should use the non-fancy gl-vis/gl-scatter2d with string dates', function() {
Plotly.plot(gd, [{
type: 'scattergl',
mode: 'markers',
x: ['2016-10-10', '2016-10-11'],
y: [15, 16]
}]);
expect(gd._fullLayout.xaxis.type).toBe('date');
expect(gd._fullLayout.yaxis.type).toBe('linear');
expect(gd._fullData[0].type).toBe('scattergl');
expect(gd._fullData[0]._module.basePlotModule.name).toBe('cartesian');
var scene = gd._fullLayout._plots.xy._scene;
expect(scene.scatter2d).toBeDefined();
expect(scene.markerOptions[0].positions.length).toEqual(4);
expect(scene.line2d).toBeDefined();
});
});