Skip to content

Commit

Permalink
add _gui(Restyle|Relayout|Update) and _storeDirectGUIEdit and track c…
Browse files Browse the repository at this point in the history
…hanges
  • Loading branch information
alexcjohnson committed Nov 9, 2018
1 parent c62cf25 commit a11ec44
Show file tree
Hide file tree
Showing 23 changed files with 235 additions and 99 deletions.
6 changes: 3 additions & 3 deletions src/components/annotations/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
});
},
doneFn: function() {
Registry.call('relayout', gd, getUpdateObj());
Registry.call('_guiRelayout', gd, getUpdateObj());
var notesBox = document.querySelector('.js-notes-box-panel');
if(notesBox) notesBox.redraw(notesBox.selectedObj);
}
Expand Down Expand Up @@ -667,7 +667,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
},
doneFn: function() {
setCursor(annTextGroupInner);
Registry.call('relayout', gd, getUpdateObj());
Registry.call('_guiRelayout', gd, getUpdateObj());
var notesBox = document.querySelector('.js-notes-box-panel');
if(notesBox) notesBox.redraw(notesBox.selectedObj);
}
Expand All @@ -691,7 +691,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) {
modifyBase(ya._name + '.autorange', true);
}

Registry.call('relayout', gd, getUpdateObj());
Registry.call('_guiRelayout', gd, getUpdateObj());
});
}
else annText.call(textLayout);
Expand Down
2 changes: 1 addition & 1 deletion src/components/colorbar/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ module.exports = function draw(gd, id) {
setCursor(container);

if(xf !== undefined && yf !== undefined) {
Registry.call('restyle',
Registry.call('_guiRestyle',
gd,
{'colorbar.x': xf, 'colorbar.y': yf},
getTrace().index
Expand Down
4 changes: 2 additions & 2 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ module.exports = function draw(gd) {
},
doneFn: function() {
if(xf !== undefined && yf !== undefined) {
Registry.call('relayout', gd, {'legend.x': xf, 'legend.y': yf});
Registry.call('_guiRelayout', gd, {'legend.x': xf, 'legend.y': yf});
}
},
clickFn: function(numClicks, e) {
Expand Down Expand Up @@ -446,7 +446,7 @@ function drawTexts(g, gd, maxLength) {
update.name = newName;
}

return Registry.call('restyle', gd, update, traceIndex);
return Registry.call('_guiRestyle', gd, update, traceIndex);
});
} else {
textLayout(textEl);
Expand Down
4 changes: 2 additions & 2 deletions src/components/legend/handle_click.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ module.exports = function handleClick(g, gd, numClicks) {
}
}

Registry.call('relayout', gd, 'hiddenlabels', hiddenSlices);
Registry.call('_guiRelayout', gd, 'hiddenlabels', hiddenSlices);
} else {
var hasLegendgroup = legendgroup && legendgroup.length;
var traceIndicesInGroup = [];
Expand Down Expand Up @@ -217,6 +217,6 @@ module.exports = function handleClick(g, gd, numClicks) {
}
}

Registry.call('restyle', gd, attrUpdate, attrIndices);
Registry.call('_guiRestyle', gd, attrUpdate, attrIndices);
}
};
18 changes: 9 additions & 9 deletions src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function handleCartesian(gd, ev) {
aobj[astr] = val;
}

Registry.call('relayout', gd, aobj);
Registry.call('_guiRelayout', gd, aobj);
}

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

Registry.call('relayout', gd, layoutUpdate);
Registry.call('_guiRelayout', gd, layoutUpdate);
}

modeBarButtons.resetCameraDefault3d = {
Expand Down Expand Up @@ -356,7 +356,7 @@ function handleCamera3d(gd, ev) {
}
}

Registry.call('relayout', gd, aobj);
Registry.call('_guiRelayout', gd, aobj);
}

