ONSvisual / svelte-charts

Reusable chart templates for Svelte projects.
14 stars 6 forks source link

Spaghetti code for implementing tween animations #5

Open bothness opened 2 years ago

bothness commented 2 years ago

At the moment, the logic that allows for pretty animations is split between:

  1. A shared component called SetCoords, which has the logic for tweening the points for all different chart types.
  2. Chart-level tweening of the xDomain/yDomain to deal with axis/scale animations.
  3. Some logic in the SVG sub-components (eg. Bar.svelte) for picking up issues like marker width on barcode charts.

There is also some logic in SetCoords that deals with screen resize (no tweening) vs data change (tweening).

henryjameslau commented 8 months ago

The setCoord stuff suffers from tweening having to between arrays of the same size so enter/exit of data causes problems. I saw this tweet and someone did it by having each data point as a component and having the tween inside the component. See this repl