Public
Edited
Nov 22, 2022
2 stars
Insert cell
Insert cell
Insert cell
line_pic.querySelector("svg").outerHTML
Insert cell
line_pic = {
let div = d3.create("div");
let svg = div.append("svg").attr("viewBox", "0 0 1200 100");
svg
.append("path")
.attr("d", line1)
.attr("stroke", "black")
.attr("fill", "none");

return div.node();
}
Insert cell
data1 = [[0, 80], [50, 20], [100, 50], [150, 30],
[200, 40], [250, 90], [400, 20], [450, 70], [500, 60]];
Insert cell
line1 = d3.line()(data1)
Insert cell
Insert cell
container = html`<div id='here'></div>`
Insert cell
doit = {
const svgns = "http://www.w3.org/2000/svg";
let svg = d3
.select("#here")
.append("svg")
// .attr('xmlns', svgns)
.attr("viewBox", "0 0 1200 100");

return svg
.append("path")
.attr("d", line1)
.attr("stroke", "black")
.attr("fill", "none")
.node();
}
Insert cell
// Make this cell depend on `doit` so that we don't try to get the SVG before it's generated.
(doit, container.querySelector("svg").outerHTML)
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