modeBarButtons.hoverClosest3d = {
Expand Down Expand Up @@ -411,7 +411,7 @@ function getNextHover3d(gd, ev) {

function handleHover3d(gd, ev) {
var layoutUpdate = getNextHover3d(gd, ev);
Registry.call('relayout', gd, layoutUpdate);
Registry.call('_guiRelayout', gd, layoutUpdate);
}

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

Registry.call('relayout', gd, id + '.projection.scale', newScale);
Registry.call('_guiRelayout', gd, id + '.projection.scale', newScale);
} else if(attr === 'reset') {
resetView(gd, 'geo');
}
Expand Down Expand Up @@ -508,7 +508,7 @@ function getNextHover(gd) {

function toggleHover(gd) {
var newHover = getNextHover(gd);
Registry.call('relayout', gd, 'hovermode', newHover);
Registry.call('_guiRelayout', gd, 'hovermode', newHover);
}

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

Registry.call('relayout', gd, layoutUpdate);
Registry.call('_guiRelayout', gd, layoutUpdate);
}
};

Expand Down Expand Up @@ -561,7 +561,7 @@ modeBarButtons.toggleSpikelines = {

var aobj = setSpikelineVisibility(gd);

Registry.call('relayout', gd, aobj);
Registry.call('_guiRelayout', gd, aobj);
}
};

Expand Down Expand Up @@ -608,5 +608,5 @@ function resetView(gd, subplotType) {
}
}

Registry.call('relayout', gd, aObj);
Registry.call('_guiRelayout', gd, aObj);
}
2 changes: 1 addition & 1 deletion src/components/rangeselector/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module.exports = function draw(gd) {
button.on('click', function() {
if(gd._dragged) return;

Registry.call('relayout', gd, update);
Registry.call('_guiRelayout', gd, update);
});

button.on('mouseover', function() {
Expand Down
5 changes: 4 additions & 1 deletion src/components/rangeslider/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) {
dataMax = clamp(opts.p2d(opts._pixelMax));

window.requestAnimationFrame(function() {
Registry.call('relayout', gd, axisOpts._name + '.range', [dataMin, dataMax]);
var update = {};
update[axisOpts._name + '.range[0]'] = dataMin;
update[axisOpts._name + '.range[1]'] = dataMax;
Registry.call('_guiRelayout', gd, update);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/shapes/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) {

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

function abortDrag() {
Expand Down
4 changes: 2 additions & 2 deletions src/components/titles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,9 @@ function draw(gd, titleClass, options) {
el.call(svgTextUtils.makeEditable, {gd: gd})
.on('edit', function(text) {
if(traceIndex !== undefined) {
Registry.call('restyle', gd, prop, text, traceIndex);
Registry.call('_guiRestyle', gd, prop, text, traceIndex);
} else {
Registry.call('relayout', gd, prop, text);
Registry.call('_guiRelayout', gd, prop, text);
}
})
.on('cancel', function() {
Expand Down
3 changes: 2 additions & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ var plotApi = require('./plot_api');
var methodNames = Object.keys(plotApi);
for(var i = 0; i < methodNames.length; i++) {
var name = methodNames[i];
exports[name] = plotApi[name];
// _ -> private API methods, but still registered for internal use
if(name.charAt(0) !== '_') exports[name] = plotApi[name];
register({
moduleType: 'apiMethod',
name: name,
Expand Down
4 changes: 4 additions & 0 deletions src/plot_api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ exports.restyle = main.restyle;
exports.relayout = main.relayout;
exports.redraw = main.redraw;
exports.update = main.update;
exports._guiRestyle = main._guiRestyle;
exports._guiRelayout = main._guiRelayout;
exports._guiUpdate = main._guiUpdate;
exports._storeDirectGUIEdit = main._storeDirectGUIEdit;
exports.react = main.react;
exports.extendTraces = main.extendTraces;
exports.prependTraces = main.prependTraces;
Expand Down
Loading

0 comments on commit a11ec44

Please sign in to comment.