-
Notifications
You must be signed in to change notification settings - Fork 185
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
labels for swatches #621
labels for swatches #621
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my preference is that we show the scale’s label by default, consistently across legend types, but that you can disable it by setting label: null. That way we don’t need to special-case the behavior for swatches.
14492bd
to
2eafe34
Compare
2eafe34
to
7dc8d9b
Compare
rebased |
7dc8d9b
to
63b7013
Compare
src/legends/swatches.js
Outdated
? swatches.call(div => div.append("p") | ||
.text(label) | ||
.style("font-weight", "bold") | ||
.style("width", "100%")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parent element here has flex because the code expects that it contains the swatches. We need to change the styles to match the structure—we shouldn’t be setting the width style.
src/legends/swatches.js
Outdated
@@ -93,6 +93,14 @@ function legendItems(scale, { | |||
--swatchHeight: ${+swatchHeight}px; | |||
`); | |||
|
|||
const palette = label | |||
? swatches.call(div => div.append("p") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’d like to revert the unrelated formatting changes… |
I'll do that. The goal of the formatting changes was to produce an output with consistent alignement. |
rebased—I still need to figure out why some alignments in the tests seem wrong |
abf5fdb
to
d495760
Compare
superseded by #1885 |
Note: the scale’s label is not shown for swatches, since most of the time it is obvious from the context. But it can be nice to write Plot.legend(…, label:"Industry"):
closes #834