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

preserve whitespace in svg text elements, when used in a reactor window #574

Closed
wants to merge 2 commits into from

Conversation

schanzer
Copy link

(addresses #573)

@schanzer schanzer requested a review from blerner January 16, 2025 16:53
@blerner
Copy link
Member

blerner commented Jan 16, 2025

This seems like the wrong fix to me, or at least, is too stringent. I suspect you want white-space: pre-wrap, since you want text to look like well-formatted text, not necessarily code. And what you likely really wanted was multiple lines of text, so you want to the white-space option that preserves linebreaks but in other respects formats text as text, hence pre-wrap.

@schanzer
Copy link
Author

schanzer commented Jan 16, 2025

I want a string to render as a TEXT node within an SVG exactly as it would render in Pyret using text. No line wrapping. (although it would be pretty cool if Pyret supported line wrapping someday!)

@schanzer
Copy link
Author

@blerner unfortunately, making this selector more restrictive is quite difficult!

Google Charts has total control over the DOM structure of a chart, and doesn't provide any helpful nodes, classes or ids that would let us identify this specific text. The best we can do is walk the DOM:

.ui-widget-content svg > g:nth-child(2) > text { white-space: pre; }

This works for our use-case, and from spot-checking all of our charts this causes no problems. But if Google ever changes their DOM tree, this will be yet another thing that breaks.

If this doesn't leave you feeling good about the PR, close it -- our userland workaround is good enough.

@blerner
Copy link
Member

blerner commented Feb 11, 2025

When you generate labels, are they strings, or can they be DOM nodes? If the latter, then generate <span class="our-specific-tag">{the string label}</span>, so you can trigger off of that...

@schanzer
Copy link
Author

They're just strings. Google's API gives us only very primitive options

@schanzer schanzer closed this Mar 13, 2025
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.

2 participants