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

Gradient fill #76

Closed
PlkMarudny opened this issue May 18, 2022 · 9 comments
Closed

Gradient fill #76

PlkMarudny opened this issue May 18, 2022 · 9 comments
Labels
has-workaround needs-documentation svelte-issue An underlying issue with svelte that this lib can't fix

Comments

@PlkMarudny
Copy link

I am trying to define a gradient for the area chart using <svelte:fragment> to insert the gradient definition but it does not seem to work - REPL here. In general, I cannot see any example using gradients, is this something unsupported?

@seblammers
Copy link

I was playing around a bit and just put your gradient definition into the Area.svelte instead of your App.svelte.

Take a look in this forked REPL to see what that looks like.

@PlkMarudny
Copy link
Author

PlkMarudny commented May 18, 2022 via email

@mhkeller
Copy link
Owner

mhkeller commented May 19, 2022

Hm that is strange. The generated HTML is correct in the first example. I'm not sure why it isn't being picked up. I'm also confused about the fix. FWIW it also works without adding the additional <svg> tag in Area.svelte

@mhkeller mhkeller reopened this May 19, 2022
@mhkeller
Copy link
Owner

mhkeller commented May 19, 2022

The first example works if you add this as the fragment

<defs>
	<linearGradient id="myGradient" gradientTransform="rotate(90)">
		<stop offset="20%" stop-color="gold" />
		<stop offset="90%" stop-color="red" />
	</linearGradient>
</defs>

This may be a svelte bug. I'll work on another reproduction later without layercake

@mhkeller mhkeller added the under-investigation Not yet classified. Needs some more info... label Jun 7, 2022
@techniq
Copy link
Contributor

techniq commented Jul 10, 2022

FWIW, I have a gradient component in LayerChart (based on LayerCake) and haven't had this issue myself.

@mhkeller
Copy link
Owner

I haven't dug into this one yet but it was very confusing before. The HTML was being created exactly as you would think it would need to be...

@mhkeller
Copy link
Owner

mhkeller commented Dec 24, 2022

I'm pretty sure this is the same issue as #97 sveltejs/svelte#7450 sveltejs/svelte#7563

The linearGradient element is coming back with a namespace of "http://www.w3.org/1999/xhtml" when it should be "http://www.w3.org/2000/svg".

The fix of putting it inside a <defs> element works because svelte is better able to detect that it should be an SVG element... I've been trying to create a svelte-only REPL but I haven't for some reason...

Here's a fix adding the xmlns attr on the linearGradient element: https://svelte.dev/repl/66fdfba669cf443382c8d71175900ffc?version=3.55.0

I'll see if I can make a svelte-only version but will update the docs to talk about gradients with either this or adding the <defs> element without the slot directly

@mhkeller mhkeller added has-workaround needs-documentation svelte-issue An underlying issue with svelte that this lib can't fix and removed under-investigation Not yet classified. Needs some more info... labels Dec 24, 2022
@mhkeller
Copy link
Owner

@mhkeller
Copy link
Owner

This is in the docs: e459eff

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-workaround needs-documentation svelte-issue An underlying issue with svelte that this lib can't fix
Projects
None yet
Development

No branches or pull requests

4 participants