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/7623_change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Remove all `*src` attributes, as well as `layout.hidesources` attribute, from the schema. Change signature of `plots.graphJson()` function to remove `mode` argument [[#7623](https://github.com/plotly/plotly.js/pull/7623)]
1 change: 1 addition & 0 deletions draftlogs/7812_remove.md
Original file line number Diff line number Diff line change
@@ -0,0 +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)]
2 changes: 1 addition & 1 deletion src/plot_api/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ function emptyContainer(outer, innerStr) {
// swap all the data and data attributes associated with x and y
exports.swapXYData = function (trace) {
var i;
Lib.swapAttrs(trace, ['?', '?0', 'd?', '?bins', 'nbins?', 'autobin?', '?src', 'error_?']);
Lib.swapAttrs(trace, ['?', '?0', 'd?', '?bins', 'nbins?', 'autobin?', 'error_?']);
if (Array.isArray(trace.z) && Array.isArray(trace.z[0])) {
if (trace.transpose) delete trace.transpose;
else trace.transpose = true;
Expand Down
4 changes: 2 additions & 2 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1564,9 +1564,9 @@ function _restyle(gd, aobj, traces) {
labelsTo = 'y';
valuesTo = 'x';
}
Lib.swapAttrs(cont, ['?', '?src'], 'labels', labelsTo);
Lib.swapAttrs(cont, ['?'], 'labels', labelsTo);
Lib.swapAttrs(cont, ['d?', '?0'], 'label', labelsTo);
Lib.swapAttrs(cont, ['?', '?src'], 'values', valuesTo);
Lib.swapAttrs(cont, ['?'], 'values', valuesTo);

if (oldVal === 'pie' || oldVal === 'funnelarea') {
nestedProperty(cont, 'marker.color').set(nestedProperty(cont, 'marker.colors').get());
Expand Down
19 changes: 3 additions & 16 deletions src/plot_api/plot_schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,29 +539,16 @@ function getFramesAttributes() {
}

function formatAttributes(attrs) {
mergeValTypeAndRole(attrs);
setRole(attrs);
formatArrayContainers(attrs);
stringify(attrs);

return attrs;
}

function mergeValTypeAndRole(attrs) {
function makeSrcAttr(attrName) {
return {
valType: 'string',
description: 'Sets the source reference on Chart Studio Cloud for `' + attrName + '`.',
editType: 'none'
};
}

function setRole(attrs) {
function callback(attr, attrName, attrs) {
if(exports.isValObject(attr)) {
if(attr.arrayOk === true || attr.valType === 'data_array') {
// all 'arrayOk' and 'data_array' attrs have a corresponding 'src' attr
attrs[attrName + 'src'] = makeSrcAttr(attrName);
}
} else if(isPlainObject(attr)) {
if(!exports.isValObject(attr) && isPlainObject(attr)) {
// all attrs container objects get role 'object'
attr.role = 'object';
}
Expand Down
2 changes: 1 addition & 1 deletion src/plot_api/to_image.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function toImage(gd, opts) {
}

if(format === 'full-json') {
var json = plots.graphJson(clonedGd, false, 'keepdata', 'object', true, true);
var json = plots.graphJson(clonedGd, false, 'object', true, true);
json.version = version;
json = JSON.stringify(json);
cleanup();
Expand Down
11 changes: 0 additions & 11 deletions src/plots/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,17 +318,6 @@ module.exports = {
'other locales may alter this default.'
].join(' ')
},
hidesources: {
valType: 'boolean',
dflt: false,
editType: 'plot',
description: [
'Determines whether or not a text link citing the data source is',
'placed at the bottom-right cored of the figure.',
'Has only an effect only on graphs that have been generated via',
'forked graphs from the Chart Studio Cloud (at https://chart-studio.plotly.com or on-premise).'
].join(' ')
},
showlegend: {
// handled in legend.supplyLayoutDefaults
// but included here because it's not in the legend object
Expand Down
29 changes: 3 additions & 26 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ plots.sendDataToCloud = function(gd) {
name: 'data'
});

hiddenformInput.node().value = plots.graphJson(gd, false, 'keepdata');
hiddenformInput.node().value = plots.graphJson(gd, false);
hiddenform.node().submit();
hiddenformDiv.remove();

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

coerce('separators', formatObj.decimal + formatObj.thousands);
coerce('hidesources');

coerce('colorway');

Expand Down Expand Up @@ -1964,7 +1963,7 @@ plots.didMarginChange = function(margin0, margin1) {
/**
* JSONify the graph data and layout
*
* This function needs to recurse because some src can be inside
* This function needs to recurse because some objects can be inside
* sub-objects.
*
* It also strips out functions and private (starts with _) elements.
Expand All @@ -1973,18 +1972,12 @@ plots.didMarginChange = function(margin0, margin1) {
*
* @param gd The graphDiv
* @param {Boolean} dataonly If true, don't return layout.
* @param {'keepref'|'keepdata'|'keepall'} [mode='keepref'] Filter what's kept
* keepref: remove data for which there's a src present
* eg if there's xsrc present (and xsrc is well-formed,
* ie has : and some chars before it), strip out x
* keepdata: remove all src tags, don't remove the data itself
* keepall: keep data and src
* @param {String} output If you specify 'object', the result will not be stringified
* @param {Boolean} useDefaults If truthy, use _fullLayout and _fullData
* @param {Boolean} includeConfig If truthy, include _context
* @returns {Object|String}
*/
plots.graphJson = function(gd, dataonly, mode, output, useDefaults, includeConfig) {
plots.graphJson = function(gd, dataonly, output, useDefaults, includeConfig) {
// if the defaults aren't supplied yet, we need to do that...
if((useDefaults && dataonly && !gd._fullData) ||
(useDefaults && !dataonly && !gd._fullLayout)) {
Expand All @@ -2001,7 +1994,6 @@ plots.graphJson = function(gd, dataonly, mode, output, useDefaults, includeConfi
}
if(Lib.isPlainObject(d)) {
var o = {};
var src;
Object.keys(d).sort().forEach(function(v) {
// remove private elements and functions
// _ is for private, [ is a mistake ie [object Object]
Expand All @@ -2013,21 +2005,6 @@ plots.graphJson = function(gd, dataonly, mode, output, useDefaults, includeConfi
return;
}

// look for src/data matches and remove the appropriate one
if(mode === 'keepdata') {
// keepdata: remove all ...src tags
if(v.slice(-3) === 'src') {
return;
}
} else if(mode !== 'keepall') {
// keepref: remove sourced data but only
// if the source tag is well-formed
src = d[v + 'src'];
if(typeof src === 'string' && src.indexOf(':') > 0) {
return;
}
}

// OK, we're including this... recurse into it
o[v] = stripObj(d[v], keepFunction);
});
Expand Down
1 change: 0 additions & 1 deletion src/snapshot/cloneplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ function cloneLayoutOverride(tileClass) {
case 'thumbnail':
override = {
title: {text: ''},
hidesources: true,
showlegend: false,
borderwidth: 0,
bordercolor: '',
Expand Down
1 change: 0 additions & 1 deletion src/types/generated/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16254,7 +16254,6 @@ export interface Layout {
yside?: 'left' | 'left plot' | 'right plot' | 'right';
};
height?: number;
hidesources?: boolean;
hoveranywhere?: boolean;
hoverdistance?: number;
hoverlabel?: {
Expand Down
17 changes: 0 additions & 17 deletions tasks/generate_schema_types.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -455,16 +455,6 @@ function valTypeToTS(attr, attrPath) {
// Structural helpers
// ---------------------------------------------------------------------------

/**
* Returns true if key looks like an auto-generated *src attribute.
* These are created for Chart Studio Cloud and shouldn't appear in types.
*/
function isSrcAttr(key, siblings) {
if (!key.endsWith('src')) return false;
const base = key.slice(0, -3);
return base in siblings;
}

/**
* Detect a linked-to-array container in the serialized schema.
*
Expand Down Expand Up @@ -508,7 +498,6 @@ function containerFingerprint(attrs) {
for (const key of Object.keys(attrs).sort()) {
if (META_KEYS.has(key)) continue;
const val = attrs[key];
if (isSrcAttr(key, attrs)) continue;
if (val == null) continue;

if (typeof val === 'string') {
Expand Down Expand Up @@ -546,7 +535,6 @@ function collectFingerprints(attrs, collector) {
for (const key of Object.keys(attrs).sort()) {
if (META_KEYS.has(key)) continue;
const val = attrs[key];
if (isSrcAttr(key, attrs)) continue;
if (val == null || typeof val !== 'object' || val.valType) continue;

let containerAttrs;
Expand Down Expand Up @@ -586,7 +574,6 @@ function countProperties(attrs) {
let count = 0;
for (const key of Object.keys(attrs)) {
if (META_KEYS.has(key)) continue;
if (isSrcAttr(key, attrs)) continue;
const val = attrs[key];
if (val == null) continue;
if (typeof val === 'string' || typeof val !== 'object') {
Expand Down Expand Up @@ -759,9 +746,6 @@ function attrsToProperties(attrs, indent, pathPrefix, sharedTypes, fieldOverride

const val = attrs[key];

// Skip src attributes
if (isSrcAttr(key, attrs)) continue;

// Skip null/undefined
if (val == null) continue;

Expand Down Expand Up @@ -928,7 +912,6 @@ function generateLayoutProperties(layoutAttrs, sharedTypes, subplotGroups, array
for (const key of Object.keys(layoutAttrs).sort()) {
if (META_KEYS.has(key)) continue;
const val = layoutAttrs[key];
if (isSrcAttr(key, layoutAttrs)) continue;
if (val == null) continue;

// String literal
Expand Down
3 changes: 1 addition & 2 deletions test/image/mocks/0.json
Original file line number Diff line number Diff line change
Expand Up @@ -1217,7 +1217,6 @@
"barmode": "stack",
"bargap": 0.2,
"bargroupgap": 0,
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
3 changes: 1 addition & 2 deletions test/image/mocks/1.json
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,6 @@
"hovermode": "x",
"dragmode": "zoom",
"boxmode": "overlay",
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
3 changes: 1 addition & 2 deletions test/image/mocks/10.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@
"plot_bgcolor": "rgb(255, 255, 255)",
"hovermode": "x",
"dragmode": "zoom",
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
3 changes: 1 addition & 2 deletions test/image/mocks/11.json
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@
"bargap": 0.2,
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
1 change: 0 additions & 1 deletion test/image/mocks/12.json
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,6 @@
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false,
"selections": [
{
"x0": 150,
Expand Down
3 changes: 1 addition & 2 deletions test/image/mocks/13.json
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@
"bargap": 0.2,
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
3 changes: 1 addition & 2 deletions test/image/mocks/14.json
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,6 @@
"bargap": 0.2,
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
3 changes: 1 addition & 2 deletions test/image/mocks/15.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,6 @@
"bargap": 0.2,
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
3 changes: 1 addition & 2 deletions test/image/mocks/17.json
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,6 @@
"bargap": 0.2,
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
1 change: 0 additions & 1 deletion test/image/mocks/18.json
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,6 @@
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false,
"yaxis2": {
"title": {
"text": "sepal width",
Expand Down
1 change: 0 additions & 1 deletion test/image/mocks/19.json
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false,
"yaxis2": {
"title": {
"text": "Click to enter Y2 axis title"
Expand Down
3 changes: 1 addition & 2 deletions test/image/mocks/21.json
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@
"bargap": 0.2,
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
3 changes: 1 addition & 2 deletions test/image/mocks/22.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@
"bargap": 0.2,
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
3 changes: 1 addition & 2 deletions test/image/mocks/23.json
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@
"bargap": 0.2,
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
3 changes: 1 addition & 2 deletions test/image/mocks/24.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@
"bargap": 0.2,
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
3 changes: 1 addition & 2 deletions test/image/mocks/25.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@
"bargap": 0.2,
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
3 changes: 1 addition & 2 deletions test/image/mocks/26.json
Original file line number Diff line number Diff line change
Expand Up @@ -21207,7 +21207,6 @@
"bargap": 0.2,
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".,",
"hidesources": false
"separators": ".,"
}
}
3 changes: 1 addition & 2 deletions test/image/mocks/27.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,6 @@
"bargap": 0.2,
"bargroupgap": 0,
"boxmode": "overlay",
"separators": ".",
"hidesources": false
"separators": "."
}
}
Loading
Loading