Public
Edited
Jan 21, 2023
Insert cell
Insert cell
Insert cell
DOM.download(() => rasterize(chart), undefined, "Save as PNG")
Insert cell
DOM.download(() => serialize(chart), undefined, "Save as SVG")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
nudata = FileAttachment("lebron_career_game_by_game_points.csv").csv()
Insert cell
Insert cell
// data.forEach(function(d) {
// d["value"] = +d["value"];
// var date_t = new Date(d["date"]);
// date_t.setDate(date_t.getDate() + 1)
// d["date"] = date_t
// });
Insert cell
Insert cell
import {rasterize} from "@mbostock/saving-svg"
Insert cell
serialize = {
const xmlns = "http://www.w3.org/2000/xmlns/";
const xlinkns = "http://www.w3.org/1999/xlink";
const svgns = "http://www.w3.org/2000/svg";
return function serialize(svg) {
svg = svg.cloneNode(true);
const fragment = window.location.href + "#";
const walker = document.createTreeWalker(svg, NodeFilter.SHOW_ELEMENT, null, false);
while (walker.nextNode()) {
for (const attr of walker.currentNode.attributes) {
if (attr.value.includes(fragment)) {
attr.value = attr.value.replace(fragment, "#");
}
}
}
svg.setAttributeNS(xmlns, "xmlns", svgns);
svg.setAttributeNS(xmlns, "xmlns:xlink", xlinkns);
const serializer = new window.XMLSerializer;
const string = serializer.serializeToString(svg);
return new Blob([string], {type: "image/svg+xml"});
};
}
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