Skip to content

Commit 056c8e7

Browse files
authored
Merge pull request #7240 from plotly/drop-transforms
Drop `transforms` from the API
2 parents 2ceb3da + b22f62b commit 056c8e7

File tree

86 files changed

+51
-7006
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+51
-7006
lines changed

Diff for: draftlogs/7240_remove.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Drop transforms from the API [[#7240](https://github.com/plotly/plotly.js/pull/7240)]

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

-15
Original file line numberDiff line numberDiff line change
@@ -232,21 +232,6 @@ module.exports = {
232232
polar: {
233233
radialaxis: {calendar: axisAttrs}
234234
}
235-
},
236-
transforms: {
237-
filter: {
238-
valuecalendar: makeAttrs([
239-
'WARNING: All transforms are deprecated and may be removed from the API in next major version.',
240-
'Sets the calendar system to use for `value`, if it is a date.'
241-
].join(' ')),
242-
targetcalendar: makeAttrs([
243-
'WARNING: All transforms are deprecated and may be removed from the API in next major version.',
244-
'Sets the calendar system to use for `target`, if it is an',
245-
'array of dates. If `target` is a string (eg *x*) we use the',
246-
'corresponding trace attribute (eg `xcalendar`) if it exists,',
247-
'even if `targetcalendar` is provided.'
248-
].join(' '))
249-
}
250235
}
251236
},
252237

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

+2-13
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) {
484484
event: evt,
485485
node: legendItem.node(),
486486
curveNumber: trace.index,
487-
expandedIndex: trace._expandedIndex,
487+
expandedIndex: trace.index,
488488
data: gd.data,
489489
layout: gd.layout,
490490
frames: gd._transitionData._frames,
@@ -559,18 +559,7 @@ function drawTexts(g, gd, legendObj) {
559559
var fullInput = legendItem.trace._fullInput || {};
560560
var update = {};
561561

562-
if(Registry.hasTransform(fullInput, 'groupby')) {
563-
var groupbyIndices = Registry.getTransformIndices(fullInput, 'groupby');
564-
var _index = groupbyIndices[groupbyIndices.length - 1];
565-
566-
var kcont = Lib.keyedContainer(fullInput, 'transforms[' + _index + '].styles', 'target', 'value.name');
567-
568-
kcont.set(legendItem.trace._group, newName);
569-
570-
update = kcont.constructUpdate();
571-
} else {
572-
update.name = newName;
573-
}
562+
update.name = newName;
574563

575564
if(fullInput._isShape) {
576565
return Registry.call('_guiRelayout', gd, 'shapes[' + trace.index + '].name', update.name);

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

+7-34
Original file line numberDiff line numberDiff line change
@@ -91,42 +91,15 @@ module.exports = function handleClick(g, gd, numClicks) {
9191
var index = fullInput.index;
9292
if(index === undefined) index = fullInput._index;
9393

94-
if(Registry.hasTransform(fullInput, 'groupby')) {
95-
var kcont = carrs[index];
96-
if(!kcont) {
97-
var groupbyIndices = Registry.getTransformIndices(fullInput, 'groupby');
98-
var lastGroupbyIndex = groupbyIndices[groupbyIndices.length - 1];
99-
kcont = Lib.keyedContainer(fullInput, 'transforms[' + lastGroupbyIndex + '].styles', 'target', 'value.visible');
100-
carrs[index] = kcont;
101-
}
102-
103-
var curState = kcont.get(fullTrace._group);
104-
105-
// If not specified, assume visible. This happens if there are other style
106-
// properties set for a group but not the visibility. There are many similar
107-
// ways to do this (e.g. why not just `curState = fullTrace.visible`??? The
108-
// answer is: because it breaks other things like groupby trace names in
109-
// subtle ways.)
110-
if(curState === undefined) {
111-
curState = true;
112-
}
94+
// false -> false (not possible since will not be visible in legend)
95+
// true -> legendonly
96+
// legendonly -> true
97+
var nextVisibility = fullInput.visible === false ? false : visibility;
11398

114-
if(curState !== false) {
115-
// true -> legendonly. All others toggle to true:
116-
kcont.set(fullTrace._group, visibility);
117-
}
118-
carrIdx[index] = insertDataUpdate(index, fullInput.visible === false ? false : true);
99+
if(isShape) {
100+
insertShapesUpdate(index, nextVisibility);
119101
} else {
120-
// false -> false (not possible since will not be visible in legend)
121-
// true -> legendonly
122-
// legendonly -> true
123-
var nextVisibility = fullInput.visible === false ? false : visibility;
124-
125-
if(isShape) {
126-
insertShapesUpdate(index, nextVisibility);
127-
} else {
128-
insertDataUpdate(index, nextVisibility);
129-
}
102+
insertDataUpdate(index, nextVisibility);
130103
}
131104
}
132105

Diff for: src/components/selections/select.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,8 @@ function newPointNumTester(pointSelectionDef) {
597597
ymax: 0,
598598
pts: [],
599599
contains: function(pt, omitFirstEdge, pointNumber, searchInfo) {
600-
var idxWantedTrace = pointSelectionDef.searchInfo.cd[0].trace._expandedIndex;
601-
var idxActualTrace = searchInfo.cd[0].trace._expandedIndex;
600+
var idxWantedTrace = pointSelectionDef.searchInfo.cd[0].trace.index;
601+
var idxActualTrace = searchInfo.cd[0].trace.index;
602602
return idxActualTrace === idxWantedTrace &&
603603
pointNumber === pointSelectionDef.pointNumber;
604604
},
@@ -844,7 +844,7 @@ function extractClickedPtInfo(hoverData, searchTraces) {
844844

845845
for(i = 0; i < searchTraces.length; i++) {
846846
searchInfo = searchTraces[i];
847-
if(hoverDatum.fullData._expandedIndex === searchInfo.cd[0].trace._expandedIndex) {
847+
if(hoverDatum.fullData.index === searchInfo.cd[0].trace.index) {
848848
// Special case for box (and violin)
849849
if(hoverDatum.hoverOnBox === true) {
850850
break;

Diff for: src/plot_api/helpers.js

-45
Original file line numberDiff line numberDiff line change
@@ -270,51 +270,6 @@ exports.cleanData = function(data) {
270270
}
271271
}
272272

273-
// transforms backward compatibility fixes
274-
if(Array.isArray(trace.transforms)) {
275-
var transforms = trace.transforms;
276-
277-
for(i = 0; i < transforms.length; i++) {
278-
var transform = transforms[i];
279-
280-
if(!Lib.isPlainObject(transform)) continue;
281-
282-
switch(transform.type) {
283-
case 'filter':
284-
if(transform.filtersrc) {
285-
transform.target = transform.filtersrc;
286-
delete transform.filtersrc;
287-
}
288-
289-
if(transform.calendar) {
290-
if(!transform.valuecalendar) {
291-
transform.valuecalendar = transform.calendar;
292-
}
293-
delete transform.calendar;
294-
}
295-
break;
296-
297-
case 'groupby':
298-
// Name has changed from `style` to `styles`, so use `style` but prefer `styles`:
299-
transform.styles = transform.styles || transform.style;
300-
301-
if(transform.styles && !Array.isArray(transform.styles)) {
302-
var prevStyles = transform.styles;
303-
var styleKeys = Object.keys(prevStyles);
304-
305-
transform.styles = [];
306-
for(var j = 0; j < styleKeys.length; j++) {
307-
transform.styles.push({
308-
target: styleKeys[j],
309-
value: prevStyles[styleKeys[j]]
310-
});
311-
}
312-
}
313-
break;
314-
}
315-
}
316-
}
317-
318273
// prune empty containers made before the new nestedProperty
319274
if(emptyContainer(trace, 'line')) delete trace.line;
320275
if('marker' in trace) {

Diff for: src/plot_api/plot_api.js

-1
Original file line numberDiff line numberDiff line change
@@ -2782,7 +2782,6 @@ function diffData(gd, oldFullData, newFullData, immutable, transition, newDataRe
27822782
for(i = 0; i < oldFullData.length; i++) {
27832783
if(newFullData[i]) {
27842784
trace = newFullData[i]._fullInput;
2785-
if(Plots.hasMakesDataTransform(trace)) trace = newFullData[i];
27862785
if(seenUIDs[trace.uid]) continue;
27872786
seenUIDs[trace.uid] = 1;
27882787

Diff for: src/plot_api/plot_config.js

-9
Original file line numberDiff line numberDiff line change
@@ -427,15 +427,6 @@ var configAttributes = {
427427
description: 'Sets the length of the undo/redo queue.'
428428
},
429429

430-
globalTransforms: {
431-
valType: 'any',
432-
dflt: [],
433-
description: [
434-
'Set global transform to be applied to all traces with no',
435-
'specification needed'
436-
].join(' ')
437-
},
438-
439430
locale: {
440431
valType: 'string',
441432
dflt: 'en-US',

Diff for: src/plot_api/plot_schema.js

+17-76
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ exports.UNDERSCORE_ATTRS = UNDERSCORE_ATTRS;
3434
* - defs
3535
* - traces
3636
* - layout
37-
* - transforms
3837
* - frames
3938
* - animations
4039
* - config
@@ -46,12 +45,6 @@ exports.get = function() {
4645
traces[type] = getTraceAttributes(type);
4746
});
4847

49-
var transforms = {};
50-
51-
Object.keys(Registry.transformsRegistry).forEach(function(type) {
52-
transforms[type] = getTransformAttributes(type);
53-
});
54-
5548
return {
5649
defs: {
5750
valObjects: valObjectMeta,
@@ -83,8 +76,6 @@ exports.get = function() {
8376
traces: traces,
8477
layout: getLayoutAttributes(),
8578

86-
transforms: transforms,
87-
8879
frames: getFramesAttributes(),
8980
animation: formatAttributes(animationAttributes),
9081

@@ -218,21 +209,6 @@ exports.findArrayAttributes = function(trace) {
218209
exports.crawl(trace._module.attributes, callback);
219210
}
220211

221-
var transforms = trace.transforms;
222-
if(transforms) {
223-
for(var i = 0; i < transforms.length; i++) {
224-
var transform = transforms[i];
225-
var module = transform._module;
226-
227-
if(module) {
228-
baseAttrName = 'transforms[' + i + '].';
229-
baseContainer = transform;
230-
231-
exports.crawl(module.attributes, callback);
232-
}
233-
}
234-
}
235-
236212
return arrayAttributes;
237213
};
238214

@@ -256,41 +232,26 @@ exports.getTraceValObject = function(trace, parts) {
256232
var i = 1; // index to start recursing from
257233
var moduleAttrs, valObject;
258234

259-
if(head === 'transforms') {
260-
if(parts.length === 1) {
261-
return baseAttributes.transforms;
262-
}
263-
var transforms = trace.transforms;
264-
if(!Array.isArray(transforms) || !transforms.length) return false;
265-
var tNum = parts[1];
266-
if(!isIndex(tNum) || tNum >= transforms.length) {
267-
return false;
268-
}
269-
moduleAttrs = (Registry.transformsRegistry[transforms[tNum].type] || {}).attributes;
270-
valObject = moduleAttrs && moduleAttrs[parts[2]];
271-
i = 3; // start recursing only inside the transform
272-
} else {
273-
// first look in the module for this trace
274-
// components have already merged their trace attributes in here
275-
var _module = trace._module;
276-
if(!_module) _module = (Registry.modules[trace.type || baseAttributes.type.dflt] || {})._module;
277-
if(!_module) return false;
278-
279-
moduleAttrs = _module.attributes;
280-
valObject = moduleAttrs && moduleAttrs[head];
281-
282-
// then look in the subplot attributes
283-
if(!valObject) {
284-
var subplotModule = _module.basePlotModule;
285-
if(subplotModule && subplotModule.attributes) {
286-
valObject = subplotModule.attributes[head];
287-
}
288-
}
235+
// first look in the module for this trace
236+
// components have already merged their trace attributes in here
237+
var _module = trace._module;
238+
if(!_module) _module = (Registry.modules[trace.type || baseAttributes.type.dflt] || {})._module;
239+
if(!_module) return false;
240+
241+
moduleAttrs = _module.attributes;
242+
valObject = moduleAttrs && moduleAttrs[head];
289243

290-
// finally look in the global attributes
291-
if(!valObject) valObject = baseAttributes[head];
244+
// then look in the subplot attributes
245+
if(!valObject) {
246+
var subplotModule = _module.basePlotModule;
247+
if(subplotModule && subplotModule.attributes) {
248+
valObject = subplotModule.attributes[head];
249+
}
292250
}
293251

252+
// finally look in the global attributes
253+
if(!valObject) valObject = baseAttributes[head];
254+
294255
return recurseIntoValObject(valObject, parts, i);
295256
};
296257

@@ -567,26 +528,6 @@ function getLayoutAttributes() {
567528
};
568529
}
569530

570-
function getTransformAttributes(type) {
571-
var _module = Registry.transformsRegistry[type];
572-
var attributes = extendDeepAll({}, _module.attributes);
573-
574-
// add registered components transform attributes
575-
Object.keys(Registry.componentsRegistry).forEach(function(k) {
576-
var _module = Registry.componentsRegistry[k];
577-
578-
if(_module.schema && _module.schema.transforms && _module.schema.transforms[type]) {
579-
Object.keys(_module.schema.transforms[type]).forEach(function(v) {
580-
insertAttrs(attributes, _module.schema.transforms[type][v], v);
581-
});
582-
}
583-
});
584-
585-
return {
586-
attributes: formatAttributes(attributes)
587-
};
588-
}
589-
590531
function getFramesAttributes() {
591532
var attrs = {
592533
frames: extendDeepAll({}, frameAttributes)

Diff for: src/plot_api/template_api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ exports.validateTemplate = function(figureIn, template) {
347347
// the template
348348
errorList.push({
349349
code: 'missing',
350-
index: fullTrace._fullInput.index,
350+
index: fullTrace.index,
351351
traceType: traceType
352352
});
353353
}

Diff for: src/plot_api/validate.js

-36
Original file line numberDiff line numberDiff line change
@@ -94,39 +94,6 @@ module.exports = function validate(data, layout) {
9494
}
9595

9696
crawl(traceIn, traceOut, traceSchema, errorList, base);
97-
98-
var transformsIn = traceIn.transforms;
99-
var transformsOut = traceOut.transforms;
100-
101-
if(transformsIn) {
102-
if(!isArray(transformsIn)) {
103-
errorList.push(format('array', base, ['transforms']));
104-
}
105-
106-
base.push('transforms');
107-
108-
for(var j = 0; j < transformsIn.length; j++) {
109-
var path = ['transforms', j];
110-
var transformType = transformsIn[j].type;
111-
112-
if(!isPlainObject(transformsIn[j])) {
113-
errorList.push(format('object', base, path));
114-
continue;
115-
}
116-
117-
var transformSchema = schema.transforms[transformType] ?
118-
schema.transforms[transformType].attributes :
119-
{};
120-
121-
// add 'type' to transform schema to validate the transform type
122-
transformSchema.type = {
123-
valType: 'enumerated',
124-
values: Object.keys(schema.transforms)
125-
};
126-
127-
crawl(transformsIn[j], transformsOut[j], transformSchema, errorList, base, path);
128-
}
129-
}
13097
}
13198

13299
var layoutOut = gd._fullLayout;
@@ -146,9 +113,6 @@ function crawl(objIn, objOut, schema, list, base, path) {
146113
for(var i = 0; i < keys.length; i++) {
147114
var k = keys[i];
148115

149-
// transforms are handled separately
150-
if(k === 'transforms') continue;
151-
152116
var p = path.slice();
153117
p.push(k);
154118

0 commit comments

Comments
 (0)