Published
Edited
Oct 30, 2019
1 fork
1 star
Insert cell
Insert cell
mutable inspectData =''
Insert cell
mutable inspectSelector = ''
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
byDepartmentClassification = d3.nest()
.key(d => d.department)
.key(d => d.classification)
.entries(rowdata)
Insert cell
// Pass thingy into hierarchy
hier = d3.hierarchy(prepped_tree, funcChildren)
Insert cell
treemap = data => d3.treemap()
.tile(d3[tile])
.size([width, height])
.padding(vPadding)
.paddingTop(vPaddingTop)
.round(true)
(d3.hierarchy(data, funcChildren)
// running .sum in this way will count the nodes, similar to .count
// ideally we want to filter...
// .sum(d => (d.children ? d.parent : 1)).value
// changed sum -> count, counting leaves to generate values
// for now this didn't do much, just changing the output graph a little, rectangles fill up properly
.count(d => 1)
)

Insert cell
Insert cell
// When we run treemap, this function wraps up stuff
// and mutates the input, computing values that
// will be passed into root for the chart all the way above...
// The code below is called in chart but you can remove it from this here.
// This line is only included so we can inspect the output above...
treemap(prepped_tree);
Insert cell
// There is probably an easier way to do this in JS
// but this way uses a constructor
obj = function(name, children) {
this.name = name;
this.values = children; }
Insert cell
prepped_tree = new obj("metStuff", byDepartmentClassification);
Insert cell
// This function is used to choose where the children are located
funcChildren = d => d.values
Insert cell
funcChildren(prepped_tree)
Insert cell
2000
Insert cell
height = 900
Insert cell
format = d3.format(",d")
Insert cell
color = d3.scaleSequential([8, 0], d3.interpolateViridis)
Insert cell
d3 = require("d3@5")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mutable objectSecondaryImg = [];
Insert cell
Insert cell
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