Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1819584

Browse filesBrowse files
authored
Merge pull request #3158 from plotly/3058-prune-unsupported-globals
prune global-level trace attributes that are already defined in a trace
2 parents ec0ddd8 + 55881c6 commit 1819584
Copy full SHA for 1819584

File tree

Expand file treeCollapse file tree

15 files changed

+64
-10
lines changed
Filter options
Expand file treeCollapse file tree

15 files changed

+64
-10
lines changed

‎src/plot_api/plot_schema.js

Copy file name to clipboardExpand all lines: src/plot_api/plot_schema.js
+14-2Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ exports.get = function() {
112112
* @param {String} attrName name string
113113
* @param {object[]} attrs all the attributes
114114
* @param {Number} level the recursion level, 0 at the root
115+
* @param {String} fullAttrString full attribute name (ie 'marker.line')
115116
* @param {Number} [specifiedLevel]
116117
* The level in the tree, in order to let the callback function detect descend or backtrack,
117118
* typically unsupplied (implied 0), just used by the self-recursive call.
@@ -460,11 +461,22 @@ function getTraceAttributes(type) {
460461
// make 'type' the first attribute in the object
461462
attributes.type = null;
462463

464+
465+
var copyBaseAttributes = extendDeepAll({}, baseAttributes);
466+
var copyModuleAttributes = extendDeepAll({}, _module.attributes);
467+
468+
// prune global-level trace attributes that are already defined in a trace
469+
exports.crawl(copyModuleAttributes, function(attr, attrName, attrs, level, fullAttrString) {
470+
Lib.nestedProperty(copyBaseAttributes, fullAttrString).set(undefined);
471+
// Prune undefined attributes
472+
if(attr === undefined) Lib.nestedProperty(copyModuleAttributes, fullAttrString).set(undefined);
473+
});
474+
463475
// base attributes (same for all trace types)
464-
extendDeepAll(attributes, baseAttributes);
476+
extendDeepAll(attributes, copyBaseAttributes);
465477

466478
// module attributes
467-
extendDeepAll(attributes, _module.attributes);
479+
extendDeepAll(attributes, copyModuleAttributes);
468480

469481
// subplot attributes
470482
if(basePlotModule.attributes) {

‎src/plots/plots.js

Copy file name to clipboardExpand all lines: src/plots/plots.js
+19-4Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,7 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac
11251125
// we want even invisible traces to make their would-be subplots visible
11261126
// so coerce the subplot id(s) now no matter what
11271127
var _module = plots.getModule(traceOut);
1128+
11281129
traceOut._module = _module;
11291130
if(_module) {
11301131
var basePlotModule = _module.basePlotModule;
@@ -1158,6 +1159,18 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac
11581159
}
11591160
}
11601161

1162+
function coerceUnlessPruned(attr, dflt, cb) {
1163+
if(_module && (attr in _module.attributes) && _module.attributes[attr] === undefined) {
1164+
// Pruned
1165+
} else {
1166+
if(cb && typeof cb === 'function') {
1167+
cb();
1168+
} else {
1169+
coerce(attr, dflt);
1170+
}
1171+
}
1172+
}
1173+
11611174
if(visible) {
11621175
coerce('customdata');
11631176
coerce('ids');
@@ -1171,10 +1184,12 @@ plots.supplyTraceDefaults = function(traceIn, traceOut, colorIndex, layout, trac
11711184
traceOut._dfltShowLegend = false;
11721185
}
11731186

1174-
Registry.getComponentMethod(
1175-
'fx',
1176-
'supplyDefaults'
1177-
)(traceIn, traceOut, defaultColor, layout);
1187+
coerceUnlessPruned('hoverlabel', '', function() {
1188+
Registry.getComponentMethod(
1189+
'fx',
1190+
'supplyDefaults'
1191+
)(traceIn, traceOut, defaultColor, layout);
1192+
});
11781193

11791194
// TODO add per-base-plot-module trace defaults step
11801195

‎src/traces/carpet/attributes.js

Copy file name to clipboardExpand all lines: src/traces/carpet/attributes.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,4 +127,5 @@ module.exports = {
127127
'Individual pieces can override this.'
128128
].join(' ')
129129
},
130+
transforms: undefined
130131
};

‎src/traces/cone/attributes.js

Copy file name to clipboardExpand all lines: src/traces/cone/attributes.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,6 @@ attrs.hoverinfo = extendFlat({}, baseAttrs.hoverinfo, {
180180
dflt: 'x+y+z+norm+text+name'
181181
});
182182

183+
attrs.transforms = undefined;
184+
183185
module.exports = attrs;

‎src/traces/contourcarpet/attributes.js

Copy file name to clipboardExpand all lines: src/traces/contourcarpet/attributes.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ module.exports = extendFlat({
9090
].join(' ')
9191
}),
9292
editType: 'plot'
93-
}
93+
},
94+
transforms: undefined
9495
},
9596

