Skip to content

Instantly share code, notes, and snippets.

@cmdcolin
Created January 9, 2024 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmdcolin/dc8586541314fa71649123980d215c9f to your computer and use it in GitHub Desktop.
Save cmdcolin/dc8586541314fa71649123980d215c9f to your computer and use it in GitHub Desktop.
// example code for "hand-drawing the d3-hierarchy on a canvas"
for (const { source, target } of hierarchy.links()) {
const { x: sy, y: sx } = source
const { x: ty, y: tx } = target
ctx.beginPath()
ctx.moveTo(sx, sy)
ctx.lineTo(sx, ty)
ctx.lineTo(tx, ty)
ctx.stroke()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment