Skip to content

Add overflow options to layout components#311

Merged
mhkeller merged 7 commits into
mainfrom
overflow-options
Aug 19, 2025
Merged

Add overflow options to layout components#311
mhkeller merged 7 commits into
mainfrom
overflow-options

Conversation

@mhkeller

@mhkeller mhkeller commented Aug 8, 2025

Copy link
Copy Markdown
Owner

Closes #283

This standardizes the how padding works on layout components and gets rid of the <g> inner tag on Svg layout components. Because of that, it will be a breaking change although I expect very few people use those features.

@github-actions

github-actions Bot commented Aug 8, 2025

Copy link
Copy Markdown
Contributor

🎭 Playwright tests failed

The Playwright tests failed on this PR. Please check the test results and fix any issues.

📊 View full test report

Comment thread src/lib/layouts/ScaledSvg.svelte Outdated
Comment thread src/lib/layouts/Svg.svelte Outdated
@mhkeller mhkeller marked this pull request as draft August 9, 2025 18:39
@mhkeller

Copy link
Copy Markdown
Owner Author

@rgieseke the test that's failing here is the full page gallery but when I look at the screenshots, they look identical to me. The flagged pixels come from the x-axis on the cleveland dot plot example. kind of mysterious that it's just that one and not all text...

@rgieseke

Copy link
Copy Markdown
Contributor

@rgieseke the test that's failing here is the full page gallery but when I look at the screenshots, they look identical to me. The flagged pixels come from the x-axis on the cleveland dot plot example. kind of mysterious that it's just that one and not all text...

Indeed odd. From the call log it seems that there are multiple attempts at taking a stable screenshot. Maybe a larger initial timeout might help?

@github-actions

Copy link
Copy Markdown
Contributor

🎭 Playwright tests failed

The Playwright tests failed on this PR. Please check the test results and fix any issues.

📊 View full test report

@github-actions

Copy link
Copy Markdown
Contributor

🎭 Playwright tests failed

The Playwright tests failed on this PR. Please check the test results and fix any issues.

📊 View full test report

@mhkeller

Copy link
Copy Markdown
Owner Author

Increasing the timeout didnt have any effect. Looks like it's some very slight differences in anti-aliasing: Screenshot 2025-08-15 at 17 22 40

I think we maybe just redo that one

@rgieseke

Copy link
Copy Markdown
Contributor

Yeah, it seems there is another timeout which gets increased until the screenshot is stable or something.

  - waiting 250ms before taking screenshot
  - 1637 pixels (ratio 0.01 of all image pixels) are different.
  - waiting 500ms before taking screenshot
  - 1242 pixels (ratio 0.01 of all image pixels) are different.
  - waiting 1000ms before taking screenshot
  - 498 pixels (ratio 0.01 of all image pixels) are different.
  - waiting 1000ms before taking screenshot

Haven't found yet whether it's possible to configure that. In any case odd that only this specific plot is wrong.

@github-actions

Copy link
Copy Markdown
Contributor

🎭 Playwright tests failed

The Playwright tests failed on this PR. Please check the test results and fix any issues.

📊 View full test report

@mhkeller mhkeller marked this pull request as ready for review August 16, 2025 19:50
@mhkeller mhkeller requested a review from rgieseke August 18, 2025 02:57
@rgieseke

Copy link
Copy Markdown
Contributor

I installed the PR locally (gh pr checkout 311) and changed some data in fruits.csv to negative values in the MultiLine example:

image

When I add the new prop ( <Svg overflow="hidden">) all axes and ticks are hidden as well.

image

When I use two separate Svg components for the Axis and Line components I get the behaviour as desired by @francois-travais in #283 I think.

<Svg overflow="visible">
	<AxisX
		gridlines={false}
		ticks={data.map(d => d[xKey]).sort((a, b) => a - b)}
		format={formatLabelX}
		snapLabels
		tickMarks
	/>
	<AxisY ticks={4} format={formatLabelY} />
</Svg>
<Svg overflow="hidden">
	<MultiLine />
</Svg>

image

Would that splitting be required with the new approach or would I have to change the padding somehow?

@rgieseke

Copy link
Copy Markdown
Contributor

For example-ssr/MultiLine this works of course directly as in the last figure above because there is only the lines in the SVG element.

<Html>
	<AxisX
		gridlines={false}
		ticks={data.map(d => d[xKey]).sort((a, b) => a - b)}
		format={formatLabelX}
		snapLabels
		tickMarks
	/>
	<AxisY format={formatLabelY} />
</Html>

<ScaledSvg overflow="hidden">
	<MultiLine />
</ScaledSvg>

@mhkeller

Copy link
Copy Markdown
Owner Author

Hm ya that isn't good. ScaledSvg didn't change so that one should be what @francois-travais had. Let me look into this more... Thanks for putting these together!

@mhkeller

Copy link
Copy Markdown
Owner Author

Oh actually, he was doing it with the axes in a separate <Html> group, so this does seem to be correct. The only question is if there is a better way to accomplish this without putting the axes in a different layout component but I'd have to think about that. My guess is likely not.

@rgieseke

Copy link
Copy Markdown
Contributor

Hm ya that isn't good. ScaledSvg didn't change so that one should be what @francois-travais had.

Not sure I understand, the overflow is new, isn't it?

The first attempt (which led to using two<Svg>) was just my initial naive approach.

@rgieseke

Copy link
Copy Markdown
Contributor

Oh actually, he was doing it [...] The only question is if there is a better way to accomplish this without putting the axes in a different layout component but I'd have to think about that. My guess is likely not.

Yeah, I had also thought that maybe one could do the clipping/overflow hiding in the MultiLine component.
In any case it's quite useful to be able to this with a HTML and SVG combination I think (and for me the default I set-up figures, axes in HTML, graph in SVG).

@mhkeller

Copy link
Copy Markdown
Owner Author

Not sure I understand, the overflow is new, isn't it?

Yes, sorry that wasn't as clear as it could have been. The overflow is new but the main portion of this PR was making sure that the <svg> or <div> element was the same across layout components and responded in the same way to padding. The Svg component had to change because previously everything was in a <g> and that responded to padding while the parent <svg> component didn't move. So if you did overflow:hidden just on the <svg> you wouldn't get the desired behavior.

However, the ScaledSvg component did not have a <g> and so the <svg> component did respond to padding. So from that perspective, nothing fundamental changed about the component besides exposing the overflow prop. Hence why I was confused if that component was behaving differently from what Francois saw since there were no sizing adjustments needed on ScaledSvg.

If this looks good to you, we'll merge it in!

@rgieseke

Copy link
Copy Markdown
Contributor

Got it, thanks for the explanation.

Looks good to me!

@mhkeller

Copy link
Copy Markdown
Owner Author

Great! Thanks for taking a look and for these other PRs. I'll go through them and then cut a new v10.0.0 release since this is a breaking change, although I doubt it will affect anyone in practice.

@mhkeller mhkeller merged commit 3aaba4e into main Aug 19, 2025
6 checks passed
@mhkeller mhkeller deleted the overflow-options branch August 19, 2025 00: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.

Not possible to hide overflow of ScaledSvg and Svg

2 participants