Skip to content
Merged
1 change: 1 addition & 0 deletions draftlogs/7240_remove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Drop transforms from the API [[#7240](https://github.com/plotly/plotly.js/pull/7240)]
15 changes: 0 additions & 15 deletions src/components/calendars/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,21 +232,6 @@ module.exports = {
polar: {
radialaxis: {calendar: axisAttrs}
}
},
transforms: {
filter: {
valuecalendar: makeAttrs([
'WARNING: All transforms are deprecated and may be removed from the API in next major version.',
'Sets the calendar system to use for `value`, if it is a date.'
].join(' ')),
targetcalendar: makeAttrs([
'WARNING: All transforms are deprecated and may be removed from the API in next major version.',
'Sets the calendar system to use for `target`, if it is an',
'array of dates. If `target` is a string (eg *x*) we use the',
'corresponding trace attribute (eg `xcalendar`) if it exists,',
'even if `targetcalendar` is provided.'
].join(' '))
}
}
},

Expand Down
15 changes: 2 additions & 13 deletions src/components/legend/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) {
event: evt,
node: legendItem.node(),
curveNumber: trace.index,
expandedIndex: trace._expandedIndex,
expandedIndex: trace.index,
data: gd.data,
layout: gd.layout,
frames: gd._transitionData._frames,
Expand Down Expand Up @@ -559,18 +559,7 @@ function drawTexts(g, gd, legendObj) {
var fullInput = legendItem.trace._fullInput || {};
var update = {};

if(Registry.hasTransform(fullInput, 'groupby')) {
var groupbyIndices = Registry.getTransformIndices(fullInput, 'groupby');
var _index = groupbyIndices[groupbyIndices.length - 1];

var kcont = Lib.keyedContainer(fullInput, 'transforms[' + _index + '].styles', 'target', 'value.name');

kcont.set(legendItem.trace._group, newName);

update = kcont.constructUpdate();
} else {
update.name = newName;
}
update.name = newName;

if(fullInput._isShape) {
return Registry.call('_guiRelayout', gd, 'shapes[' + trace.index + '].name', update.name);
Expand Down
41 changes: 7 additions & 34 deletions src/components/legend/handle_click.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,42 +91,15 @@ module.exports = function handleClick(g, gd, numClicks) {
var index = fullInput.index;
if(index === undefined) index = fullInput._index;

if(Registry.hasTransform(fullInput, 'groupby')) {
var kcont = carrs[index];
if(!kcont) {
var groupbyIndices = Registry.getTransformIndices(fullInput, 'groupby');
var lastGroupbyIndex = groupbyIndices[groupbyIndices.length - 1];
kcont = Lib.keyedContainer(fullInput, 'transforms[' + lastGroupbyIndex + '].styles', 'target', 'value.visible');
carrs[index] = kcont;
}

var curState = kcont.get(fullTrace._group);

// If not specified, assume visible. This happens if there are other style
// properties set for a group but not the visibility. There are many similar
// ways to do this (e.g. why not just `curState = fullTrace.visible`??? The
// answer is: because it breaks other things like groupby trace names in
// subtle ways.)
if(curState === undefined) {
curState = true;
}
// false -> false (not possible since will not be visible in legend)
// true -> legendonly
// legendonly -> true
var nextVisibility = fullInput.visible === false ? false : visibility;

if(curState !== false) {
// true -> legendonly. All others toggle to true:
kcont.set(fullTrace._group, visibility);
}
carrIdx[index] = insertDataUpdate(index, fullInput.visible === false ? false : true);
if(isShape) {
insertShapesUpdate(index, nextVisibility);
} else {
// false -> false (not possible since will not be visible in legend)
// true -> legendonly
// legendonly -> true
var nextVisibility = fullInput.visible === false ? false : visibility;

if(isShape) {
insertShapesUpdate(index, nextVisibility);
} else {
insertDataUpdate(index, nextVisibility);
}
insertDataUpdate(index, nextVisibility);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/selections/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,8 @@ function newPointNumTester(pointSelectionDef) {
ymax: 0,
pts: [],
contains: function(pt, omitFirstEdge, pointNumber, searchInfo) {
var idxWantedTrace = pointSelectionDef.searchInfo.cd[0].trace._expandedIndex;
var idxActualTrace = searchInfo.cd[0].trace._expandedIndex;
var idxWantedTrace = pointSelectionDef.searchInfo.cd[0].trace.index;
var idxActualTrace = searchInfo.cd[0].trace.index;
return idxActualTrace === idxWantedTrace &&
pointNumber === pointSelectionDef.pointNumber;
},
Expand Down Expand Up @@ -844,7 +844,7 @@ function extractClickedPtInfo(hoverData, searchTraces) {

for(i = 0; i < searchTraces.length; i++) {
searchInfo = searchTraces[i];
if(hoverDatum.fullData._expandedIndex === searchInfo.cd[0].trace._expandedIndex) {
if(hoverDatum.fullData.index === searchInfo.cd[0].trace.index) {
// Special case for box (and violin)
if(hoverDatum.hoverOnBox === true) {
break;
Expand Down
45 changes: 0 additions & 45 deletions src/plot_api/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,51 +270,6 @@ exports.cleanData = function(data) {
}
}

// transforms backward compatibility fixes
if(Array.isArray(trace.transforms)) {
var transforms = trace.transforms;

for(i = 0; i < transforms.length; i++) {
var transform = transforms[i];

if(!Lib.isPlainObject(transform)) continue;

switch(transform.type) {
case 'filter':
if(transform.filtersrc) {
transform.target = transform.filtersrc;
delete transform.filtersrc;
}

if(transform.calendar) {
if(!transform.valuecalendar) {
transform.valuecalendar = transform.calendar;
}
delete transform.calendar;
}
break;

case 'groupby':
// Name has changed from `style` to `styles`, so use `style` but prefer `styles`:
transform.styles = transform.styles || transform.style;

if(transform.styles && !Array.isArray(transform.styles)) {
var prevStyles = transform.styles;
var styleKeys = Object.keys(prevStyles);

transform.styles = [];
for(var j = 0; j < styleKeys.length; j++) {
transform.styles.push({
target: styleKeys[j],
value: prevStyles[styleKeys[j]]
});
}
}
break;
}
}
}

// prune empty containers made before the new nestedProperty
if(emptyContainer(trace, 'line')) delete trace.line;
if('marker' in trace) {
Expand Down
1 change: 0 additions & 1 deletion src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2782,7 +2782,6 @@ function diffData(gd, oldFullData, newFullData, immutable, transition, newDataRe
for(i = 0; i < oldFullData.length; i++) {
if(newFullData[i]) {
trace = newFullData[i]._fullInput;
if(Plots.hasMakesDataTransform(trace)) trace = newFullData[i];
if(seenUIDs[trace.uid]) continue;
seenUIDs[trace.uid] = 1;

Expand Down
9 changes: 0 additions & 9 deletions src/plot_api/plot_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -427,15 +427,6 @@ var configAttributes = {
description: 'Sets the length of the undo/redo queue.'
},

globalTransforms: {
valType: 'any',
dflt: [],
description: [
'Set global transform to be applied to all traces with no',
'specification needed'
].join(' ')
},

locale: {
valType: 'string',
dflt: 'en-US',
Expand Down
93 changes: 17 additions & 76 deletions src/plot_api/plot_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ exports.UNDERSCORE_ATTRS = UNDERSCORE_ATTRS;
* - defs
* - traces
* - layout
* - transforms
* - frames
* - animations
* - config
Expand All @@ -46,12 +45,6 @@ exports.get = function() {
traces[type] = getTraceAttributes(type);
});

var transforms = {};

Object.keys(Registry.transformsRegistry).forEach(function(type) {
transforms[type] = getTransformAttributes(type);
});

return {
defs: {
valObjects: valObjectMeta,
Expand Down Expand Up @@ -83,8 +76,6 @@ exports.get = function() {
traces: traces,
layout: getLayoutAttributes(),

transforms: transforms,

frames: getFramesAttributes(),
animation: formatAttributes(animationAttributes),

Expand Down Expand Up @@ -218,21 +209,6 @@ exports.findArrayAttributes = function(trace) {
exports.crawl(trace._module.attributes, callback);
}

var transforms = trace.transforms;
if(transforms) {
for(var i = 0; i < transforms.length; i++) {
var transform = transforms[i];
var module = transform._module;

if(module) {
baseAttrName = 'transforms[' + i + '].';
baseContainer = transform;

exports.crawl(module.attributes, callback);
}
}
}

return arrayAttributes;
};

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

if(head === 'transforms') {
if(parts.length === 1) {
return baseAttributes.transforms;
}
var transforms = trace.transforms;
if(!Array.isArray(transforms) || !transforms.length) return false;
var tNum = parts[1];
if(!isIndex(tNum) || tNum >= transforms.length) {
return false;
}
moduleAttrs = (Registry.transformsRegistry[transforms[tNum].type] || {}).attributes;
valObject = moduleAttrs && moduleAttrs[parts[2]];
i = 3; // start recursing only inside the transform
} else {
// first look in the module for this trace
// components have already merged their trace attributes in here
var _module = trace._module;
if(!_module) _module = (Registry.modules[trace.type || baseAttributes.type.dflt] || {})._module;
if(!_module) return false;

moduleAttrs = _module.attributes;
valObject = moduleAttrs && moduleAttrs[head];

// then look in the subplot attributes
if(!valObject) {
var subplotModule = _module.basePlotModule;
if(subplotModule && subplotModule.attributes) {
valObject = subplotModule.attributes[head];
}
}
// first look in the module for this trace
// components have already merged their trace attributes in here
var _module = trace._module;
if(!_module) _module = (Registry.modules[trace.type || baseAttributes.type.dflt] || {})._module;
if(!_module) return false;

moduleAttrs = _module.attributes;
valObject = moduleAttrs && moduleAttrs[head];

// finally look in the global attributes
if(!valObject) valObject = baseAttributes[head];
// then look in the subplot attributes
if(!valObject) {
var subplotModule = _module.basePlotModule;
if(subplotModule && subplotModule.attributes) {
valObject = subplotModule.attributes[head];
}
}

// finally look in the global attributes
if(!valObject) valObject = baseAttributes[head];

return recurseIntoValObject(valObject, parts, i);
};

Expand Down Expand Up @@ -567,26 +528,6 @@ function getLayoutAttributes() {
};
}

function getTransformAttributes(type) {
var _module = Registry.transformsRegistry[type];
var attributes = extendDeepAll({}, _module.attributes);

// add registered components transform attributes
Object.keys(Registry.componentsRegistry).forEach(function(k) {
var _module = Registry.componentsRegistry[k];

if(_module.schema && _module.schema.transforms && _module.schema.transforms[type]) {
Object.keys(_module.schema.transforms[type]).forEach(function(v) {
insertAttrs(attributes, _module.schema.transforms[type][v], v);
});
}
});

return {
attributes: formatAttributes(attributes)
};
}

function getFramesAttributes() {
var attrs = {
frames: extendDeepAll({}, frameAttributes)
Expand Down
2 changes: 1 addition & 1 deletion src/plot_api/template_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ exports.validateTemplate = function(figureIn, template) {
// the template
errorList.push({
code: 'missing',
index: fullTrace._fullInput.index,
index: fullTrace.index,
traceType: traceType
});
}
Expand Down
36 changes: 0 additions & 36 deletions src/plot_api/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,39 +94,6 @@ module.exports = function validate(data, layout) {
}

crawl(traceIn, traceOut, traceSchema, errorList, base);

var transformsIn = traceIn.transforms;
var transformsOut = traceOut.transforms;

if(transformsIn) {
if(!isArray(transformsIn)) {
errorList.push(format('array', base, ['transforms']));
}

base.push('transforms');

for(var j = 0; j < transformsIn.length; j++) {
var path = ['transforms', j];
var transformType = transformsIn[j].type;

if(!isPlainObject(transformsIn[j])) {
errorList.push(format('object', base, path));
continue;
}

var transformSchema = schema.transforms[transformType] ?
schema.transforms[transformType].attributes :
{};

// add 'type' to transform schema to validate the transform type
transformSchema.type = {
valType: 'enumerated',
values: Object.keys(schema.transforms)
};

crawl(transformsIn[j], transformsOut[j], transformSchema, errorList, base, path);
}
}
}

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

// transforms are handled separately
if(k === 'transforms') continue;

var p = path.slice();
p.push(k);

Expand Down
Loading