Skip to content

Commit e54e65c

Browse files
committed
remove support for 'title' as string, and remove 'titlefont', 'titleside', 'titleoffset', and 'titleposition'
1 parent d5d3712 commit e54e65c

File tree

11 files changed

+10
-238
lines changed

11 files changed

+10
-238
lines changed

src/components/titles/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ var SUBTITLE_PADDING_EM = 1.6;
2222
* @param {DOM element} gd - the graphDiv
2323
* @param {string} titleClass - the css class of this title
2424
* @param {object} options - how and what to draw
25-
* propContainer - the layout object containing `title` and `titlefont`
26-
* attributes that apply to this title
25+
* propContainer - the layout object containing the `title` attribute that
26+
* applies to this title
2727
* propName - the full name of the title property (for Plotly.relayout)
2828
* [traceIndex] - include only if this property applies to one trace
2929
* (such as a colorbar title) - then editing pipes to Plotly.restyle

src/plot_api/helpers.js

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,6 @@ exports.cleanLayout = function(layout) {
9090
delete ax.autotick;
9191
}
9292

93-
cleanTitle(ax);
94-
} else if(polarAttrRegex && polarAttrRegex.test(key)) {
95-
// modifications for polar
96-
97-
var polar = layout[key];
98-
cleanTitle(polar.radialaxis);
99-
} else if(ternaryAttrRegex && ternaryAttrRegex.test(key)) {
100-
// modifications for ternary
101-
102-
var ternary = layout[key];
103-
cleanTitle(ternary.aaxis);
104-
cleanTitle(ternary.baxis);
105-
cleanTitle(ternary.caxis);
10693
} else if(sceneAttrRegex && sceneAttrRegex.test(key)) {
10794
// modifications for 3D scenes
10895

@@ -130,11 +117,6 @@ exports.cleanLayout = function(layout) {
130117

131118
delete scene.cameraposition;
132119
}
133-
134-
// clean axis titles
135-
cleanTitle(scene.xaxis);
136-
cleanTitle(scene.yaxis);
137-
cleanTitle(scene.zaxis);
138120
}
139121
}
140122

@@ -199,9 +181,6 @@ exports.cleanLayout = function(layout) {
199181
}
200182
}
201183

202-
// clean plot title
203-
cleanTitle(layout);
204-
205184
/*
206185
* Moved from rotate -> orbit for dragmode
207186
*/
@@ -227,44 +206,6 @@ function cleanAxRef(container, attr) {
227206
}
228207
}
229208

