Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions draftlogs/7834_remove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Remove internal `trace._fullInput` property and other dead code related to the removed `transforms` feature. No user-facing changes expected [[#7834](https://github.com/plotly/plotly.js/pull/7834)]
12 changes: 1 addition & 11 deletions src/components/fx/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,17 +122,7 @@ exports.makeEventData = function (pt, trace, cd) {
pointNumber: pointNumber
};

if (trace._indexToPoints) {
var pointIndices = trace._indexToPoints[pointNumber];

if (pointIndices.length === 1) {
out.pointIndex = pointIndices[0];
} else {
out.pointIndices = pointIndices;
}
} else {
out.pointIndex = pointNumber;
}
out.pointIndex = pointNumber;

if (trace._module.eventData) {
out = trace._module.eventData(out, pt, trace, cd, pointNumber);
Expand Down
4 changes: 1 addition & 3 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ function drawOne(gd, opts) {

var shapeLegend = {
_isShape: true,
_fullInput: shape,
index: shape._index,
name: shape.name || shape.label.text || ('shape ' + shape._index),
legend: shape.legend,
Expand Down Expand Up @@ -599,12 +598,11 @@ function drawTexts(g, gd, legendObj) {
this.text(ensureLength(newName, maxNameLength))
.call(textLayout, g, gd, legendObj);

var fullInput = legendItem.trace._fullInput || {};
var update = {};

update.name = newName;

if(fullInput._isShape) {
if(legendItem.trace._isShape) {
return Registry.call('_guiRelayout', gd, 'shapes[' + trace.index + '].name', update.name);
} else {
return Registry.call('_guiRestyle', gd, update, trace.index);
Expand Down
16 changes: 6 additions & 10 deletions src/components/legend/handle_click.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ exports.handleItemClick = function handleItemClick(g, gd, legendObj, mode) {

var fullTrace = legendItem.trace;
if (fullTrace._isShape) {
fullTrace = fullTrace._fullInput;
fullTrace = fullLayout.shapes[fullTrace.index];
}

var legendgroup = fullTrace.legendgroup;
Expand Down Expand Up @@ -92,15 +92,14 @@ exports.handleItemClick = function handleItemClick(g, gd, legendObj, mode) {
function setVisibility(fullTrace, visibility) {
if (legendItem.groupTitle && !toggleGroup) return;

var fullInput = fullTrace._fullInput || fullTrace;
var isShape = fullInput._isShape;
var index = fullInput.index;
if (index === undefined) index = fullInput._index;
var isShape = fullTrace._isShape;
var index = fullTrace.index;
if (index === undefined) index = fullTrace._index;

// false -> false (not possible since will not be visible in legend)
// true -> legendonly
// legendonly -> true
var nextVisibility = fullInput.visible === false ? false : visibility;
var nextVisibility = fullTrace.visible === false ? false : visibility;

if (isShape) {
insertShapesUpdate(index, nextVisibility);
Expand All @@ -111,10 +110,7 @@ exports.handleItemClick = function handleItemClick(g, gd, legendObj, mode) {

var thisLegend = fullTrace.legend;

var fullInput = fullTrace._fullInput;
var isShape = fullInput && fullInput._isShape;

if (!isShape && Registry.traceIs(fullTrace, 'pie-like')) {
if (!fullTrace._isShape && Registry.traceIs(fullTrace, 'pie-like')) {
var thisLabel = legendItem.label;
var thisLabelIndex = hiddenSlices.indexOf(thisLabel);

Expand Down
21 changes: 5 additions & 16 deletions src/components/selections/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -940,51 +940,40 @@ function isOnlyOnePointSelected(searchTraces) {

function updateSelectedState(gd, searchTraces, eventData) {
var i;
var trace;

// before anything else, update preGUI if necessary
for(i = 0; i < searchTraces.length; i++) {
var fullInputTrace = searchTraces[i].cd[0].trace._fullInput;
var tracePreGUI = gd._fullLayout._tracePreGUI[fullInputTrace.uid] || {};
trace = searchTraces[i].cd[0].trace;
var tracePreGUI = gd._fullLayout._tracePreGUI[trace.uid] || {};
if(tracePreGUI.selectedpoints === undefined) {
tracePreGUI.selectedpoints = fullInputTrace._input.selectedpoints || null;
tracePreGUI.selectedpoints = trace._input.selectedpoints || null;
}
}

var trace;
if(eventData) {
var pts = eventData.points || [];
for(i = 0; i < searchTraces.length; i++) {
trace = searchTraces[i].cd[0].trace;
trace._input.selectedpoints = trace._fullInput.selectedpoints = [];
if(trace._fullInput !== trace) trace.selectedpoints = [];
trace._input.selectedpoints = trace.selectedpoints = [];
}

for(var k = 0; k < pts.length; k++) {
var pt = pts[k];
var data = pt.data;
var fullData = pt.fullData;
var pointIndex = pt.pointIndex;
var pointIndices = pt.pointIndices;
if(pointIndices) {
[].push.apply(data.selectedpoints, pointIndices);
if(trace._fullInput !== trace) {
[].push.apply(fullData.selectedpoints, pointIndices);
}
} else {
data.selectedpoints.push(pointIndex);
if(trace._fullInput !== trace) {
fullData.selectedpoints.push(pointIndex);
}
}
}
} else {
for(i = 0; i < searchTraces.length; i++) {
trace = searchTraces[i].cd[0].trace;
delete trace.selectedpoints;
delete trace._input.selectedpoints;
if(trace._fullInput !== trace) {
delete trace._fullInput.selectedpoints;
}
}
}

Expand Down
52 changes: 3 additions & 49 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,39 +585,17 @@ lib.extractOption = function (calcPt, trace, calcKey, traceKey) {
if (!Array.isArray(traceVal)) return traceVal;
};

function makePtIndex2PtNumber(indexToPoints) {
var ptIndex2ptNumber = {};
for (var k in indexToPoints) {
var pts = indexToPoints[k];
for (var j = 0; j < pts.length; j++) {
ptIndex2ptNumber[pts[j]] = +k;
}
}
return ptIndex2ptNumber;
}

/** Tag selected calcdata items
*
* N.B. note that point 'index' corresponds to input data array index
* whereas 'number' is its post-transform version.
*
* @param {array} calcTrace
* @param {object} trace
* - selectedpoints {array}
* - _indexToPoints {object}
* @param {ptNumber2cdIndex} ptNumber2cdIndex (optional)
* optional map object for trace types that do not have 1-to-1 point number to
* calcdata item index correspondence (e.g. histogram)
*/
lib.tagSelected = function (calcTrace, trace, ptNumber2cdIndex) {
var selectedpoints = trace.selectedpoints;
var indexToPoints = trace._indexToPoints;
var ptIndex2ptNumber;

// make pt index-to-number map object, which takes care of transformed traces
if (indexToPoints) {
ptIndex2ptNumber = makePtIndex2PtNumber(indexToPoints);
}

function isCdIndexValid(v) {
return v !== undefined && v < calcTrace.length;
Expand All @@ -630,7 +608,7 @@ lib.tagSelected = function (calcTrace, trace, ptNumber2cdIndex) {
lib.isIndex(ptIndex) ||
(lib.isArrayOrTypedArray(ptIndex) && lib.isIndex(ptIndex[0]) && lib.isIndex(ptIndex[1]))
) {
var ptNumber = ptIndex2ptNumber ? ptIndex2ptNumber[ptIndex] : ptIndex;
var ptNumber = ptIndex;
var cdIndex = ptNumber2cdIndex ? ptNumber2cdIndex[ptNumber] : ptNumber;

if (isCdIndexValid(cdIndex)) {
Expand All @@ -640,30 +618,6 @@ lib.tagSelected = function (calcTrace, trace, ptNumber2cdIndex) {
}
};

lib.selIndices2selPoints = function (trace) {
var selectedpoints = trace.selectedpoints;
var indexToPoints = trace._indexToPoints;

if (indexToPoints) {
var ptIndex2ptNumber = makePtIndex2PtNumber(indexToPoints);
var out = [];

for (var i = 0; i < selectedpoints.length; i++) {
var ptIndex = selectedpoints[i];
if (lib.isIndex(ptIndex)) {
var ptNumber = ptIndex2ptNumber[ptIndex];
if (lib.isIndex(ptNumber)) {
out.push(ptNumber);
}
}
}

return out;
} else {
return selectedpoints;
}
};

/** Returns target as set by 'target' transform attribute
*
* @param {object} trace : full trace object
Expand Down Expand Up @@ -956,8 +910,8 @@ lib.expandObjectPaths = function (data) {
data[prop] = data[prop] || [];

if (match[3] === '.') {
// This is the case where theere are subsequent properties into which
// we must recurse, e.g. transforms[0].value
// This is the case where there are subsequent properties into which
// we must recurse, e.g. annotations[0].text
trailingPath = match[4];
dest = data[prop][idx] = data[prop][idx] || {};

Expand Down
47 changes: 17 additions & 30 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1408,16 +1408,6 @@ function _restyle(gd, aobj, traces) {
return 'LAYOUT' + axName + '.range';
}

function getFullTrace(traceIndex) {
// usually fullData maps 1:1 onto data, but with groupby transforms
// the fullData index can be greater. Take the *first* matching trace.
for (var j = traceIndex; j < fullData.length; j++) {
if (fullData[j]._input === data[traceIndex]) return fullData[j];
}
// should never get here - and if we *do* it should cause an error
// later on undefined fullTrace is passed to nestedProperty.
}

// for attrs that interact (like scales & autoscales), save the
// old vals before making the change
// val=undefined will not set a value, just record what the value was.
Expand All @@ -1438,7 +1428,7 @@ function _restyle(gd, aobj, traces) {
extraparam = layoutNP(gd.layout, attr.replace('LAYOUT', ''));
} else {
var tracei = traces[i];
var preGUI = fullLayout._tracePreGUI[getFullTrace(tracei)._fullInput.uid];
var preGUI = fullLayout._tracePreGUI[fullData[tracei].uid];
extraparam = makeNP(preGUI, guiEditFlag)(data[tracei], attr);
}

Expand Down Expand Up @@ -1509,8 +1499,8 @@ function _restyle(gd, aobj, traces) {
undoit[ai] = a0();
for (i = 0; i < traces.length; i++) {
cont = data[traces[i]];
contFull = getFullTrace(traces[i]);
var preGUI = fullLayout._tracePreGUI[contFull._fullInput.uid];
contFull = fullData[traces[i]];
var preGUI = fullLayout._tracePreGUI[contFull.uid];
param = makeNP(preGUI, guiEditFlag)(cont, ai);
oldVal = param.get();
newVal = Array.isArray(vi) ? vi[i % vi.length] : vi;
Expand Down Expand Up @@ -2343,8 +2333,7 @@ var layoutUIControlPatterns = [
// or with no `attr` we use `trace.uirevision`
var traceUIControlPatterns = [
{ pattern: /^selectedpoints$/, attr: 'selectionrevision' },
// "visible" includes trace.transforms[i].styles[j].value.visible
{ pattern: /(^|value\.)visible$/, attr: 'legend.uirevision' },
{ pattern: /^visible$/, attr: 'legend.uirevision' },
{ pattern: /^dimensions\[\d+\]\.constraintrange/ },
{ pattern: /^node\.(x|y|groups)/ }, // for Sankey nodes
{ pattern: /^level$/ }, // for Sunburst, Treemap and Icicle traces
Expand All @@ -2354,8 +2343,7 @@ var traceUIControlPatterns = [
// reasonable or should these be `editrevision`?
// Also applies to axis titles up in the layout section

// "name" also includes transform.styles
{ pattern: /(^|value\.)name$/ },
{ pattern: /^name$/ },
// including nested colorbar attributes (ie marker.colorbar)
{ pattern: /colorbar\.title\.text$/ },
{ pattern: /colorbar\.(x|y)$/, attr: 'editrevision' }
Expand Down Expand Up @@ -2392,7 +2380,7 @@ function getNewRev(revAttr, container) {

function getFullTraceIndexFromUid(uid, fullData) {
for (var i = 0; i < fullData.length; i++) {
if (fullData[i]._fullInput.uid === uid) return i;
if (fullData[i].uid === uid) return i;
}
return -1;
}
Expand Down Expand Up @@ -2499,7 +2487,7 @@ function applyUIRevisions(data, layout, oldFullData, oldFullLayout) {
for (var uid in allTracePreGUI) {
var tracePreGUI = allTracePreGUI[uid];
var newTrace = null;
var fullInput;
var fullTrace;
for (key in tracePreGUI) {
// wait until we know we have preGUI values to look for traces
// but if we don't find both, stop looking at this uid
Expand All @@ -2511,10 +2499,9 @@ function applyUIRevisions(data, layout, oldFullData, oldFullLayout) {
delete allTracePreGUI[uid];
break;
}
var fullTrace = oldFullData[fulli];
fullInput = fullTrace._fullInput;
fullTrace = oldFullData[fulli];

var newTracei = getTraceIndexFromUid(uid, data, fullInput.index);
var newTracei = getTraceIndexFromUid(uid, data, fullTrace.index);
if (newTracei < 0) {
// No match in new data
delete allTracePreGUI[uid];
Expand All @@ -2529,7 +2516,7 @@ function applyUIRevisions(data, layout, oldFullData, oldFullLayout) {
oldRev = nestedProperty(oldFullLayout, match.attr).get();
newRev = oldRev && getNewRev(match.attr, layout);
} else {
oldRev = fullInput.uirevision;
oldRev = fullTrace.uirevision;
// inheritance for trace.uirevision is simple, just layout.uirevision
newRev = newTrace.uirevision;
if (newRev === undefined) newRev = layout.uirevision;
Expand All @@ -2541,7 +2528,7 @@ function applyUIRevisions(data, layout, oldFullData, oldFullLayout) {
newNP = nestedProperty(newTrace, key);
newVal = newNP.get();
if (valsMatch(newVal, preGUIVal)) {
newNP.set(undefinedToNull(nestedProperty(fullInput, key).get()));
newNP.set(undefinedToNull(nestedProperty(fullTrace, key).get()));
continue;
}
}
Expand Down Expand Up @@ -2630,9 +2617,9 @@ function react(gd, data, layout, config) {

applyUIRevisions(gd.data, gd.layout, oldFullData, oldFullLayout);

// "true" skips updating calcdata and remapping arrays from calcTransforms,
// which supplyDefaults usually does at the end, but we may need to NOT do
// if the diff (which we haven't determined yet) says we'll recalc
// "true" skips updating calcdata, which supplyDefaults usually does at
// the end, but we may need to NOT do if the diff (which we haven't
// determined yet) says we'll recalc
Plots.supplyDefaults(gd, { skipUpdateCalc: true });

var newFullData = gd._fullData;
Expand Down Expand Up @@ -2667,7 +2654,7 @@ function react(gd, data, layout, config) {
if (emptyCategories) emptyCategories();
}
}
// otherwise do the calcdata updates and calcTransform array remaps that we skipped earlier
// otherwise do the calcdata updates that we skipped earlier
} else {
Plots.supplyDefaultsUpdateCalc(gd.calcdata, newFullData);
}
Expand Down Expand Up @@ -2783,11 +2770,11 @@ function diffData(gd, oldFullData, newFullData, immutable, transition, newDataRe

for (i = 0; i < oldFullData.length; i++) {
if (newFullData[i]) {
trace = newFullData[i]._fullInput;
trace = newFullData[i];
if (seenUIDs[trace.uid]) continue;
seenUIDs[trace.uid] = 1;

getDiffFlags(oldFullData[i]._fullInput, trace, [], diffOpts);
getDiffFlags(oldFullData[i], trace, [], diffOpts);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/plot_api/plot_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ exports.findArrayAttributes = function(trace) {
* @param {object} trace
* full trace object that contains a reference to `_module.attributes`
* @param {object} parts
* an array of parts, like ['transforms', 1, 'value']
* an array of parts, like ['dimensions', 1, 'values']
* typically from nestedProperty(...).parts
*
* @return {object|false}
Expand Down
Loading
Loading