D3 delaunay renderPoints, how to set the radius with SVG

I’m playing with D3 delaunay.renderPoints(context[,radius]), and not sure if this is the right way to set the size of the render points when using SVG.


It says if context isn’t parsed then it treats it as SVG and the source code checks for null. So I guess you can parse null as well as a control point radius.

It works, but fells very hackery.


this is an oversight, issue filed at renderPoints(5) crashes · Issue #130 · d3/d3-delaunay · GitHub

1 Like

How would and what is the context for an SVG if I was going to parse SVG?

d3.path / D3 / Observable has details

That covers canvas context but not svg context. What is SVG context and how do you find it?

Sorry, I meant to say, in d3-delaunay/delaunay.js at main · d3/d3-delaunay · GitHub the context is set to Path when we want to return a SVG path string.

What Path does (as documented in the d3.path notebook) is its accepts canvas “turtle” commands and returns a svg path string.

So for SVG we create this “fake svg context” (Path) instead of the canvas context; the rendering function then uses the same code path to do its drawing. When it returns, either it was canvas and the canvas commands have been sent, or it was svg and the Path has accumulated the drawing information, and can be used as a svg path string.