Skip to content

Commit 8796f1b

Browse files
committed
5291: changed tests to do dynamic transforms
1 parent 3b9071f commit 8796f1b

File tree

5 files changed

+105
-37
lines changed

5 files changed

+105
-37
lines changed

src/plots/polar/polar.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,8 +680,8 @@ proto.updateMainDrag = function(fullLayout) {
680680
var chw = constants.cornerHalfWidth;
681681
var chl = constants.cornerLen / 2;
682682

683-
var scaleX = gd._fullLayout._inverseScaleX;
684-
var scaleY = gd._fullLayout._inverseScaleY;
683+
var scaleX;
684+
var scaleY;
685685

686686
var mainDrag = dragBox.makeDragger(layers, 'path', 'maindrag', 'crosshair');
687687

@@ -943,8 +943,10 @@ proto.updateMainDrag = function(fullLayout) {
943943
var dragModeNow = gd._fullLayout.dragmode;
944944

945945
var bbox = mainDrag.getBoundingClientRect();
946-
var inverse = gd._fullLayout._inverseTransform;
947946
gd._fullLayout._calcInverseTransform(gd);
947+
var inverse = gd._fullLayout._inverseTransform;
948+
scaleX = gd._fullLayout._inverseScaleX;
949+
scaleY = gd._fullLayout._inverseScaleY;
948950
var transformedCoords = Lib.apply3DTransform(inverse)(startX - bbox.left, startY - bbox.top);
949951
x0 = transformedCoords[0];
950952
y0 = transformedCoords[1];

test/jasmine/tests/cartesian_interact_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2519,8 +2519,8 @@ describe('Cartesian plots with css transforms', function() {
25192519
var start = [50, 50];
25202520
var end = [150, 150];
25212521

2522-
transformPlot(gd, transform);
25232522
Plotly.newPlot(gd, Lib.extendDeep({}, mock))
2523+
.then(function() { transformPlot(gd, transform); })
25242524
.then(function() {_drag(start, end); })
25252525
.then(function() {
25262526
_assertTransformedZoombox(start, end);

test/jasmine/tests/choropleth_test.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,6 @@ describe('Test choropleth hover:', function() {
167167
function run(hasCssTransform, pos, fig, content, style) {
168168
gd = createGraphDiv();
169169
var scale = 1;
170-
if(hasCssTransform) {
171-
scale = 0.5;
172-
transformPlot(gd, 'translate(-25%, -25%) scale(0.5)');
173-
}
174170

175171
style = style || {
176172
bgcolor: 'rgb(68, 68, 68)',
@@ -180,7 +176,14 @@ describe('Test choropleth hover:', function() {
180176
fontFamily: 'Arial'
181177
};
182178

183-
return Plotly.plot(gd, fig).then(function() {
179+
return Plotly.plot(gd, fig)
180+
.then(function() {
181+
if(hasCssTransform) {
182+
scale = 0.5;
183+
transformPlot(gd, 'translate(-25%, -25%) scale(0.5)');
184+
}
185+
})
186+
.then(function() {
184187
mouseEvent('mousemove', scale * pos[0], scale * pos[1]);
185188
assertHoverLabelContent({
186189
nums: content[0],

test/jasmine/tests/select_test.js

Lines changed: 88 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,7 +1851,7 @@ describe('Test select box and lasso per trace:', function() {
18511851
dblClickPos = dblClickPos || [250, 200];
18521852

18531853
var scale = 1;
1854-
if(hasCssTransform) {
1854+
if (hasCssTransform){
18551855
scale = 0.5;
18561856
}
18571857
dblClickPos[0] *= scale;
@@ -1894,8 +1894,12 @@ describe('Test select box and lasso per trace:', function() {
18941894
fig.layout.dragmode = 'select';
18951895
addInvisible(fig);
18961896

1897-
if(hasCssTransform) transformPlot(gd, cssTransform);
1898-
Plotly.plot(gd, fig).then(function() {
1897+
Plotly.plot(gd, fig)
1898+
.then(function() {
1899+
if (hasCssTransform)
1900+
transformPlot(gd, cssTransform);
1901+
})
1902+
.then(function() {
18991903
return _run(hasCssTransform,
19001904
[[400, 200], [445, 235]],
19011905
function() {
@@ -1950,8 +1954,12 @@ describe('Test select box and lasso per trace:', function() {
19501954
fig.layout.dragmode = 'select';
19511955
addInvisible(fig);
19521956

1953-
if(hasCssTransform) transformPlot(gd, cssTransform);
1954-
Plotly.plot(gd, fig).then(function() {
1957+
Plotly.plot(gd, fig)
1958+
.then(function() {
1959+
if (hasCssTransform)
1960+
transformPlot(gd, cssTransform);
1961+
})
1962+
.then(function() {
19551963
return _run(hasCssTransform,
19561964
[[300, 200], [400, 250]],
19571965
function() {
@@ -1997,7 +2005,7 @@ describe('Test select box and lasso per trace:', function() {
19972005
};
19982006
addInvisible(fig);
19992007

2000-
if(hasCssTransform) transformPlot(gd, cssTransform);
2008+
if (hasCssTransform)transformPlot(gd, cssTransform);
20012009
Plotly.plot(gd, fig).then(function() {
20022010
return _run(hasCssTransform,
20032011
[[370, 120], [500, 200]],
@@ -2056,8 +2064,12 @@ describe('Test select box and lasso per trace:', function() {
20562064
};
20572065
addInvisible(fig);
20582066

2059-
if(hasCssTransform) transformPlot(gd, cssTransform);
2060-
Plotly.plot(gd, fig).then(function() {
2067+
Plotly.plot(gd, fig)
2068+
.then(function() {
2069+
if (hasCssTransform)
2070+
transformPlot(gd, cssTransform);
2071+
})
2072+
.then(function() {
20612073
return _run(hasCssTransform,
20622074
[[150, 150], [300, 300]],
20632075
function() {
@@ -2128,8 +2140,11 @@ describe('Test select box and lasso per trace:', function() {
21282140
};
21292141
addInvisible(fig);
21302142

2131-
if(hasCssTransform) transformPlot(gd, cssTransform);
21322143
Plotly.plot(gd, fig)
2144+
.then(function() {
2145+
if (hasCssTransform)
2146+
transformPlot(gd, cssTransform);
2147+
})
21332148
.then(function() {
21342149
return _run(hasCssTransform,
21352150
[[350, 200], [450, 400]],
@@ -2202,8 +2217,12 @@ describe('Test select box and lasso per trace:', function() {
22022217
fig.layout.dragmode = 'select';
22032218
addInvisible(fig);
22042219

2205-
if(hasCssTransform) transformPlot(gd, cssTransform);
2206-
Plotly.plot(gd, fig).then(function() {
2220+
Plotly.plot(gd, fig)
2221+
.then(function() {
2222+
if (hasCssTransform)
2223+
transformPlot(gd, cssTransform);
2224+
})
2225+
.then(function() {
22072226
return _run(hasCssTransform,
22082227
[[150, 150], [350, 250]],
22092228
function() {
@@ -2245,8 +2264,12 @@ describe('Test select box and lasso per trace:', function() {
22452264
fig.layout.dragmode = 'select';
22462265
addInvisible(fig);
22472266

2248-
if(hasCssTransform) transformPlot(gd, cssTransform);
2249-
Plotly.plot(gd, fig).then(function() {
2267+
Plotly.plot(gd, fig)
2268+
.then(function() {
2269+
if (hasCssTransform)
2270+
transformPlot(gd, cssTransform);
2271+
})
2272+
.then(function() {
22502273
return _run(hasCssTransform,
22512274
[[150, 150], [250, 250]],
22522275
function() {
@@ -2313,8 +2336,11 @@ describe('Test select box and lasso per trace:', function() {
23132336
emptyChoroplethTrace.z = [];
23142337
fig.data.push(emptyChoroplethTrace);
23152338

2316-
if(hasCssTransform) transformPlot(gd, cssTransform);
23172339
Plotly.plot(gd, fig)
2340+
.then(function() {
2341+
if (hasCssTransform)
2342+
transformPlot(gd, cssTransform);
2343+
})
23182344
.then(function() {
23192345
return _run(hasCssTransform,
23202346
[[350, 200], [400, 250]],
@@ -2369,8 +2395,11 @@ describe('Test select box and lasso per trace:', function() {
23692395
fig.layout.dragmode = 'lasso';
23702396
addInvisible(fig);
23712397

2372-
if(hasCssTransform) transformPlot(gd, cssTransform);
23732398
Plotly.plot(gd, fig)
2399+
.then(function() {
2400+
if (hasCssTransform)
2401+
transformPlot(gd, cssTransform);
2402+
})
23742403
.then(function() {
23752404
return _run(hasCssTransform,
23762405
[[400, 300], [200, 400], [400, 500], [600, 400], [500, 350]],
@@ -2430,8 +2459,11 @@ describe('Test select box and lasso per trace:', function() {
24302459
fig.layout.dragmode = 'lasso';
24312460
addInvisible(fig);
24322461

2433-
if(hasCssTransform) transformPlot(gd, cssTransform);
24342462
Plotly.plot(gd, fig)
2463+
.then(function() {
2464+
if (hasCssTransform)
2465+
transformPlot(gd, cssTransform);
2466+
})
24352467
.then(function() {
24362468
return _run(hasCssTransform,
24372469
[[400, 300], [200, 400], [400, 500], [600, 400], [500, 350]],
@@ -2493,8 +2525,11 @@ describe('Test select box and lasso per trace:', function() {
24932525
fig.layout.dragmode = 'lasso';
24942526
addInvisible(fig);
24952527

2496-
if(hasCssTransform) transformPlot(gd, cssTransform);
24972528
Plotly.plot(gd, fig)
2529+
.then(function() {
2530+
if (hasCssTransform)
2531+
transformPlot(gd, cssTransform);
2532+
})
24982533
.then(function() {
24992534
return _run(hasCssTransform,
25002535
[[350, 200], [400, 200], [400, 250], [350, 250], [350, 200]],
@@ -2600,8 +2635,11 @@ describe('Test select box and lasso per trace:', function() {
26002635
var x1 = 250;
26012636
var y1 = 250;
26022637

2603-
if(hasCssTransform) transformPlot(gd, cssTransform);
26042638
Plotly.plot(gd, fig)
2639+
.then(function() {
2640+
if (hasCssTransform)
2641+
transformPlot(gd, cssTransform);
2642+
})
26052643
.then(function() {
26062644
return _run(hasCssTransform,
26072645
[[x0, y0], [x1, y0], [x1, y1], [x0, y1], [x0, y0]],
@@ -2649,8 +2687,11 @@ describe('Test select box and lasso per trace:', function() {
26492687
fig.layout.height = 500;
26502688
addInvisible(fig);
26512689

2652-
if(hasCssTransform) transformPlot(gd, cssTransform);
26532690
Plotly.plot(gd, fig)
2691+
.then(function() {
2692+
if (hasCssTransform)
2693+
transformPlot(gd, cssTransform);
2694+
})
26542695
.then(function() {
26552696
return _run(hasCssTransform,
26562697
[[200, 200], [400, 200], [400, 350], [200, 350], [200, 200]],
@@ -2705,8 +2746,11 @@ describe('Test select box and lasso per trace:', function() {
27052746
fig.layout.xaxis = {range: [-0.565, 1.5]};
27062747
addInvisible(fig);
27072748

2708-
if(hasCssTransform) transformPlot(gd, cssTransform);
27092749
Plotly.plot(gd, fig)
2750+
.then(function() {
2751+
if (hasCssTransform)
2752+
transformPlot(gd, cssTransform);
2753+
})
27102754
.then(function() {
27112755
return _run(hasCssTransform,
27122756
[[200, 200], [400, 200], [400, 350], [200, 350], [200, 200]],
@@ -2778,8 +2822,11 @@ describe('Test select box and lasso per trace:', function() {
27782822
}
27792823
};
27802824

2781-
if(hasCssTransform) transformPlot(gd, cssTransform);
27822825
Plotly.plot(gd, fig)
2826+
.then(function() {
2827+
if (hasCssTransform)
2828+
transformPlot(gd, cssTransform);
2829+
})
27832830
.then(function() {
27842831
return _run(hasCssTransform,
27852832
[[200, 200], [400, 200], [400, 350], [200, 350], [200, 200]],
@@ -2821,8 +2868,11 @@ describe('Test select box and lasso per trace:', function() {
28212868
fig.layout.height = 500;
28222869
addInvisible(fig);
28232870

2824-
if(hasCssTransform) transformPlot(gd, cssTransform);
28252871
Plotly.plot(gd, fig)
2872+
.then(function() {
2873+
if (hasCssTransform)
2874+
transformPlot(gd, cssTransform);
2875+
})
28262876
.then(function() {
28272877
return _run(hasCssTransform,
28282878
[[200, 200], [400, 200], [400, 350], [200, 350], [200, 200]],
@@ -2903,7 +2953,6 @@ describe('Test select box and lasso per trace:', function() {
29032953
return unselected;
29042954
}
29052955

2906-
if(hasCssTransform) transformPlot(gd, cssTransform);
29072956
Plotly.newPlot(gd, [{
29082957
type: type,
29092958
x: ['2011-01-02', '2011-01-03', '2011-01-04'],
@@ -2918,6 +2967,10 @@ describe('Test select box and lasso per trace:', function() {
29182967
yaxis: {range: [-3, 9]},
29192968
dragmode: 'lasso'
29202969
})
2970+
.then(function() {
2971+
if (hasCssTransform)
2972+
transformPlot(gd, cssTransform);
2973+
})
29212974
.then(function() {
29222975
return _run(hasCssTransform,
29232976
[[l0, t], [l0, b], [r0, b], [r0, t], [l0, t]],
@@ -2958,7 +3011,6 @@ describe('Test select box and lasso per trace:', function() {
29583011
it('@flaky should work on traces with enabled transforms, hasCssTransform: ' + hasCssTransform, function(done) {
29593012
var assertSelectedPoints = makeAssertSelectedPoints();
29603013

2961-
if(hasCssTransform) transformPlot(gd, cssTransform);
29623014
Plotly.plot(gd, [{
29633015
x: [1, 2, 3, 4, 5],
29643016
y: [2, 3, 1, 7, 9],
@@ -2985,6 +3037,10 @@ describe('Test select box and lasso per trace:', function() {
29853037
height: 400,
29863038
margin: {l: 0, t: 0, r: 0, b: 0}
29873039
})
3040+
.then(function() {
3041+
if (hasCssTransform)
3042+
transformPlot(gd, cssTransform);
3043+
})
29883044
.then(function() {
29893045
return _run(hasCssTransform,
29903046
[[5, 5], [395, 395]],
@@ -3015,7 +3071,6 @@ describe('Test select box and lasso per trace:', function() {
30153071
});
30163072
}
30173073

3018-
if(hasCssTransform) transformPlot(gd, cssTransform);
30193074
Plotly.plot(gd, [{
30203075
mode: 'markers+text',
30213076
x: [1, 2, 3],
@@ -3035,6 +3090,10 @@ describe('Test select box and lasso per trace:', function() {
30353090
height: 400,
30363091
margin: {l: 0, t: 0, r: 0, b: 0}
30373092
})
3093+
.then(function() {
3094+
if (hasCssTransform)
3095+
transformPlot(gd, cssTransform);
3096+
})
30383097
.then(function() {
30393098
return _run(hasCssTransform,
30403099
[[10, 10], [100, 300]],
@@ -3062,8 +3121,11 @@ describe('Test select box and lasso per trace:', function() {
30623121
fig.layout.dragmode = 'select';
30633122
var dblClickPos = [250, 400];
30643123

3065-
if(hasCssTransform) transformPlot(gd, cssTransform);
30663124
Plotly.plot(gd, fig)
3125+
.then(function() {
3126+
if (hasCssTransform)
3127+
transformPlot(gd, cssTransform);
3128+
})
30673129
.then(function() {
30683130
// No groups initially
30693131
expect(gd._fullData[0].node.groups).toEqual([]);

test/jasmine/tests/ternary_test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,9 @@ describe('ternary plots when css transform is present', function() {
585585

586586
var mockCopy = Lib.extendDeep({}, mock);
587587

588-
transformPlot(gd, cssTransform);
589-
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(done);
588+
Plotly.plot(gd, mockCopy.data, mockCopy.layout)
589+
.then(function() { transformPlot(gd, cssTransform); })
590+
.then(done);
590591
});
591592

592593
it('should respond zoom drag interactions', function(done) {

0 commit comments

Comments
 (0)