Published
Edited
Jun 11, 2020
Fork of Hierarchies
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = d3
.csvParse(await FileAttachment("vgsales.csv").text())
.filter((d, i) => {
return i < 50;
})
Insert cell
render_data_table(data.slice(0, 10))
Insert cell
md`This data set contains information about the sales of video games, along with information about their publisher, genre, and platform. The data was scraped from vgchartz, a website that keeps track of video game sales.`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
sunburst_data = d3
.nest()
.key(d => d['Platform'])
.key(r => r['Publisher'])
.entries(data)
Insert cell
sunburst_data2 = sunburst_data.map(d => {
d.name = d.key;
d.values = d.values.map(dd => {
dd.name = dd.key;
dd.values = dd.values.map(ddd => {
ddd.name = ddd.key;
return ddd;
});
return dd;
});
return d;
})
Insert cell
sunburst_hierarchy = d3.hierarchy(
{ key: "Platform", values: sunburst_data2 },
d => d.values
)
Insert cell
sunburst_hierarchy2 = sunburst_hierarchy.copy().sum(d => +d.Global_Sales)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
circles
Insert cell
Insert cell
Insert cell
Insert cell
d3 = require("d3")
Insert cell
height = 800
Insert cell
width = 800
Insert cell
format = d3.format(",d")
Insert cell
import { swatches } from "@d3/color-legend"
Insert cell
import { chart as sunburst } with {
sunburst_hierarchy2 as data
} from "@d3/sunburst"
Insert cell
import { chart as circles } with {
sunburst_data2 as data
} from "@d3/circle-packing"
Insert cell
_ = require("lodash")
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