Skip to content

Commit a11ec44

Browse files
committed
add _gui(Restyle|Relayout|Update) and _storeDirectGUIEdit and track changes
1 parent c62cf25 commit a11ec44

File tree

23 files changed

+235
-99
lines changed

23 files changed

+235
-99
lines changed

Diff for: src/components/annotations/draw.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
584584
});
585585
},
586586
doneFn: function() {
587-
Registry.call('relayout', gd, getUpdateObj());
587+
Registry.call('_guiRelayout', gd, getUpdateObj());
588588
var notesBox = document.querySelector('.js-notes-box-panel');
589589
if(notesBox) notesBox.redraw(notesBox.selectedObj);
590590
}
@@ -667,7 +667,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
667667
},
668668
doneFn: function() {
669669
setCursor(annTextGroupInner);
670-
Registry.call('relayout', gd, getUpdateObj());
670+
Registry.call('_guiRelayout', gd, getUpdateObj());
671671
var notesBox = document.querySelector('.js-notes-box-panel');
672672
if(notesBox) notesBox.redraw(notesBox.selectedObj);
673673
}
@@ -691,7 +691,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
691691
modifyBase(ya._name + '.autorange', true);
692692
}
693693

694-
Registry.call('relayout', gd, getUpdateObj());
694+
Registry.call('_guiRelayout', gd, getUpdateObj());
695695
});
696696
}
697697
else annText.call(textLayout);

Diff for: src/components/colorbar/draw.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ module.exports = function draw(gd, id) {
627627
setCursor(container);
628628

629629
if(xf !== undefined && yf !== undefined) {
630-
Registry.call('restyle',
630+
Registry.call('_guiRestyle',
631631
gd,
632632
{'colorbar.x': xf, 'colorbar.y': yf},
633633
getTrace().index

Diff for: src/components/legend/draw.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ module.exports = function draw(gd) {
339339
},
340340
doneFn: function() {
341341
if(xf !== undefined && yf !== undefined) {
342-
Registry.call('relayout', gd, {'legend.x': xf, 'legend.y': yf});
342+
Registry.call('_guiRelayout', gd, {'legend.x': xf, 'legend.y': yf});
343343
}
344344
},
345345
clickFn: function(numClicks, e) {
@@ -446,7 +446,7 @@ function drawTexts(g, gd, maxLength) {
446446
update.name = newName;
447447
}
448448

449-
return Registry.call('restyle', gd, update, traceIndex);
449+
return Registry.call('_guiRestyle', gd, update, traceIndex);
450450
});
451451
} else {
452452
textLayout(textEl);

Diff for: src/components/legend/handle_click.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module.exports = function handleClick(g, gd, numClicks) {
111111
}
112112
}
113113

114-
Registry.call('relayout', gd, 'hiddenlabels', hiddenSlices);
114+
Registry.call('_guiRelayout', gd, 'hiddenlabels', hiddenSlices);
115115
} else {
116116
var hasLegendgroup = legendgroup && legendgroup.length;
117117
var traceIndicesInGroup = [];
@@ -217,6 +217,6 @@ module.exports = function handleClick(g, gd, numClicks) {
217217
}
218218
}
219219

220-
Registry.call('restyle', gd, attrUpdate, attrIndices);
220+
Registry.call('_guiRestyle', gd, attrUpdate, attrIndices);
221221
}
222222
};

Diff for: src/components/modebar/buttons.js

+9-9
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ function handleCartesian(gd, ev) {
261261
aobj[astr] = val;
262262
}
263263

264-
Registry.call('relayout', gd, aobj);
264+
Registry.call('_guiRelayout', gd, aobj);
265265
}
266266

267267
modeBarButtons.zoom3d = {
@@ -317,7 +317,7 @@ function handleDrag3d(gd, ev) {
317317
var val2d = (val === 'pan') ? val : 'zoom';
318318
layoutUpdate.dragmode = val2d;
319319

320-
Registry.call('relayout', gd, layoutUpdate);
320+
Registry.call('_guiRelayout', gd, layoutUpdate);
321321
}
322322

323323
modeBarButtons.resetCameraDefault3d = {
@@ -356,7 +356,7 @@ function handleCamera3d(gd, ev) {
356356
}
357357
}
358358

359-
Registry.call('relayout', gd, aobj);
359+
Registry.call('_guiRelayout', gd, aobj);
360360
}
361361

