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

labels for swatches #621

Closed
wants to merge 1 commit into from
Closed

labels for swatches #621

wants to merge 1 commit into from

Conversation

Fil
Copy link
Contributor

@Fil Fil commented Dec 17, 2021

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"):

Capture d’écran 2021-12-17 à 23 57 18

closes #834

@Fil Fil requested a review from mbostock December 17, 2021 22:57
Copy link
Member

@mbostock mbostock left a 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.

@Fil Fil force-pushed the fil/label-swatches branch from 14492bd to 2eafe34 Compare January 11, 2022 14:24
@Fil Fil changed the title explicit label for swatches labels for swatches Jan 11, 2022
@Fil Fil requested a review from mbostock January 11, 2022 14:28
@Fil Fil force-pushed the fil/label-swatches branch from 2eafe34 to 7dc8d9b Compare January 19, 2022 17:41
@Fil
Copy link
Contributor Author

Fil commented Jan 19, 2022

rebased

@mbostock mbostock mentioned this pull request Jan 25, 2022
1 task
@mbostock mbostock force-pushed the fil/label-swatches branch from 7dc8d9b to 63b7013 Compare March 30, 2022 15:04
? swatches.call(div => div.append("p")
.text(label)
.style("font-weight", "bold")
.style("width", "100%"))
Copy link
Member

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.

@@ -93,6 +93,14 @@ function legendItems(scale, {
--swatchHeight: ${+swatchHeight}px;
`);

const palette = label
? swatches.call(div => div.append("p")
Copy link
Member

Choose a reason for hiding this comment

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

I think we probably don’t want to use a P element here, and instead should have a DIV with more specific margins as needed. Probably slightly less vertical spacing between the label and the swatches than in this current example.

Screen Shot 2022-03-30 at 8 08 45 AM

@Fil Fil requested a review from mbostock March 31, 2022 13:21
@Fil Fil force-pushed the fil/label-swatches branch from 20f86a3 to 98f3f24 Compare June 6, 2022 19:35
@mbostock
Copy link
Member

mbostock commented Jun 6, 2022

I’d like to revert the unrelated formatting changes…

@Fil
Copy link
Contributor Author

Fil commented Jun 7, 2022

I'll do that. The goal of the formatting changes was to produce an output with consistent alignement.

@Fil Fil force-pushed the fil/label-swatches branch from 98f3f24 to e5ba031 Compare June 7, 2022 05:09
@Fil Fil force-pushed the fil/label-swatches branch from e5ba031 to abf5fdb Compare July 18, 2022 16:23
@Fil
Copy link
Contributor Author

Fil commented Feb 6, 2023

rebased—I still need to figure out why some alignments in the tests seem wrong

@Fil Fil force-pushed the fil/label-swatches branch from abf5fdb to d495760 Compare February 6, 2023 12:54
@Fil Fil marked this pull request as draft April 3, 2023 15:00
@Fil Fil closed this Apr 6, 2023
@Fil Fil force-pushed the fil/label-swatches branch from d495760 to 44f4f9a Compare April 6, 2023 09:33
@Fil Fil reopened this Apr 6, 2023
@Fil Fil force-pushed the fil/label-swatches branch from c87d494 to ed4e1b6 Compare April 6, 2023 09:41
@Fil Fil marked this pull request as ready for review April 6, 2023 09:44
@Fil Fil mentioned this pull request Aug 15, 2023
6 tasks
@Fil Fil mentioned this pull request Sep 29, 2023
@Fil
Copy link
Contributor Author

Fil commented Sep 29, 2023

superseded by #1885

@Fil Fil closed this Sep 29, 2023
@Fil Fil deleted the fil/label-swatches branch September 29, 2023 15:15
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.

Swatches legends should support the label option
2 participants