Rich-Harris / pancake

Experimental charting library for Svelte
MIT License
1.29k stars 61 forks source link

Make it possible to use d3-shape with SvgLine #32

Open Rich-Harris opened 3 years ago

Rich-Harris commented 3 years ago

(and SvgArea?)

jdomeij commented 3 years ago

Why not allow custom svg generator to be passed to SvgLine, this will prevent pancake to depend on d3-shape if not needed (it also allows more custom modifiers for the shape).

I have added this feature to my modified version of pancake (https://github.com/jdomeij/pancake/commit/3064c8de7a7b76d8f72ab3785bbfbb0ec405ee53)

If then want to use d3-shape you only need to override the default svg generator with customized d3-shape like

  import { line as d3Line, curveCardinal } from 'd3-shape';
  const d3Curve = curveCardinal.tension(0);
  const d3LineFunc = d3Line().curve(d3Curve).x(p=>p.x).y(p=>p.y);

<Pancake.SvgLine data={points} line={d3LineFunc} let:d>