Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork21
(DRAFT) feat: axis and grid transitions#233
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
netlifybot commentedOct 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
✅ Deploy Preview forsvelteplot ready!
To edit notification comments on pull requests, go to yourNetlify project configuration. |
📦 Preview package for this PR is published! Version: Install it with: npm install svelteplot@pr-233# or install the specific versionnpm install svelteplot@0.5.0-pr-233.0 |
📦 Preview package for this PR is published! Version: Install it with: npm install svelteplot@pr-233# or install the specific versionnpm install svelteplot@0.5.0-pr-233.1 |
gka commentedOct 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@bothness following your initiative in#231 I tried how far I would get with CSS-based transitions in SveltePlot. The CSS transitions do work fine, but I had to find a solution for allowing to pass a Svelte transitions for grid lines and axis ticks so we can also animate ticks getting introduced and ticks leaving the DOM. The syntax is still a draft, but we can experiment with it. consttIn=[fade,{duration:300,delay:500}];consttOut=[fade,{duration:500}];setPlotDefaults({axis:{ tIn, tOut},grid:{ tIn, tOut},}) you can see it in action here:https://svelte.dev/playground/71f57033f5124a638a66c3a647650dae?version=5.41.0 However this approach has its limitations, as some marks can't be simply transitioned via CSS. For instance, and SVG path cannot yet animate its path string via CSS, so if the plot includes a line mark, the transitions break, as you cansee here. Similarly, CSS transitions obviously also don't work with with canvas-rendered marks, asdemonstrated here. That's why so far I have always resorted to (manual)domain transitions using Tween from So there are a few questions:
|
bothness commentedOct 18, 2025
Hi@gka. Thanks for taking this onboard! I'm not sure if there's a route to supporting CSS transitions for all mark types, but there's a surprisingly large subset where there's a potential... And perhaps a possibility to polyfill others using appropriate JS libraries(?) I worked on a proof-of-concept chart library with CSS transitions a while back (using Lit, but same principles apply in Svelte), and it's even possible to do things like a bar chart race. With regards to path transitions, there's definitely some level of support in Chromium and Firefox, but apparently not yet Safari. I haven't tested what the limits are as yet, but definitely it works fine when the number of vertices on a line remains constant. |
bothness commentedOct 18, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
My apologies@gka. I read your post in a hurry and skipped over some of the details. I should have some time to investigate a bit further and think through your questions over the coming week. But you're right that this obviously won't cover scenarios like canvas. However, I did manage to get your path example to work in my Chromium browser using a transition on the d property of the path: Update: This example also works for me in Firefox. On Safari 17.6 on MacOS Sonoma I don't seem to get any transitions on either the axes or the paths (there should be support in Safari for transitioning the axis transforms, but seems it supports fewer cases than other browsers). |
bothness commentedOct 22, 2025
@gka I had a chat with a couple of colleagues about the points you raised above. The context is that we've just started a process of overhauling our rather limitedsvelte-charts library, and are hoping to use SveltePlot as a core to build a much wider range of templates on top of. This existing library was largely focused on being able to run dynamic/animated charts for scrollytelling articles (see examples inthis template). Alongside looking for a core library to build around, we've also been doing experiments with CSS chart transitions with generally very good results in terms of performance (like theLit example above), so it would be great to kill two birds with one stone if high performance transitions were supported out-of-the-box in SveltePlot. With regards to your specific questions:
I would be happy to have a chat to discuss the above and how best to contribute to these efforts, and generally to the development of SveltePlot. Please do feel free to DM me on that front! |
gka commentedOct 23, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Thanks for your feedback@bothness! I think I'd like to explore this idea further. A few more observations:
|
This is an proof of concept for how transitions could work with axis ticks and grid lines. The changes are as follows:
in:andout:transitions for axes and grids throughsetPlotDefaults