Published
Edited
Aug 5, 2019
7 stars
Insert cell
Insert cell
Insert cell
build_colors(color_categorical_scheme_d3)
Insert cell
Insert cell
color_categorical_scheme_d3 = d3.scaleOrdinal().domain(data)
.range(d3.schemeAccent)
Insert cell
build_colors(color_categorical)
Insert cell
color_categorical = d3.scaleOrdinal().domain(data)
.range(['#1C2A39', '#5C6A79', '#5E2C0B', '#9E6C4B', '#932210', '#D3623B', '#A84410', '#E67E22', '#005C01', '#009C41', '#005B50', '#009B90', '#102770', '#0067B0', '#1E003D', '#6E248D', '#8A0028', '#CA2C68', '#870000', '#D73C2C'])
Insert cell
Insert cell
build_colors(color_linear)
Insert cell
color_linear = d3.scaleLinear().domain([1, max_value])
.range(['white', '#DA3C78'])
Insert cell
Insert cell
build_colors = (type_color_func) => {
const svg = d3.select(DOM.svg(width, height))
svg.selectAll('.color')
.data(data)
.enter()
.append('circle')
.attr('cx', (d,i) => 50 + i * 40)
.attr('cy', 50)
.attr('r', 19)
.attr('fill', (d) => type_color_func(d))

return svg.node()
}
Insert cell
data = d3.range(max_value)
Insert cell
max_value = 20
Insert cell
height = 80
Insert cell
d3 = require('d3@5')
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