9697
colorscaleAttrs('', {

‎src/traces/heatmap/attributes.js

Copy file name to clipboardExpand all lines: src/traces/heatmap/attributes.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ module.exports = extendFlat({
111111
'https://github.com/d3/d3-format/blob/master/README.md#locale_format'
112112
].join(' ')
113113
},
114+
transforms: undefined
114115
},
115116
colorscaleAttrs('', {
116117
cLetter: 'z',

‎src/traces/mesh3d/attributes.js

Copy file name to clipboardExpand all lines: src/traces/mesh3d/attributes.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ module.exports = extendFlat({
165165
'Overrides *color* and *vertexcolor*.'
166166
].join(' ')
167167
},
168+
transforms: undefined
168169
},
169170

170171
colorscaleAttrs('', {

‎src/traces/parcoords/attributes.js

Copy file name to clipboardExpand all lines: src/traces/parcoords/attributes.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ var templatedArray = require('../../plot_api/plot_template').templatedArray;
2020
module.exports = {
2121
domain: domainAttrs({name: 'parcoords', trace: true, editType: 'calc'}),
2222

23+
hoverlabel: undefined,
24+
2325
labelfont: fontAttrs({
2426
editType: 'calc',
2527
description: 'Sets the font for the `dimension` labels.'

‎src/traces/pointcloud/attributes.js

Copy file name to clipboardExpand all lines: src/traces/pointcloud/attributes.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,5 +141,6 @@ module.exports = {
141141
editType: 'calc'
142142
},
143143
editType: 'calc'
144-
}
144+
},
145+
transforms: undefined
145146
};

‎src/traces/sankey/attributes.js

Copy file name to clipboardExpand all lines: src/traces/sankey/attributes.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var domainAttrs = require('../../plots/domain').attributes;
1717
var extendFlat = require('../../lib/extend').extendFlat;
1818
var overrideAll = require('../../plot_api/edit_types').overrideAll;
1919

20-
module.exports = overrideAll({
20+
var attrs = module.exports = overrideAll({
2121
hoverinfo: extendFlat({}, plotAttrs.hoverinfo, {
2222
flags: [],
2323
arrayOk: false,
@@ -219,3 +219,4 @@ module.exports = overrideAll({
219219
description: 'The links of the Sankey plot.'
220220
}
221221
}, 'calc', 'nested');
222+
attrs.transforms = undefined;

‎src/traces/streamtube/attributes.js

Copy file name to clipboardExpand all lines: src/traces/streamtube/attributes.js
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,6 @@ attrs.hoverinfo = extendFlat({}, baseAttrs.hoverinfo, {
152152
dflt: 'x+y+z+norm+text+name'
153153
});
154154

155+
attrs.transforms = undefined;
156+
155157
module.exports = attrs;

‎src/traces/surface/attributes.js

Copy file name to clipboardExpand all lines: src/traces/surface/attributes.js
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,4 @@ colorscaleAttrs('', {
256256
}), 'calc', 'nested');
257257

258258
attrs.x.editType = attrs.y.editType = attrs.z.editType = 'calc+clearAxisTypes';
259+
attrs.transforms = undefined;

‎src/traces/table/attributes.js

Copy file name to clipboardExpand all lines: src/traces/table/attributes.js
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ var overrideAll = require('../../plot_api/edit_types').overrideAll;
1414
var fontAttrs = require('../../plots/font_attributes');
1515
var domainAttrs = require('../../plots/domain').attributes;
1616

17-
module.exports = overrideAll({
17+
var attrs = module.exports = overrideAll({
1818
domain: domainAttrs({name: 'table', trace: true}),
1919

2020
columnwidth: {
@@ -198,3 +198,4 @@ module.exports = overrideAll({
198198
font: extendFlat({}, fontAttrs({arrayOk: true}))
199199
}
200200
}, 'calc', 'from-root');
201+
attrs.transforms = undefined;

‎test/jasmine/bundle_tests/plotschema_test.js

Copy file name to clipboardExpand all lines: test/jasmine/bundle_tests/plotschema_test.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,11 @@ describe('plot schema', function() {
362362
expect(typeof splomAttrs.yaxes.items.regex).toBe('string');
363363
expect(splomAttrs.yaxes.items.regex).toBe('/^y([2-9]|[1-9][0-9]+)?$/');
364364
});
365+
366+
it('should prune unsupported global-level trace attributes', function() {
367+
expect(Plotly.PlotSchema.get().traces.sankey.attributes.hoverinfo.flags.length).toBe(0);
368+
});
369+
365370
});
366371

367372
describe('getTraceValObject', function() {

‎test/jasmine/tests/parcoords_test.js

Copy file name to clipboardExpand all lines: test/jasmine/tests/parcoords_test.js
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ describe('parcoords initialization tests', function() {
7979
expect(gd._fullData[0].tickfont).toEqual(expected);
8080
expect(gd._fullData[0].rangefont).toEqual(expected);
8181
});
82+
83+
it('should not coerce hoverlabel', function() {
84+
var gd = Lib.extendDeep({}, mock1);
85+
86+
supplyAllDefaults(gd);
87+
88+
expect(gd._fullData[0].hoverlabel).toBeUndefined();
89+
});
8290
});
8391

8492
describe('parcoords defaults', function() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.