Skip to content

Apply trace opacity to 'mode: 'lines' legend items #1204

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 7 commits into from
Jan 12, 2017

Conversation

etpinard
Copy link
Contributor

fixes #1174

@etpinard etpinard added status: reviewable bug something broken labels Nov 28, 2016
@@ -30,7 +30,8 @@
9
],
"mode": "lines",
"type": "scatter"
"type": "scatter",
"opacity": 0.5
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be a better test to set the opacity on a lines+markers trace - which I don't think is handled correctly in this PR, trace opacity should get set on traceGroup rather than independently to lines and markers (and fills!).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

First, see

image

trace opacity should get set on traceGroup

that would imply that the trace name (rendered in the <text class="legendtext"> node) would be semi-transparent whenever trace.opacity < 1.

So, in d009798 a new <g> is added grouping the fill, lines and symbols <g> and applying trace.opacity once.

@etpinard etpinard added this to the v1.22.0 milestone Jan 4, 2017
@alexcjohnson
Copy link
Collaborator

So, in d009798 a new is added grouping the fill, lines and symbols and applying trace.opacity once.

👍

and then a test with lines+markers? Ideally with different line and marker colors?

Do you know why 28.png changed the way it did? I don't think the new one looks wrong per se, but in addition to the slight transparency to the legend lines, it seems like the lines got a little bit shorter. And in some of the other cases the semitransparent lines got a little thinner. Any idea why?

- to test trace vs marker opacity in legend
@etpinard
Copy link
Contributor Author

and then a test with lines+markers?

Hopefully somethint like 849782d is what you had in mind.

I don't think the new one looks wrong per se, but in addition to the slight transparency to the legend lines,

as it should, all traces in 28.json have opacity: 0.84 which wasn't honored previously.

it seems like the lines got a little bit shorter.

I can't detect a difference to be honest, maybe I'm going blind 👓

@alexcjohnson
Copy link
Collaborator

it seems like the lines got a little bit shorter.

I can't detect a difference to be honest, maybe I'm going blind 👓

Ok, don't worry about it. Probably just some different antialiasing algorithm when opacity is included.

Hopefully something like 849782d is what you had in mind.

Technically it does show what I wanted to see - it will fail if the marker and line get trace.opacity applied separately rather than to the containing group - though that failure would be rather subtle, especially since you included marker opacity. I was imagining something that will make it blazingly obvious how the opacity was applied, like:

Plotly.newPlot(gd,[{
    x: [1, 2, 3],
    y: [1, 2, 3],
    opacity: 0.2,
    line: {width: 10, color: 'red'},
    marker: {size: 20, color: 'blue'}
}], {
    showlegend: true
})

And the legend matches the plot:
screen shot 2017-01-11 at 12 27 30 pm
but if it was done wrong, the legend would look like:
screen shot 2017-01-11 at 12 22 28 pm

"y": [1, 2, 3],
"opacity": 0.2,
"line": { "width": 10, "color": "red"},
"marker": { "size": 20, "color": "blue"}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

image

looks like it is done right.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Beautiful, thanks :) 💃

@etpinard etpinard removed this from the v1.22.0 milestone Jan 12, 2017
@etpinard
Copy link
Contributor Author

Dropping from the 1.22.0 milestone and merging as the 1.21.x series will get another patch release early next week.

@etpinard etpinard merged commit 7ef3235 into master Jan 12, 2017
@etpinard etpinard deleted the legend-line-opacity branch January 12, 2017 15:27
@flying-sheep
Copy link

Hi! I have a plot where I set per-marker opacity using a array.

The legend takes the opacity of the more transparent points. How can I force the legend’s opacity to be 1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Opacity on line series not reflected properly in legend
3 participants