@@ -1197,26 +1197,12 @@ describe('Plotly.react and uirevision attributes', function() {
1197
1197
} ;
1198
1198
}
1199
1199
1200
- function editModes ( ) {
1201
- return Registry . call ( '_guiRelayout' , gd , {
1202
- dragmode : 'pan' ,
1203
- hovermode : false ,
1204
- 'xaxis.showspikes' : false ,
1205
- 'yaxis.showspikes' : false ,
1206
- 'scene.dragmode' : 'pan' ,
1207
- 'scene.hovermode' : false ,
1208
- 'scene.xaxis.showspikes' : false ,
1209
- 'scene.yaxis.showspikes' : false ,
1210
- 'scene.zaxis.showspikes' : false
1211
- } ) ;
1212
- }
1213
-
1214
- function _checkModes ( original ) {
1200
+ function attrs ( original ) {
1215
1201
var dragmode = original ? 'zoom' : 'pan' ;
1216
1202
var hovermode = original ? 'closest' : false ;
1217
1203
var spikes = original ? true : false ;
1218
1204
var spikes3D = original ? [ undefined , true ] : false ;
1219
- return checkState ( [ ] , {
1205
+ return {
1220
1206
dragmode : dragmode ,
1221
1207
hovermode : hovermode ,
1222
1208
'xaxis.showspikes' : spikes ,
@@ -1226,10 +1212,15 @@ describe('Plotly.react and uirevision attributes', function() {
1226
1212
'scene.xaxis.showspikes' : spikes3D ,
1227
1213
'scene.yaxis.showspikes' : spikes3D ,
1228
1214
'scene.zaxis.showspikes' : spikes3D
1229
- } ) ;
1215
+ } ;
1230
1216
}
1231
- var checkOriginalModes = _checkModes ( true ) ;
1232
- var checkEditedModes = _checkModes ( false ) ;
1217
+
1218
+ function editModes ( ) {
1219
+ return Registry . call ( '_guiRelayout' , gd , attrs ( ) ) ;
1220
+ }
1221
+
1222
+ var checkOriginalModes = checkState ( [ ] , attrs ( true ) ) ;
1223
+ var checkEditedModes = checkState ( [ ] , attrs ( ) ) ;
1233
1224
1234
1225
_run ( fig , editModes , checkOriginalModes , checkEditedModes ) . then ( done ) ;
1235
1226
} ) ;
@@ -1247,25 +1238,21 @@ describe('Plotly.react and uirevision attributes', function() {
1247
1238
} ;
1248
1239
}
1249
1240
1250
- function editView ( ) {
1251
- return Registry . call ( '_guiRelayout' , gd , {
1252
- 'geo.projection.scale' : 3 ,
1253
- 'geo.projection.rotation.lon' : - 45 ,
1254
- 'geo.center.lat' : 22 ,
1255
- 'geo.center.lon' : - 45
1256
- } ) ;
1257
- }
1258
-
1259
- function _checkView ( original ) {
1260
- return checkState ( [ ] , {
1241
+ function attrs ( original ) {
1242
+ return {
1261
1243
'geo.projection.scale' : original ? [ undefined , 1 ] : 3 ,
1262
1244
'geo.projection.rotation.lon' : original ? [ undefined , 0 ] : - 45 ,
1263
1245
'geo.center.lat' : original ? [ undefined , 0 ] : 22 ,
1264
1246
'geo.center.lon' : original ? [ undefined , 0 ] : - 45
1265
- } ) ;
1247
+ } ;
1248
+ }
1249
+
1250
+ function editView ( ) {
1251
+ return Registry . call ( '_guiRelayout' , gd , attrs ( ) ) ;
1266
1252
}
1267
- var checkOriginalView = _checkView ( true ) ;
1268
- var checkEditedView = _checkView ( false ) ;
1253
+
1254
+ var checkOriginalView = checkState ( [ ] , attrs ( true ) ) ;
1255
+ var checkEditedView = checkState ( [ ] , attrs ( ) ) ;
1269
1256
1270
1257
_run ( fig , editView , checkOriginalView , checkEditedView ) . then ( done ) ;
1271
1258
} ) ;
@@ -1369,26 +1356,25 @@ describe('Plotly.react and uirevision attributes', function() {
1369
1356
} ;
1370
1357
}
1371
1358
1372
- function editPolar ( ) {
1373
- return Registry . call ( '_guiRelayout' , gd , {
1374
- 'polar.radialaxis.range' : [ - 2 , 4 ] ,
1375
- 'polar.radialaxis.angle' : 45 ,
1376
- 'polar.angularaxis.rotation' : - 90
1377
- } ) ;
1378
- }
1379
-
1380
- function checkPolar ( original ) {
1381
- return checkState ( [ ] , {
1359
+ function attrs ( original ) {
1360
+ return {
1382
1361
'polar.radialaxis.range[0]' : original ? 0 : - 2 ,
1383
1362
'polar.radialaxis.range[1]' : original ? 2 : 4 ,
1384
1363
'polar.radialaxis.angle' : original ? [ undefined , 0 ] : 45 ,
1385
1364
'polar.angularaxis.rotation' : original ? [ undefined , 0 ] : - 90
1386
- } ) ;
1365
+ } ;
1387
1366
}
1388
1367
1389
- _run ( fig , editPolar , checkPolar ( true ) , checkPolar ( ) )
1368
+ function editPolar ( ) {
1369
+ return Registry . call ( '_guiRelayout' , gd , attrs ( ) ) ;
1370
+ }
1371
+
1372
+ var checkInitial = checkState ( [ ] , attrs ( true ) ) ;
1373
+ var checkEdited = checkState ( [ ] , attrs ( ) ) ;
1374
+
1375
+ _run ( fig , editPolar , checkInitial , checkEdited )
1390
1376
. then ( function ( ) {
1391
- return _run ( fig2 , editPolar , checkPolar ( true ) , checkPolar ( ) ) ;
1377
+ return _run ( fig2 , editPolar , checkInitial , checkEdited ) ;
1392
1378
} )
1393
1379
. then ( done ) ;
1394
1380
} ) ;
@@ -1418,25 +1404,24 @@ describe('Plotly.react and uirevision attributes', function() {
1418
1404
} ;
1419
1405
}
1420
1406
1421
- function editTernary ( ) {
1422
- return Registry . call ( '_guiRelayout' , gd , {
1423
- 'ternary.aaxis.min' : 0.1 ,
1424
- 'ternary.baxis.min' : 0.2 ,
1425
- 'ternary.caxis.min' : 0.3
1426
- } ) ;
1427
- }
1428
-
1429
- function checkTernary ( original ) {
1430
- return checkState ( [ ] , {
1407
+ function attrs ( original ) {
1408
+ return {
1431
1409
'ternary.aaxis.min' : original ? [ undefined , 0 ] : 0.1 ,
1432
1410
'ternary.baxis.min' : original ? [ undefined , 0 ] : 0.2 ,
1433
1411
'ternary.caxis.min' : original ? [ undefined , 0 ] : 0.3 ,
1434
- } ) ;
1412
+ } ;
1413
+ }
1414
+
1415
+ function editTernary ( ) {
1416
+ return Registry . call ( '_guiRelayout' , gd , attrs ( ) ) ;
1435
1417
}
1436
1418
1437
- _run ( fig , editTernary , checkTernary ( true ) , checkTernary ( ) )
1419
+ var checkInitial = checkState ( [ ] , attrs ( true ) ) ;
1420
+ var checkEdited = checkState ( [ ] , attrs ( ) ) ;
1421
+
1422
+ _run ( fig , editTernary , checkInitial , checkEdited )
1438
1423
. then ( function ( ) {
1439
- return _run ( fig2 , editTernary , checkTernary ( true ) , checkTernary ( ) ) ;
1424
+ return _run ( fig2 , editTernary , checkInitial , checkEdited ) ;
1440
1425
} )
1441
1426
. then ( done ) ;
1442
1427
} ) ;
@@ -1452,31 +1437,28 @@ describe('Plotly.react and uirevision attributes', function() {
1452
1437
} ;
1453
1438
}
1454
1439
1455
- function editMap ( ) {
1456
- return Registry . call ( '_guiRelayout' , gd , {
1457
- 'mapbox.center.lat' : 1 ,
1458
- 'mapbox.center.lon' : 2 ,
1459
- 'mapbox.zoom' : 3 ,
1460
- 'mapbox.bearing' : 4 ,
1461
- 'mapbox.pitch' : 5
1462
- } ) ;
1463
- }
1464
-
1465
- function checkMapbox ( original ) {
1466
- return checkState ( [ ] , {
1440
+ function attrs ( original ) {
1441
+ return {
1467
1442
'mapbox.center.lat' : original ? [ undefined , 0 ] : 1 ,
1468
1443
'mapbox.center.lon' : original ? [ undefined , 0 ] : 2 ,
1469
1444
'mapbox.zoom' : original ? [ undefined , 1 ] : 3 ,
1470
1445
'mapbox.bearing' : original ? [ undefined , 0 ] : 4 ,
1471
1446
'mapbox.pitch' : original ? [ undefined , 0 ] : 5
1472
- } ) ;
1447
+ } ;
1448
+ }
1449
+
1450
+ function editMap ( ) {
1451
+ return Registry . call ( '_guiRelayout' , gd , attrs ( ) ) ;
1473
1452
}
1474
1453
1454
+ var checkInitial = checkState ( [ ] , attrs ( true ) ) ;
1455
+ var checkEdited = checkState ( [ ] , attrs ( ) ) ;
1456
+
1475
1457
Plotly . setPlotConfig ( {
1476
1458
mapboxAccessToken : MAPBOX_ACCESS_TOKEN
1477
1459
} ) ;
1478
1460
1479
- _run ( fig , editMap , checkMapbox ( true ) , checkMapbox ( ) ) . then ( done ) ;
1461
+ _run ( fig , editMap , checkInitial , checkEdited ) . then ( done ) ;
1480
1462
} ) ;
1481
1463
1482
1464
it ( 'preserves editable: true shape & annotation edits using editrevision' , function ( done ) {
0 commit comments