Description
I'd like to preface this by commending you on such a great library. It's truly a breath of fresh air.
I’m unsure whether svelteplot strictly adheres to Observable Plot’s API or is open to divergence as noted in the README:
Its API is heavily inspired by Observable Plot.
Regardless, I’d like to propose three potential solutions for a missing feature.
Is your feature request related to a problem? Please describe.
Currently, users lack fine-grained control over mark rendering beyond the exposed props. My specific use case involves tweening between states, which doesn’t seem possible with svelteplot
today. Another use case is rendering custom components as marks.
Describe the solution you'd like
Here are three approaches to address this:
1. Implement a render
transform
This would expose low-level D3 constructs, allowing users to inject custom logic (e.g., .transform()
) into the rendering pipeline.
Example: https://observablehq.com/@fil/plot-animate-a-bar-chart/2
2. Integrate with svelte/motion
Expose a motion prop, either:
-
Declaratively (similar to
layerchart
):<LineY {data} x="x" y="y" motion={{ type: "tween", duration: 500, ...rest }} />
-
Or via direct object injection (cleaner/treeshakable):
<LineY {data} x="x" y="y" motion={new Tween(0, { duration: 500, ...rest })} />
Examples:
- https://next.layerchart.com/docs/examples/Area#clip_tween_on_mount
- https://next.layerchart.com/docs/examples/Area#clipped_area_on_tooltip
3. Support children
snippet
The simplest yet most powerful option: allow users to inject Svelte snippets for full rendering control.