Published unlisted
Edited
Aug 18, 2021
1 star
Insert cell
# parsing-data-to-suite-a-line-chart

https://talk.observablehq.com/t/parsing-data-to-suite-a-line-chart/5475

I converted the info into a csv file.


Insert cell
data = d3.csv(await FileAttachment("data.csv").url()).then((item) =>
item
.map((item) => {
const values = item.dataDescription.split("_");
return { attributeA: values[0], attributeB: values[1], ...item };
})
.filter((item) => item.attributeB === "PRL")
);
Insert cell
Plot.plot({
y: {
grid: true
},
marks: [
Plot.line(data, {x: "3-Aug-21", y: "attributeA", stroke: "#C2E812" }),
Plot.line(data, {x: "4-Aug-21", y: "attributeA", stroke: "#91F5AD" }),
Plot.line(data, {x: "5-Aug-21", y: "attributeA", stroke: "#8B9EB7" }),
Plot.line(data, {x: "6-Aug-21", y: "attributeA", stroke: "#745296" }),
Plot.line(data, {x: "7-Aug-21", y: "attributeA", stroke: "#632A50" }),
]
})
Insert cell
Insert cell
FileAttachment("data.csv").csv()
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