Published
Edited
Feb 27, 2020
Insert cell
Insert cell
json = FileAttachment("test@7.json").json()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
d3.map(json.samples, d => d.cell_type).keys()
Insert cell
Insert cell
d3.keys(json.samples[0])


Insert cell
{
let cell_types = d3.map(json.samples, d => d.cell_type).keys();
let temp = d3.range(cell_types.length);
let scale = d3
.scaleLinear()
.domain(temp)
.range([300, 0]);
return temp;
}
Insert cell
{
let cell_types = d3.map(json.samples, d => d.cell_type).keys();
let cell_ordinal = d3
.scaleOrdinal()
.domain(cell_types)
.range(d3.range(cell_types.length));
let cell_scale = d3
.scaleLinear()
.domain([0, cell_types.length - 1])
.range([500, 0]);
let cell_range = cell_types.map(d => cell_scale(cell_ordinal(d)));
return cell_range;
}
Insert cell
Insert cell
d3 = require("d3@5")
Insert cell
d3_svg_annotation = require("d3-svg-annotation")
Insert cell
_ = require("lodash")
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