230-
/**
231-
* Cleans up old title attribute structure (flat) in favor of the new one (nested).
232-
*
233-
* @param {Object} titleContainer - an object potentially including deprecated title attributes
234-
*/
235-
function cleanTitle(titleContainer) {
236-
if(titleContainer) {
237-
// title -> title.text
238-
// (although title used to be a string attribute,
239-
// numbers are accepted as well)
240-
if(typeof titleContainer.title === 'string' || typeof titleContainer.title === 'number') {
241-
titleContainer.title = {
242-
text: titleContainer.title
243-
};
244-
}
245-
246-
rewireAttr('titlefont', 'font');
247-
rewireAttr('titleposition', 'position');
248-
rewireAttr('titleside', 'side');
249-
rewireAttr('titleoffset', 'offset');
250-
}
251-
252-
function rewireAttr(oldAttrName, newAttrName) {
253-
var oldAttrSet = titleContainer[oldAttrName];
254-
var newAttrSet = titleContainer.title && titleContainer.title[newAttrName];
255-
256-
if(oldAttrSet && !newAttrSet) {
257-
// Ensure title object exists
258-
if(!titleContainer.title) {
259-
titleContainer.title = {};
260-
}
261-
262-
titleContainer.title[newAttrName] = titleContainer[oldAttrName];
263-
delete titleContainer[oldAttrName];
264-
}
265-
}
266-
}
267-
268209
/*
269210
* cleanData: Make a few changes to the data for backward compatibility
270211
* before it gets used for anything. Modifies the data traces users provide.
@@ -467,13 +408,6 @@ exports.cleanData = function(data) {
467408
delete trace.autobiny;
468409
delete trace.ybins;
469410
}
470-
471-
cleanTitle(trace);
472-
if(trace.colorbar) cleanTitle(trace.colorbar);
473-
if(trace.marker && trace.marker.colorbar) cleanTitle(trace.marker.colorbar);
474-
if(trace.line && trace.line.colorbar) cleanTitle(trace.line.colorbar);
475-
if(trace.aaxis) cleanTitle(trace.aaxis);
476-
if(trace.baxis) cleanTitle(trace.baxis);
477411
}
478412
};
479413

src/plot_api/plot_api.js

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,8 +1397,6 @@ function _restyle(gd, aobj, traces) {
13971397
var eventData = Lib.extendDeepAll({}, aobj);
13981398
var i;
13991399

1400-
cleanDeprecatedAttributeKeys(aobj);
1401-
14021400
// initialize flags
14031401
var flags = editTypes.traceFlags();
14041402

@@ -1700,49 +1698,6 @@ function _restyle(gd, aobj, traces) {
17001698
};
17011699
}
17021700

1703-
/**
1704-
* Converts deprecated attribute keys to
1705-
* the current API to ensure backwards compatibility.
1706-
*
1707-
* This is needed for the update mechanism to determine which
1708-
* subroutines to run based on the actual attribute
1709-
* definitions (that don't include the deprecated ones).
1710-
*
1711-
* E.g. Maps {'xaxis.title': 'A chart'} to {'xaxis.title.text': 'A chart'}
1712-
* and {titlefont: {...}} to {'title.font': {...}}.
1713-
*
1714-
* @param aobj
1715-
*/
1716-
function cleanDeprecatedAttributeKeys(aobj) {
1717-
var oldAxisTitleRegex = Lib.counterRegex('axis', '\.title', false, false);
1718-
var colorbarRegex = /colorbar\.title$/;
1719-
var keys = Object.keys(aobj);
1720-
var i, key, value;
1721-
1722-
for(i = 0; i < keys.length; i++) {
1723-
key = keys[i];
1724-
value = aobj[key];
1725-
1726-
if((key === 'title' || oldAxisTitleRegex.test(key) || colorbarRegex.test(key)) &&
1727-
(typeof value === 'string' || typeof value === 'number')) {
1728-
replace(key, key.replace('title', 'title.text'));
1729-
} else if(key.indexOf('titlefont') > -1 && key.indexOf('grouptitlefont') === -1) {
1730-
replace(key, key.replace('titlefont', 'title.font'));
1731-
} else if(key.indexOf('titleposition') > -1) {
1732-
replace(key, key.replace('titleposition', 'title.position'));
1733-
} else if(key.indexOf('titleside') > -1) {
1734-
replace(key, key.replace('titleside', 'title.side'));
1735-
} else if(key.indexOf('titleoffset') > -1) {
1736-
replace(key, key.replace('titleoffset', 'title.offset'));
1737-
}
1738-
}
1739-
1740-
function replace(oldAttrStr, newAttrStr) {
1741-
aobj[newAttrStr] = aobj[oldAttrStr];
1742-
delete aobj[oldAttrStr];
1743-
}
1744-
}
1745-
17461701
/**
17471702
* relayout: update layout attributes of an existing plot
17481703
*
@@ -1926,7 +1881,6 @@ function _relayout(gd, aobj) {
19261881

19271882
var arrayStr, i, j;
19281883

1929-
cleanDeprecatedAttributeKeys(aobj);
19301884
keys = Object.keys(aobj);
19311885

19321886
// look for 'allaxes', split out into all axes

src/plots/cartesian/layout_attributes.js

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -207,20 +207,11 @@ module.exports = {
207207
text: {
208208
valType: 'string',
209209
editType: 'ticks',
210-
description: [
211-
'Sets the title of this axis.',
212-
'Note that before the existence of `title.text`, the title\'s',
213-
'contents used to be defined as the `title` attribute itself.',
214-
'This behavior has been deprecated.'
215-
].join(' ')
210+
description: 'Sets the title of this axis.'
216211
},
217212
font: fontAttrs({
218213
editType: 'ticks',
219-
description: [
220-
'Sets this axis\' title font.',
221-
'Note that the title\'s font used to be customized',
222-
'by the now deprecated `titlefont` attribute.'
223-
].join(' ')
214+
description: 'Sets this axis\' title font.'
224215
}),
225216
standoff: {
226217
valType: 'number',
@@ -1250,20 +1241,5 @@ module.exports = {
12501241
'Set `tickmode` to *linear* for `autotick` *false*.'
12511242
].join(' ')
12521243
},
1253-
title: {
1254-
valType: 'string',
1255-
editType: 'ticks',
1256-
description: [
1257-
'Value of `title` is no longer a simple *string* but a set of sub-attributes.',
1258-
'To set the axis\' title, please use `title.text` now.'
1259-
].join(' ')
1260-
},
1261-
titlefont: fontAttrs({
1262-
editType: 'ticks',
1263-
description: [
1264-
'Former `titlefont` is now the sub-attribute `font` of `title`.',
1265-
'To customize title font properties, please use `title.font` now.'
1266-
].join(' ')
1267-
})
12681244
}
12691245
};

src/plots/cartesian/tick_label_defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
2727
var position = containerOut.ticklabelposition || '';
2828
var dfltFontColor = position.indexOf('inside') !== -1 ?
2929
contrast(options.bgColor) :
30-
// as with titlefont.color, inherit axis.color only if one was
30+
// as with title.font.color, inherit axis.color only if one was
3131
// explicitly provided
3232
(contColor && contColor !== layoutAttributes.color.dflt) ?
3333
contColor : font.color;

src/plots/gl3d/layout/axis_attributes.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,5 @@ module.exports = overrideAll({
122122
zerolinecolor: axesAttrs.zerolinecolor,
123123
zerolinewidth: axesAttrs.zerolinewidth,
124124
_deprecated: {
125-
title: axesAttrs._deprecated.title,
126-
titlefont: axesAttrs._deprecated.titlefont
127125
}
128126
}, 'plot', 'from-root');

src/plots/layout_attributes.js

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,11 @@ module.exports = {
2626
text: {
2727
valType: 'string',
2828
editType: 'layoutstyle',
29-
description: [
30-
'Sets the plot\'s title.',
31-
'Note that before the existence of `title.text`, the title\'s',
32-
'contents used to be defined as the `title` attribute itself.',
33-
'This behavior has been deprecated.'
34-
].join(' ')
29+
description: 'Sets the plot\'s title.'
3530
},
3631
font: fontAttrs({
3732
editType: 'layoutstyle',
38-
description: [
39-
'Sets the title font.',
40-
'Note that the title\'s font used to be customized',
41-
'by the now deprecated `titlefont` attribute.'
42-
].join(' ')
33+
description: 'Sets the title font.'
4334
}),
4435
subtitle: {
4536
text: {
@@ -461,20 +452,5 @@ module.exports = {
461452
editType: 'none'
462453
}),
463454
_deprecated: {
464-
title: {
465-
valType: 'string',
466-
editType: 'layoutstyle',
467-
description: [
468-
'Value of `title` is no longer a simple *string* but a set of sub-attributes.',
469-
'To set the contents of the title, please use `title.text` now.'
470-
].join(' ')
471-
},
472-
titlefont: fontAttrs({
473-
editType: 'layoutstyle',
474-
description: [
475-
'Former `titlefont` is now the sub-attribute `font` of `title`.',
476-
'To customize title font properties, please use `title.font` now.'
477-
].join(' ')
478-
})
479455
}
480456
};

src/plots/polar/layout_attributes.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ var radialAxisAttrs = {
148148
editType: 'calc',
149149

150150
_deprecated: {
151-
title: axesAttrs._deprecated.title,
152-
titlefont: axesAttrs._deprecated.titlefont
153151
}
154152
};
155153

src/plots/ternary/layout_attributes.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ var ternaryAxesAttrs = {
6363
].join(' ')
6464
},
6565
_deprecated: {
66-
title: axesAttrs._deprecated.title,
67-
titlefont: axesAttrs._deprecated.titlefont
6866
}
6967
};
7068

src/traces/carpet/axis_attributes.js

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,11 @@ module.exports = {
3232
valType: 'string',
3333
dflt: '',
3434
editType: 'calc',
35-
description: [
36-
'Sets the title of this axis.',
37-
'Note that before the existence of `title.text`, the title\'s',
38-
'contents used to be defined as the `title` attribute itself.',
39-
'This behavior has been deprecated.'
40-
].join(' ')
35+
description: 'Sets the title of this axis.'
4136
},
4237
font: fontAttrs({
4338
editType: 'calc',
44-
description: [
45-
'Sets this axis\' title font.',
46-
'Note that the title\'s font used to be set',
47-
'by the now deprecated `titlefont` attribute.'
48-
].join(' ')
39+
description: 'Sets this axis\' title font.',
4940
}),
5041
// TODO how is this different than `title.standoff`
5142
offset: {
@@ -55,8 +46,6 @@ module.exports = {
5546
description: [
5647
'An additional amount by which to offset the title from the tick',
5748
'labels, given in pixels.',
58-
'Note that this used to be set',
59-
'by the now deprecated `titleoffset` attribute.'
6049
].join(' '),
6150
},
6251
editType: 'calc',
@@ -464,25 +453,6 @@ module.exports = {
464453
},
465454

466455
_deprecated: {
467-
title: {
468-
valType: 'string',
469-
editType: 'calc',
470-
description: [
471-
'Deprecated in favor of `title.text`.',
472-
'Note that value of `title` is no longer a simple',
473-
'*string* but a set of sub-attributes.'
474-
].join(' ')
475-
},
476-
titlefont: fontAttrs({
477-
editType: 'calc',
478-
description: 'Deprecated in favor of `title.font`.'
479-
}),
480-
titleoffset: {
481-
valType: 'number',
482-
dflt: 10,
483-
editType: 'calc',
484-
description: 'Deprecated in favor of `title.offset`.'
485-
}
486456
},
487457

488458
editType: 'calc'

0 commit comments

Comments
 (0)