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

Do not show Aa text in legends unless there is only text in the legend item #5682

Merged
merged 7 commits into from
May 27, 2021

Conversation

archmoj
Copy link
Contributor

@archmoj archmoj commented May 25, 2021

Resolves #5679.

@plotly/plotly_js

@archmoj archmoj added this to the NEXT milestone May 25, 2021
@@ -145,7 +145,7 @@ module.exports = function style(s, gd, legend) {

// with fill and no markers or text, move the line and fill up a bit
// so it's more centered
var markersOrText = subTypes.hasMarkers(trace) || subTypes.hasText(trace);
var markersOrText = subTypes.hasMarkers(trace) || subTypes.isText(trace);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe this change is correct, though I don't see any test images in which the legend symbol shifted position due to the text being removed. Probably OK, just want to note it as a gap. This would need to be something like mode: 'lines+text', fill: 'tozeroy'.

Actually this raises a question: what if we have just fill and text, mode: 'text', fill: 'tozeroy' - do we still want to show the Aa in that case, or only the fill? Currently in this PR we would still show Aa but I might argue for dropping it, ie showing text only when there's nothing else at all in the legend. @nicolaskruchten thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, let's make this rule "if rendering no text would result in no legend item at all, show the text". So if fills without lines cause a marker to appear, then no text please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 10d1138.

@alexcjohnson
Copy link
Collaborator

FYI not new, I'm just noticing it here, there's an inconsistency in 4 mocks (gl2d_)?text_chart(_invalid)?-arrays that makes it look like there's a bug, but in fact the legend is just out of step with the actual mode.

            "mode": "lines+markers+text",
            "name": "Lines and Text",

@archmoj
Copy link
Contributor Author

archmoj commented May 26, 2021

inconsistency in 4 mocks

Good eye. Fixed in 0bd9660.

Copy link
Collaborator

@alexcjohnson alexcjohnson left a comment

Choose a reason for hiding this comment

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

💃 looks good. Thanks for updating those inconsistent mocks 🎉

@archmoj archmoj changed the title Do not show Aa text in legends unless the mode is set to text Do not show Aa text in legends unless there is only text in the legend item May 27, 2021
@archmoj archmoj merged commit 13831b2 into master May 27, 2021
@archmoj archmoj deleted the fix5679-hide-Aa-text branch May 27, 2021 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supress "Aa" text from scatter-like legend items when mode != "text"
3 participants