Skip to content

Drop support for deprecated annotation.ref attribute (use annotation.xref and annotation.yref instead) #7215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 8, 2024
Merged
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/7215_remove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop support for deprecated `annotation.ref` attribute (use `annotation.xref` and `annotation.yref` instead) [[#7215](https://github.com/plotly/plotly.js/pull/7215)]
10 changes: 0 additions & 10 deletions src/components/annotations/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,4 @@ module.exports = templatedArray('annotation', {
].join(' ')
},
editType: 'calc',

_deprecated: {
ref: {
valType: 'string',
editType: 'calc',
description: [
'Obsolete. Set `xref` and `yref` separately instead.'
].join(' ')
}
}
});
11 changes: 0 additions & 11 deletions src/plot_api/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,6 @@ exports.cleanLayout = function(layout) {

if(!Lib.isPlainObject(ann)) continue;

if(ann.ref) {
if(ann.ref === 'paper') {
ann.xref = 'paper';
ann.yref = 'paper';
} else if(ann.ref === 'data') {
ann.xref = 'x';
ann.yref = 'y';
}
delete ann.ref;
}

cleanAxRef(ann, 'xref');
cleanAxRef(ann, 'yref');
}
Expand Down
3 changes: 2 additions & 1 deletion test/image/mocks/11.json
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@
"xatype": "category",
"yatype": "linear",
"tag": "",
"ref": "paper"
"xref": "paper",
"yref": "paper"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just for my own learning, why has the "ref" property become "xref" and "yref"?

Copy link
Collaborator

@alexcjohnson alexcjohnson Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that you can place an annotation at a fixed horizontal position (xref=“paper”) and data-referenced vertical position (yref=“y”) for example. With a single ref things like that are not possible.

}
],
"margin": {
Expand Down
18 changes: 12 additions & 6 deletions test/image/mocks/14.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@
"xatype": "log",
"yatype": "log",
"tag": "",
"ref": "plot"
"xref": "plot",
"yref": "plot"
},
{
"x": 0.15585471975544452,
Expand Down Expand Up @@ -198,7 +199,8 @@
"xatype": "log",
"yatype": "log",
"tag": "",
"ref": "plot"
"xref": "plot",
"yref": "plot"
},
{
"x": 1.8420351138192386,
Expand Down Expand Up @@ -229,7 +231,8 @@
"xatype": "log",
"yatype": "log",
"tag": "",
"ref": "plot"
"xref": "plot",
"yref": "plot"
},
{
"x": -0.5537301200821234,
Expand Down Expand Up @@ -260,7 +263,8 @@
"xatype": "log",
"yatype": "log",
"tag": "",
"ref": "plot"
"xref": "plot",
"yref": "plot"
},
{
"x": -2.701204903100102,
Expand Down Expand Up @@ -291,7 +295,8 @@
"xatype": "log",
"yatype": "log",
"tag": "",
"ref": "plot"
"xref": "plot",
"yref": "plot"
},
{
"x": -1.6961577824283882,
Expand Down Expand Up @@ -322,7 +327,8 @@
"xatype": "log",
"yatype": "log",
"tag": "",
"ref": "plot"
"xref": "plot",
"yref": "plot"
}
],
"margin": {
Expand Down
3 changes: 2 additions & 1 deletion test/image/mocks/17.json
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,8 @@
"xatype": "linear",
"yatype": "linear",
"tag": "",
"ref": "plot"
"xref": "plot",
"yref": "plot"
}
],
"margin": {
Expand Down
3 changes: 2 additions & 1 deletion test/image/mocks/27.json
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@
"xatype": "linear",
"yatype": "linear",
"tag": "",
"ref": "plot"
"xref": "plot",
"yref": "plot"
}
],
"margin": {
Expand Down
3 changes: 2 additions & 1 deletion test/image/mocks/29.json
Original file line number Diff line number Diff line change
Expand Up @@ -2256,7 +2256,8 @@
"xanchor": "auto",
"yanchor": "auto",
"tag": "",
"ref": "paper"
"xref": "paper",
"yref": "paper"
}
],
"margin": {
Expand Down
6 changes: 2 additions & 4 deletions test/jasmine/tests/plot_api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2540,7 +2540,6 @@ describe('Test plot api', function() {

var layout = {
annotations: [
{ ref: 'paper' },
null,
{ xref: 'x02', yref: 'y1' }
],
Expand All @@ -2553,9 +2552,8 @@ describe('Test plot api', function() {

Plotly.newPlot(gd, data, layout);

expect(gd.layout.annotations[0]).toEqual({ xref: 'paper', yref: 'paper' });
expect(gd.layout.annotations[1]).toEqual(null);
expect(gd.layout.annotations[2]).toEqual({ xref: 'x2', yref: 'y' });
expect(gd.layout.annotations[0]).toEqual(null);
expect(gd.layout.annotations[1]).toEqual({ xref: 'x2', yref: 'y' });

expect(gd.layout.shapes[0].xref).toBeUndefined();
expect(gd.layout.shapes[0].yref).toBeUndefined();
Expand Down
7 changes: 0 additions & 7 deletions test/plot-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -730,13 +730,6 @@
"annotations": {
"items": {
"annotation": {
"_deprecated": {
"ref": {
"description": "Obsolete. Set `xref` and `yref` separately instead.",
"editType": "calc",
"valType": "string"
}
},
"align": {
"description": "Sets the horizontal alignment of the `text` within the box. Has an effect only if `text` spans two or more lines (i.e. `text` contains one or more <br> HTML tags) or if an explicit width is set to override the text width.",
"dflt": "center",
Expand Down