Published
Edited
Jul 27, 2019
5 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
genChart("dave.reed@tr.com")
Insert cell
genChart = (email) => {
const hash = hashFcn(email)
const h1 = hash
const chord1 = _.toPairs(bitDef).map(([a,b]) => ({label: a, value: getBits(h1, ...b)}))
const h2 = getBits(hash, 16, 31)
const chord2 = _.toPairs(bitDef).map(([a,b]) => ({label: a, value: getBits(h2, ...b)}))
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height)
const g = svg
.append("g")
.attr("transform", `translate(${width/2}, ${height/2})`)
const c1 = f1(...chord1.map(d => d.value))
g.append("path")
.attr("d", ribbon({
source: {startAngle: c1.s1, endAngle: c1.s2, radius: innerRadius},
target: {startAngle: c1.s3, endAngle: c1.s4, radius: innerRadius}
}))
.attr("fill", d => c1.c)
.attr("stroke", d => d3.rgb(c1.c).darker());
const c2 = f1(...chord2.map(d => d.value))
g.append("path")
.attr("d", ribbon({
source: {startAngle: c2.s1, endAngle: c2.s2, radius: innerRadius},
target: {startAngle: c2.s3, endAngle: c2.s4, radius: innerRadius}
}))
.attr("fill", d => c2.c)
.attr("stroke", d => d3.rgb(c2.c).darker());

return svg.node();
}
Insert cell
arc = d3.arc()
.innerRadius(innerRadius)
.outerRadius(outerRadius)
Insert cell
ribbon = d3.ribbon()
.radius(innerRadius)
Insert cell
// color = d3.scaleOrdinal()
// .domain(d3.range(4))
// .range(["#000000", "#FFDD89", "#957244", "#F26223"])
Insert cell
outerRadius = Math.min(width, height) * 0.5 - 5
Insert cell
innerRadius = outerRadius - 5
Insert cell
height = 100
Insert cell
width = 100
Insert cell
d3 = require("d3@5")
Insert cell
_ = require("lodash")
Insert cell
import {table} from "@tmcw/tables"
Insert cell
faker = require("https://bundle.run/faker@4.1.0")
Insert cell
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