Skip to content
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

Drop support for deprecated error bar opacity attribute (use alpha channel of error bar color attribute instead) #7216

Merged
merged 8 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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/7216_remove.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Drop support for deprecated error bar `opacity` attribute (use alpha channel of error bar `color` attribute instead) [[#7214](https://github.com/plotly/plotly.js/pull/7216)]
13 changes: 1 addition & 12 deletions src/components/errorbars/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ module.exports = {
color: {
valType: 'color',
editType: 'style',
description: 'Sets the stoke color of the error bars.'
description: 'Sets the stroke color of the error bars.'
},
thickness: {
valType: 'number',
Expand All @@ -121,15 +121,4 @@ module.exports = {
].join(' ')
},
editType: 'calc',

_deprecated: {
opacity: {
valType: 'number',
editType: 'style',
description: [
'Obsolete.',
'Use the alpha channel in error bar `color` to set the opacity.'
].join(' ')
}
}
};
12 changes: 0 additions & 12 deletions src/plot_api/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,18 +283,6 @@ exports.cleanData = function(data) {
delete trace.xbins;
}

// error_y.opacity is obsolete - merge into color
if(trace.error_y && 'opacity' in trace.error_y) {
var dc = Color.defaults;
var yeColor = trace.error_y.color || (traceIs(trace, 'bar') ?
Color.defaultLine :
dc[tracei % dc.length]);
trace.error_y.color = Color.addOpacity(
Color.rgb(yeColor),
Color.opacity(yeColor) * trace.error_y.opacity);
delete trace.error_y.opacity;
}

// convert bardir to orientation, and put the data into
// the axes it's eventually going to be used with
if('bardir' in trace) {
Expand Down
6 changes: 2 additions & 4 deletions test/image/mocks/error_bar_style.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,14 @@
"value": 0.1,
"color": "#85144B",
"thickness": 1.5,
"width": 3,
"opacity": 1
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, what happened to "opacity"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

opacity can also be specified by using the alpha channel of the color attribute, which defaults to full-opacity, so the same image result can be achieved without explicitly setting the opacity.

I guess for the purposes of this test it might make sense to include it explicitly though.

Copy link
Contributor

Choose a reason for hiding this comment

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

very happy to use color instead (fewer parameters is better) - was just wondering how we were now handling it - thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't know why we chose to deprecate opacity here though and not elsewhere, maybe @archmoj has an idea

Copy link
Collaborator

Choose a reason for hiding this comment

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

In some places - particularly where multiple colors or multiple objects are involved - there are many different effects you can achieve depending on exactly where you set the opacity

Screenshot 2024-10-08 at 10 15 34

Here though I guess there's nothing you can't achieve just with the opacity of the color.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes perfect sense -- thanks @alexcjohnson .

"width": 3
},
"error_x": {
"type": "constant",
"value": 0.2,
"color": "#85144B",
"thickness": 1.5,
"width": 3,
"opacity": 1
"width": 3
},
"marker": {
"color": "#85144B",
Expand Down
99 changes: 11 additions & 88 deletions test/plot-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17363,13 +17363,6 @@
"valType": "number"
},
"error_x": {
"_deprecated": {
"opacity": {
"description": "Obsolete. Use the alpha channel in error bar `color` to set the opacity.",
"editType": "style",
"valType": "number"
}
},
"array": {
"description": "Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data.",
"editType": "calc",
Expand All @@ -17391,7 +17384,7 @@
"valType": "string"
},
"color": {
"description": "Sets the stoke color of the error bars.",
"description": "Sets the stroke color of the error bars.",
Copy link
Contributor

Choose a reason for hiding this comment

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

good catch

"editType": "style",
"valType": "color"
},
Expand Down Expand Up @@ -17463,13 +17456,6 @@
}
},
"error_y": {
"_deprecated": {
"opacity": {
"description": "Obsolete. Use the alpha channel in error bar `color` to set the opacity.",
"editType": "style",
"valType": "number"
}
},
"array": {
"description": "Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data.",
"editType": "calc",
Expand All @@ -17491,7 +17477,7 @@
"valType": "string"
},
"color": {
"description": "Sets the stoke color of the error bars.",
"description": "Sets the stroke color of the error bars.",
"editType": "style",
"valType": "color"
},
Expand Down Expand Up @@ -43795,13 +43781,6 @@
"valType": "string"
},
"error_x": {
"_deprecated": {
"opacity": {
"description": "Obsolete. Use the alpha channel in error bar `color` to set the opacity.",
"editType": "style",
"valType": "number"
}
},
"array": {
"description": "Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data.",
"editType": "calc",
Expand All @@ -43823,7 +43802,7 @@
"valType": "string"
},
"color": {
"description": "Sets the stoke color of the error bars.",
"description": "Sets the stroke color of the error bars.",
"editType": "style",
"valType": "color"
},
Expand Down Expand Up @@ -43895,13 +43874,6 @@
}
},
"error_y": {
"_deprecated": {
"opacity": {
"description": "Obsolete. Use the alpha channel in error bar `color` to set the opacity.",
"editType": "style",
"valType": "number"
}
},
"array": {
"description": "Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data.",
"editType": "calc",
Expand All @@ -43923,7 +43895,7 @@
"valType": "string"
},
"color": {
"description": "Sets the stoke color of the error bars.",
"description": "Sets the stroke color of the error bars.",
"editType": "style",
"valType": "color"
},
Expand Down Expand Up @@ -64082,13 +64054,6 @@
"valType": "number"
},
"error_x": {
"_deprecated": {
"opacity": {
"description": "Obsolete. Use the alpha channel in error bar `color` to set the opacity.",
"editType": "style",
"valType": "number"
}
},
"array": {
"description": "Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data.",
"editType": "calc",
Expand All @@ -64110,7 +64075,7 @@
"valType": "string"
},
"color": {
"description": "Sets the stoke color of the error bars.",
"description": "Sets the stroke color of the error bars.",
"editType": "style",
"valType": "color"
},
Expand Down Expand Up @@ -64182,13 +64147,6 @@
}
},
"error_y": {
"_deprecated": {
"opacity": {
"description": "Obsolete. Use the alpha channel in error bar `color` to set the opacity.",
"editType": "style",
"valType": "number"
}
},
"array": {
"description": "Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data.",
"editType": "calc",
Expand All @@ -64210,7 +64168,7 @@
"valType": "string"
},
"color": {
"description": "Sets the stoke color of the error bars.",
"description": "Sets the stroke color of the error bars.",
"editType": "style",
"valType": "color"
},
Expand Down Expand Up @@ -67013,13 +66971,6 @@
"valType": "string"
},
"error_x": {
"_deprecated": {
"opacity": {
"description": "Obsolete. Use the alpha channel in error bar `color` to set the opacity.",
"editType": "calc",
"valType": "number"
}
},
"array": {
"description": "Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data.",
"editType": "calc",
Expand All @@ -67041,7 +66992,7 @@
"valType": "string"
},
"color": {
"description": "Sets the stoke color of the error bars.",
"description": "Sets the stroke color of the error bars.",
"editType": "calc",
"valType": "color"
},
Expand Down Expand Up @@ -67113,13 +67064,6 @@
}
},
"error_y": {
"_deprecated": {
"opacity": {
"description": "Obsolete. Use the alpha channel in error bar `color` to set the opacity.",
"editType": "calc",
"valType": "number"
}
},
"array": {
"description": "Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data.",
"editType": "calc",
Expand All @@ -67141,7 +67085,7 @@
"valType": "string"
},
"color": {
"description": "Sets the stoke color of the error bars.",
"description": "Sets the stroke color of the error bars.",
"editType": "calc",
"valType": "color"
},
Expand Down Expand Up @@ -67213,13 +67157,6 @@
}
},
"error_z": {
"_deprecated": {
"opacity": {
"description": "Obsolete. Use the alpha channel in error bar `color` to set the opacity.",
"editType": "calc",
"valType": "number"
}
},
"array": {
"description": "Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data.",
"editType": "calc",
Expand All @@ -67241,7 +67178,7 @@
"valType": "string"
},
"color": {
"description": "Sets the stoke color of the error bars.",
"description": "Sets the stroke color of the error bars.",
"editType": "calc",
"valType": "color"
},
Expand Down Expand Up @@ -74731,13 +74668,6 @@
"valType": "number"
},
"error_x": {
"_deprecated": {
"opacity": {
"description": "Obsolete. Use the alpha channel in error bar `color` to set the opacity.",
"editType": "calc",
"valType": "number"
}
},
"array": {
"description": "Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data.",
"editType": "calc",
Expand All @@ -74759,7 +74689,7 @@
"valType": "string"
},
"color": {
"description": "Sets the stoke color of the error bars.",
"description": "Sets the stroke color of the error bars.",
"editType": "calc",
"valType": "color"
},
Expand Down Expand Up @@ -74831,13 +74761,6 @@
}
},
"error_y": {
"_deprecated": {
"opacity": {
"description": "Obsolete. Use the alpha channel in error bar `color` to set the opacity.",
"editType": "calc",
"valType": "number"
}
},
"array": {
"description": "Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data.",
"editType": "calc",
Expand All @@ -74859,7 +74782,7 @@
"valType": "string"
},
"color": {
"description": "Sets the stoke color of the error bars.",
"description": "Sets the stroke color of the error bars.",
"editType": "calc",
"valType": "color"
},
Expand Down