Published
Edited
Jun 3, 2022
Insert cell
Insert cell
svg = {

const svg = d3.create("svg")
.attr("viewBox", [0, 0, W, H])
.style('background', "#000")
.attr('width',W)
.attr('height',H);

svg.append('g').attr('id','out0')
return svg.node()
}
Insert cell
makeFurn = {
svg
count[0]=0
count[1]=0
trans.str = "translate(245, 600) rotate(0)"
draw1(levels)
}
Insert cell
levels = 70
Insert cell
function draw1(d){

let out = d3.selectAll(`#out${count[1]}`) // selectors failing as nodes not updated?
count[0]++; // branch counter
count[1]++; // incremntal counter

let c = w-count[0]*12

out.append('g')
.attr('id',`out${count[1]}`)
.attr('transform', `${trans.str}`)
.append('line')
.attr('x1', 0)
.attr('y1', 0)
.attr('x2', 0)
.attr('y2', -d)
.attr('stroke',colour(w,c));
trans.str = `translate(0 ${-d}) rotate(${radToDeg(0.06)})` // this reset is breaking it?

if(d*4>5) draw1(d*0.8);

let t = `rotate(${radToDeg(-0.06)}) translate(0 ${d*0.4}) rotate(${radToDeg(-1)})`
trans.str = trans.str.concat(' ',t)

if(d*4>9) draw1(d*4/9);
t = `rotate(${radToDeg(2)})`
trans.str = trans.str.concat(' ',t)

if(d*4>9)draw1(d*4/9);

t= `rotate(${radToDeg(-1)}) translate(0 ${d*0.6})`
trans.str = trans.str.concat(' ',t)

count[0]--
};

Insert cell
count = [0,0]
Insert cell
trans.str
Insert cell
trans = ({ })
Insert cell
w = 245
Insert cell
colour = (w,c) => chroma(w,c,c/4).toString()
Insert cell
W = 500
Insert cell
H = 640
Insert cell
chroma = require('chroma-js@2.4.2/chroma.js') // http://vis4.net/chromajs/
Insert cell
import {radToDeg} from "@makio135/utilities"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more