Skip to content

Commit d01c5fe

Browse files
authored
Merge pull request #7829 from plotly/remove-src-attrs
Remove `*src` attributes
2 parents 6031ecb + 1c903d2 commit d01c5fe

54 files changed

Lines changed: 49 additions & 9466 deletions

Some content is hidden

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

draftlogs/7812_remove.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Remove config attributes `showLink`, `linkText`, `sendData`, `showSources`, and `showEditInChartStudio`, as well as trace attribute `stream`, since all of these were associated with Chart Studio and are no longer needed [[#7812](https://github.com/plotly/plotly.js/pull/7812)]

draftlogs/7829_change.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Change signature of `plots.graphJson()` function to remove `mode` argument [[#7829](https://github.com/plotly/plotly.js/pull/7829)]

draftlogs/7829_remove.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Remove all `*src` attributes, as well as `layout.hidesources` attribute, from the schema [[#7829](https://github.com/plotly/plotly.js/pull/7829)]

src/plot_api/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ function emptyContainer(outer, innerStr) {
354354
// swap all the data and data attributes associated with x and y
355355
exports.swapXYData = function (trace) {
356356
var i;
357-
Lib.swapAttrs(trace, ['?', '?0', 'd?', '?bins', 'nbins?', 'autobin?', '?src', 'error_?']);
357+
Lib.swapAttrs(trace, ['?', '?0', 'd?', '?bins', 'nbins?', 'autobin?', 'error_?']);
358358
if (Array.isArray(trace.z) && Array.isArray(trace.z[0])) {
359359
if (trace.transpose) delete trace.transpose;
360360
else trace.transpose = true;

src/plot_api/plot_api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,9 +1564,9 @@ function _restyle(gd, aobj, traces) {
15641564
labelsTo = 'y';
15651565
valuesTo = 'x';
15661566
}
1567-
Lib.swapAttrs(cont, ['?', '?src'], 'labels', labelsTo);
1567+
Lib.swapAttrs(cont, ['?'], 'labels', labelsTo);
15681568
Lib.swapAttrs(cont, ['d?', '?0'], 'label', labelsTo);
1569-
Lib.swapAttrs(cont, ['?', '?src'], 'values', valuesTo);
1569+
Lib.swapAttrs(cont, ['?'], 'values', valuesTo);
15701570

15711571
if (oldVal === 'pie' || oldVal === 'funnelarea') {
15721572
nestedProperty(cont, 'marker.color').set(nestedProperty(cont, 'marker.colors').get());

src/plot_api/plot_schema.js

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -539,29 +539,16 @@ function getFramesAttributes() {
539539
}
540540

541541
function formatAttributes(attrs) {
542-
mergeValTypeAndRole(attrs);
542+
setRole(attrs);
543543
formatArrayContainers(attrs);
544544
stringify(attrs);
545545

546546
return attrs;
547547
}
548548

549-
function mergeValTypeAndRole(attrs) {
550-
function makeSrcAttr(attrName) {
551-
return {
552-
valType: 'string',
553-
description: 'Sets the source reference on Chart Studio Cloud for `' + attrName + '`.',
554-
editType: 'none'
555-
};
556-
}
557-
549+
function setRole(attrs) {
558550
function callback(attr, attrName, attrs) {
559-
if(exports.isValObject(attr)) {
560-
if(attr.arrayOk === true || attr.valType === 'data_array') {
561-
// all 'arrayOk' and 'data_array' attrs have a corresponding 'src' attr
562-
attrs[attrName + 'src'] = makeSrcAttr(attrName);
563-
}
564-
} else if(isPlainObject(attr)) {
551+
if(!exports.isValObject(attr) && isPlainObject(attr)) {
565552
// all attrs container objects get role 'object'
566553
attr.role = 'object';
567554
}

src/plot_api/to_image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function toImage(gd, opts) {
170170
}
171171

172172
if(format === 'full-json') {
173-
var json = plots.graphJson(clonedGd, false, 'keepdata', 'object', true, true);
173+
var json = plots.graphJson(clonedGd, false, 'object', true, true);
174174
json.version = version;
175175
json = JSON.stringify(json);
176176
cleanup();

src/plots/layout_attributes.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -318,17 +318,6 @@ module.exports = {
318318
'other locales may alter this default.'
319319
].join(' ')
320320
},
321-
hidesources: {
322-
valType: 'boolean',
323-
dflt: false,
324-
editType: 'plot',
325-
description: [
326-
'Determines whether or not a text link citing the data source is',
327-
'placed at the bottom-right cored of the figure.',
328-
'Has only an effect only on graphs that have been generated via',
329-
'forked graphs from the Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise).'
330-
].join(' ')
331-
},
332321
showlegend: {
333322
// handled in legend.supplyLayoutDefaults
334323
// but included here because it's not in the legend object

src/plots/plots.js

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ plots.sendDataToCloud = function(gd) {
139139
name: 'data'
140140
});
141141

142-
hiddenformInput.node().value = plots.graphJson(gd, false, 'keepdata');
142+
hiddenformInput.node().value = plots.graphJson(gd);
143143
hiddenform.node().submit();
144144
hiddenformDiv.remove();
145145

@@ -1318,7 +1318,6 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
13181318
coerce('paper_bgcolor');
13191319

13201320
coerce('separators', formatObj.decimal + formatObj.thousands);
1321-
coerce('hidesources');
13221321

13231322
coerce('colorway');
13241323

@@ -1964,27 +1963,21 @@ plots.didMarginChange = function(margin0, margin1) {
19641963
/**
19651964
* JSONify the graph data and layout
19661965
*
1967-
* This function needs to recurse because some src can be inside
1966+
* This function needs to recurse because some objects can be inside
19681967
* sub-objects.
19691968
*
19701969
* It also strips out functions and private (starts with _) elements.
19711970
* Therefore, we can add temporary things to data and layout that don't
19721971
* get saved.
19731972
*
19741973
* @param gd The graphDiv
1975-
* @param {Boolean} dataonly If true, don't return layout.
1976-
* @param {'keepref'|'keepdata'|'keepall'} [mode='keepref'] Filter what's kept
1977-
* keepref: remove data for which there's a src present
1978-
* eg if there's xsrc present (and xsrc is well-formed,
1979-
* ie has : and some chars before it), strip out x
1980-
* keepdata: remove all src tags, don't remove the data itself
1981-
* keepall: keep data and src
1982-
* @param {String} output If you specify 'object', the result will not be stringified
1983-
* @param {Boolean} useDefaults If truthy, use _fullLayout and _fullData
1984-
* @param {Boolean} includeConfig If truthy, include _context
1974+
* @param {Boolean} [dataonly=false] If true, don't return layout.
1975+
* @param {String} [output='json'] If set to 'object', return result as a JS Object, otherwise return as a JSON string
1976+
* @param {Boolean} [useDefaults=false] If truthy, use _fullLayout and _fullData (after supplyDefaults step)
1977+
* @param {Boolean} [includeConfig=false] If truthy, include _context
19851978
* @returns {Object|String}
19861979
*/
1987-
plots.graphJson = function(gd, dataonly, mode, output, useDefaults, includeConfig) {
1980+
plots.graphJson = function(gd, dataonly = false, output = 'json', useDefaults = false, includeConfig = false) {
19881981
// if the defaults aren't supplied yet, we need to do that...
19891982
if((useDefaults && dataonly && !gd._fullData) ||
19901983
(useDefaults && !dataonly && !gd._fullLayout)) {
@@ -2001,7 +1994,6 @@ plots.graphJson = function(gd, dataonly, mode, output, useDefaults, includeConfi
20011994
}
20021995
if(Lib.isPlainObject(d)) {
20031996
var o = {};
2004-
var src;
20051997
Object.keys(d).sort().forEach(function(v) {
20061998
// remove private elements and functions
20071999
// _ is for private, [ is a mistake ie [object Object]
@@ -2013,21 +2005,6 @@ plots.graphJson = function(gd, dataonly, mode, output, useDefaults, includeConfi
20132005
return;
20142006
}
20152007

2016-
// look for src/data matches and remove the appropriate one
2017-
if(mode === 'keepdata') {
2018-
// keepdata: remove all ...src tags
2019-
if(v.slice(-3) === 'src') {
2020-
return;
2021-
}
2022-
} else if(mode !== 'keepall') {
2023-
// keepref: remove sourced data but only
2024-
// if the source tag is well-formed
2025-
src = d[v + 'src'];
2026-
if(typeof src === 'string' && src.indexOf(':') > 0) {
2027-
return;
2028-
}
2029-
}
2030-
20312008
// OK, we're including this... recurse into it
20322009
o[v] = stripObj(d[v], keepFunction);
20332010
});

src/snapshot/cloneplot.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ function cloneLayoutOverride(tileClass) {
2626
case 'thumbnail':
2727
override = {
2828
title: {text: ''},
29-
hidesources: true,
3029
showlegend: false,
3130
borderwidth: 0,
3231
bordercolor: '',

0 commit comments

Comments
 (0)