Skip to content

Commit

Permalink
update uirevisions for new title attribute structure #3276
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcjohnson committed Nov 30, 2018
1 parent d9b3aea commit 0621e43
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
10 changes: 5 additions & 5 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2427,22 +2427,22 @@ exports._guiUpdate = guiEdit(update);
// Ordered by most common edits first, to minimize our search time
var layoutUIControlPatterns = [
{pattern: /^hiddenlabels/, attr: 'legend.uirevision'},
{pattern: /^((x|y)axis\d*)\.((auto)?range|title)/},
{pattern: /^((x|y)axis\d*)\.((auto)?range|title\.text)/},

// showspikes and modes include those nested inside scenes
{pattern: /axis\d*\.showspikes$/, attr: 'modebar.uirevision'},
{pattern: /(hover|drag)mode$/, attr: 'modebar.uirevision'},

{pattern: /^(scene\d*)\.camera/},
{pattern: /^(geo\d*)\.(projection|center)/},
{pattern: /^(ternary\d*\.[abc]axis)\.(min|title)$/},
{pattern: /^(polar\d*\.radialaxis)\.((auto)?range|angle|title)/},
{pattern: /^(ternary\d*\.[abc]axis)\.(min|title\.text)$/},
{pattern: /^(polar\d*\.radialaxis)\.((auto)?range|angle|title\.text)/},
{pattern: /^(polar\d*\.angularaxis)\.rotation/},
{pattern: /^(mapbox\d*)\.(center|zoom|bearing|pitch)/},

{pattern: /^legend\.(x|y)$/, attr: 'editrevision'},
{pattern: /^(shapes|annotations)/, attr: 'editrevision'},
{pattern: /^title$/, attr: 'editrevision'}
{pattern: /^title\.text$/, attr: 'editrevision'}
];

// same for trace attributes: if `attr` is given it's in layout,
Expand All @@ -2461,7 +2461,7 @@ var traceUIControlPatterns = [
// "name" also includes transform.styles
{pattern: /(^|value\.)name$/},
// including nested colorbar attributes (ie marker.colorbar)
{pattern: /colorbar\.title$/},
{pattern: /colorbar\.title\.text$/},
{pattern: /colorbar\.(x|y)$/, attr: 'editrevision'}
];

Expand Down
3 changes: 3 additions & 0 deletions src/plots/polar/layout_attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ var radialAxisAttrs = {
}
};

// radial title is not gui-editable, so it needs dflt: '', similar to carpet axes.
radialAxisAttrs.title.text.dflt = '';

extendFlat(
radialAxisAttrs,

Expand Down
20 changes: 10 additions & 10 deletions test/jasmine/tests/plot_api_react_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ describe('Plotly.react and uirevision attributes', function() {
function editEditable() {
return Registry.call('_guiUpdate', gd,
{'colorbar.x': 0.8, 'colorbar.y': 0.6},
{title: 'yep', 'legend.x': 1.1, 'legend.y': 0.9},
{'title.text': 'yep', 'legend.x': 1.1, 'legend.y': 0.9},
[2]
);
}
Expand All @@ -1653,7 +1653,7 @@ describe('Plotly.react and uirevision attributes', function() {
'colorbar.x': original ? [undefined, 1.02] : 0.8,
'colorbar.y': original ? [undefined, 0.5] : 0.6
}], {
title: original ? [undefined, 'Click to enter Plot title'] : 'yep',
'title.text': original ? [undefined, 'Click to enter Plot title'] : 'yep',
'legend.x': original ? [undefined, 1.02] : 1.1,
'legend.y': original ? [undefined, 1] : 0.9
});
Expand Down Expand Up @@ -1688,7 +1688,7 @@ describe('Plotly.react and uirevision attributes', function() {
return {
'dimensions[0].constraintrange': original ? [[2.5, 3.5]] : [[[1.5, 2.5], [2.938, 3.979]]],
'dimensions[1].constraintrange': original ? undefined : [[6.937, 7.979]],
'line.colorbar.title': original ? [undefined, 'Click to enter Colorscale title'] : 'color',
'line.colorbar.title.text': original ? [undefined, 'Click to enter Colorscale title'] : 'color',
name: original ? [undefined, 'trace 0'] : 'name'
};
}
Expand All @@ -1700,7 +1700,7 @@ describe('Plotly.react and uirevision attributes', function() {
function editTrace() {
var _;
return Registry.call('_guiRestyle', gd,
{'line.colorbar.title': 'color', name: 'name'},
{'line.colorbar.title.text': 'color', name: 'name'},
[0]
)
.then(function() {
Expand Down Expand Up @@ -1742,12 +1742,12 @@ describe('Plotly.react and uirevision attributes', function() {

function attrs(original) {
return {
'xaxis.title': original ? [undefined, 'Click to enter X axis title'] : 'XXX',
'yaxis.title': original ? [undefined, 'Click to enter Y axis title'] : 'YYY',
'ternary.aaxis.title': original ? [undefined, 'Component A'] : 'AAA',
'ternary.baxis.title': original ? [undefined, 'Component B'] : 'BBB',
'ternary.caxis.title': original ? [undefined, 'Component C'] : 'CCC',
'polar.radialaxis.title': original ? [undefined, ''] : 'RRR'
'xaxis.title.text': original ? [undefined, 'Click to enter X axis title'] : 'XXX',
'yaxis.title.text': original ? [undefined, 'Click to enter Y axis title'] : 'YYY',
'ternary.aaxis.title.text': original ? [undefined, 'Component A'] : 'AAA',
'ternary.baxis.title.text': original ? [undefined, 'Component B'] : 'BBB',
'ternary.caxis.title.text': original ? [undefined, 'Component C'] : 'CCC',
'polar.radialaxis.title.text': original ? [undefined, ''] : 'RRR'
};
}

Expand Down

0 comments on commit 0621e43

Please sign in to comment.