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

✨ (grapher) improve SVG output for manual manipulation #3621

Merged
merged 1 commit into from
May 27, 2024

Conversation

sophiamersmann
Copy link
Member

@sophiamersmann sophiamersmann commented May 21, 2024

Resolves #3607

Adds labels to SVG groups and elements for more intuitive manual inspection and manipulation.

Figma displays an element's ID as its title. I researched if there is a way to customize this and show something else as an element's title, e.g. a data-name attribute or so, but I couldn't find anything. Since it's a bit odd to assign IDs to elements like that, I added a makeIdForHumanConsumption function that communicates that these IDs are for human inspection only and are not used in code, thus can be safely deleted.

I also made an effort to groups elements together, e.g. a tick's line and label is rendered into one group element.

PS: I also fixed this annoyance 👇🏻

Screenshot 2024-05-21 at 11 27 08
Figma screenshot Screenshot 2024-05-21 at 11 18 46

Copy link
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @sophiamersmann and the rest of your teammates on Graphite Graphite

@owidbot
Copy link
Contributor

owidbot commented May 21, 2024

Quick links (staging server):

Site Admin Wizard

Login: ssh owid@staging-site-improve-for-figma

SVG tester:

Number of differences (default views): 4530 (41995b)
Number of differences (all views): 2744 (b32081)

Edited: 2024-05-27 12:11:52 UTC
Execution time: 1.20 seconds

@sophiamersmann sophiamersmann force-pushed the improve-for-figma branch 2 times, most recently from 33bacb2 to 7f00352 Compare May 21, 2024 09:13
@sophiamersmann sophiamersmann changed the title ✨ (grapher) improve SVG ouput for manual manipulation ✨ (grapher) improve SVG output for manual manipulation May 21, 2024
@sophiamersmann sophiamersmann marked this pull request as ready for review May 21, 2024 09:43
Copy link
Member

@marcelgerber marcelgerber left a comment

Choose a reason for hiding this comment

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

Nice, I think this'll make Lucas et al.'s life a lot easier :)

{labelTextWrap &&
labelTextWrap.renderSVG(
-verticalAxis.rangeCenter - labelTextWrap.width / 2,
bounds.left,
{
id: makeIdForHumanConsumption("axis-label"),
Copy link
Member

Choose a reason for hiding this comment

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

In theory, according to W3C rules, an ID should be unique for the whole page.

It's not a big deal that we're breaking that rule here (I think, at least), but still wanted to flag it just to go sure.

In this case, we could change it to horizontal-axis-label and vertical-axis-label and be good.

Copy link
Member Author

Choose a reason for hiding this comment

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

I have renamed axis-label, but since we often have multiple Graphers on one page, I expect most of these IDs to be present on a page multiple times. I think as long as we don't use them, we should be fine. (I hope makeIdForHumanConsumption makes it clear that we shouldn't)

Copy link

@sophiamersmann sophiamersmann merged commit 6c73dfc into master May 27, 2024
22 checks passed
@sophiamersmann sophiamersmann deleted the improve-for-figma branch May 27, 2024 12:56
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.

Add group labels in SVG for easier manipulation in Figma
3 participants