Public
Edited
Mar 24, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
width
Insert cell
height = 400
Insert cell
Insert cell
chartWidth = width/2
Insert cell
Insert cell
margins = ({
top: 60,
right: 30,
bottom: 30,
left: 80
})
Insert cell
Insert cell
Insert cell
emptyCanvas = {
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height);
const subPlot1 = svg.append("g")
.attr("class", "emptySubPlot1");
const sublot2 = svg.append("g")
.attr("transform", `translate(${chartWidth}, 0)`)
.attr("class", "emptySubPlot2");
return svg.node();
}
Insert cell
Insert cell
Insert cell
updateEmptyCanvas = {
const chartsContainer = d3.select(emptyCanvas);
chartsContainer.select("g.emptySubPlot1")
.call(emptySubPlot1)
chartsContainer.select("g.emptySubPlot2")
.call(emptySubPlot2)
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
emptySubPlot1 = container => {
container.append("text")
.attr("x", chartWidth/2)
.attr("y", height/2)
.text("subplot1")
.attr("fill", "black")
}
Insert cell
emptySubPlot2 = container => {
container
.append("text")
.attr("x", chartWidth/2)
.attr("y", height/2)
.text("subplot2")
.attr("fill", "black")
}
Insert cell
Insert cell
Insert cell
Insert cell
import {tooltipChart as barChart} from "7630862fe4a1f037"
Insert cell
import {presentChart as networkChart} from "f2990e64eef48906"
Insert cell
canvas = {
const svg = d3.create("svg")
.attr("width", width)
.attr("height", height);
const subPlot1 = svg.append("g")
.attr("class", "SubPlot1");
const sublot2 = svg.append("g")
.attr("transform", `translate(${chartWidth}, 0)`)
.attr("class", "SubPlot2");
return svg.node();
}
Insert cell
updateCanvas = {
const chartsContainer = d3.select(canvas);
chartsContainer.select("g.SubPlot1")
.call(barChart)
chartsContainer.select("g.SubPlot2")
.call(networkChart)
}
Insert cell
Insert cell
Insert cell
import {textcolor} from "@observablehq/text-color-annotations-in-markdown"
Insert cell
import {toc} from "@jonfroehlich/collapsible-toc"
Insert cell
d3 = require("d3@7")
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