362362
modeBarButtons.hoverClosest3d = {
@@ -411,7 +411,7 @@ function getNextHover3d(gd, ev) {
411411

412412
function handleHover3d(gd, ev) {
413413
var layoutUpdate = getNextHover3d(gd, ev);
414-
Registry.call('relayout', gd, layoutUpdate);
414+
Registry.call('_guiRelayout', gd, layoutUpdate);
415415
}
416416

417417
modeBarButtons.zoomInGeo = {
@@ -467,7 +467,7 @@ function handleGeo(gd, ev) {
467467
var scale = geoLayout.projection.scale;
468468
var newScale = (val === 'in') ? 2 * scale : 0.5 * scale;
469469

470-
Registry.call('relayout', gd, id + '.projection.scale', newScale);
470+
Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale);
471471
} else if(attr === 'reset') {
472472
resetView(gd, 'geo');
473473
}
@@ -508,7 +508,7 @@ function getNextHover(gd) {
508508

509509
function toggleHover(gd) {
510510
var newHover = getNextHover(gd);
511-
Registry.call('relayout', gd, 'hovermode', newHover);
511+
Registry.call('_guiRelayout', gd, 'hovermode', newHover);
512512
}
513513

514514
// buttons when more then one plot types are present
@@ -525,7 +525,7 @@ modeBarButtons.toggleHover = {
525525
var layoutUpdate = getNextHover3d(gd, ev);
526526
layoutUpdate.hovermode = getNextHover(gd);
527527

528-
Registry.call('relayout', gd, layoutUpdate);
528+
Registry.call('_guiRelayout', gd, layoutUpdate);
529529
}
530530
};
531531

@@ -561,7 +561,7 @@ modeBarButtons.toggleSpikelines = {
561561

562562
var aobj = setSpikelineVisibility(gd);
563563

564-
Registry.call('relayout', gd, aobj);
564+
Registry.call('_guiRelayout', gd, aobj);
565565
}
566566
};
567567

@@ -608,5 +608,5 @@ function resetView(gd, subplotType) {
608608
}
609609
}
610610

611-
Registry.call('relayout', gd, aObj);
611+
Registry.call('_guiRelayout', gd, aObj);
612612
}

Diff for: src/components/rangeselector/draw.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ module.exports = function draw(gd) {
6969
button.on('click', function() {
7070
if(gd._dragged) return;
7171

72-
Registry.call('relayout', gd, update);
72+
Registry.call('_guiRelayout', gd, update);
7373
});
7474

7575
button.on('mouseover', function() {

Diff for: src/components/rangeslider/draw.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,10 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) {
286286
dataMax = clamp(opts.p2d(opts._pixelMax));
287287

288288
window.requestAnimationFrame(function() {
289-
Registry.call('relayout', gd, axisOpts._name + '.range', [dataMin, dataMax]);
289+
var update = {};
290+
update[axisOpts._name + '.range[0]'] = dataMin;
291+
update[axisOpts._name + '.range[1]'] = dataMax;
292+
Registry.call('_guiRelayout', gd, update);
290293
});
291294
}
292295

Diff for: src/components/shapes/draw.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) {
306306

307307
// Don't rely on clipPath being activated during re-layout
308308
setClipPath(shapePath, gd, shapeOptions);
309-
Registry.call('relayout', gd, editHelpers.getUpdateObj());
309+
Registry.call('_guiRelayout', gd, editHelpers.getUpdateObj());
310310
}
311311

312312
function abortDrag() {

Diff for: src/components/titles/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ function draw(gd, titleClass, options) {
237237
el.call(svgTextUtils.makeEditable, {gd: gd})
238238
.on('edit', function(text) {
239239
if(traceIndex !== undefined) {
240-
Registry.call('restyle', gd, prop, text, traceIndex);
240+
Registry.call('_guiRestyle', gd, prop, text, traceIndex);
241241
} else {
242-
Registry.call('relayout', gd, prop, text);
242+
Registry.call('_guiRelayout', gd, prop, text);
243243
}
244244
})
245245
.on('cancel', function() {

Diff for: src/core.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ var plotApi = require('./plot_api');
2929
var methodNames = Object.keys(plotApi);
3030
for(var i = 0; i < methodNames.length; i++) {
3131
var name = methodNames[i];
32-
exports[name] = plotApi[name];
32+
// _ -> private API methods, but still registered for internal use
33+
if(name.charAt(0) !== '_') exports[name] = plotApi[name];
3334
register({
3435
moduleType: 'apiMethod',
3536
name: name,

Diff for: src/plot_api/index.js

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ exports.restyle = main.restyle;
1616
exports.relayout = main.relayout;
1717
exports.redraw = main.redraw;
1818
exports.update = main.update;
19+
exports._guiRestyle = main._guiRestyle;
20+
exports._guiRelayout = main._guiRelayout;
21+
exports._guiUpdate = main._guiUpdate;
22+
exports._storeDirectGUIEdit = main._storeDirectGUIEdit;
1923
exports.react = main.react;
2024
exports.extendTraces = main.extendTraces;
2125
exports.prependTraces = main.prependTraces;

0 commit comments

Comments
 (0)