Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Tween y coordinates of SVG path to animate chart transitions dynamically

$
0
0

I'm dynamically drawing an SVG path based on a data array (think linechart).

Would love to animate the chart transition when the data changes but this only makes sense for the Y values in my case.

The path is built

data.forEach(d => {            path += `L ${pctCoordX(d.time)} ${pctCoordY(d.value)} `})

This works great for the fixed values and is called whenever data changes to update the path.

Instead I'd like to have a reactive path that consist of something like

L ${pctCoordX(data[0].time)} ${tweenedY[0]} L ${pctCoordX(data[1].time)} ${tweenedY[1]}

but haven't found a away to make this work since it needs to be created dynamically and the amount of datapoints is not fixed.

Is there an elegant Svelte solution for this?


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>