Published
Edited
Aug 14, 2022
Insert cell
Insert cell
Insert cell
Insert cell
d3.namespaces
Insert cell
d3.namespace("svg:text")
Insert cell
Insert cell
d3.create("svg") // equivalent to svg:svg
Insert cell
d3.create("svg:svg") // more explicitly
Insert cell
d3.create("svg:g") // an SVG G element
Insert cell
d3.create("g") // an HTML G (unknown) element
Insert cell
Insert cell
Insert cell
alphabet = [..."ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
Insert cell
Insert cell
svg1 = {
const svg = d3
.create("svg")
.attr("viewBox", [0, 0, width, 33])
.attr("font-family", "sans-serif")
.attr("font-size", 10)
.style("display", "block");

// svg
// .selectAll("text")
// .data(alphabet)
// .join("text")
// .attr("x", (d, i) => i * 17)
// .attr("y", 17)
// .attr("dy", "0.35em")
// .text((d) => d);

return svg;
}
Insert cell
svg1.node()
Insert cell
chart1_svg.selectAll("text")
Insert cell
chart1_svg.selectAll("text").data(alphabet)
Insert cell
chart1_svg.selectAll("text").data(alphabet).join("text")
Insert cell
chart1_svg
.selectAll("text")
.data(alphabet)
.join("text")
.attr("x", (d, i) => i * 17)
Insert cell
chart1_svg._groups[0][0]
Insert cell
Insert cell
Insert cell
Insert cell
selection = require("https://cdn.jsdelivr.net/npm/d3-selection@3.0.0/dist/d3-selection.js")
Insert cell
Insert cell
d3 = require("https://cdn.jsdelivr.net/npm/d3@7.6.1/dist/d3.js")
Insert cell
Insert cell
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