Public
Edited
Jul 30, 2023
Insert cell
Insert cell
dataRead = FileAttachment("data.json").json()
Insert cell
dateparser = d3.timeParse("%d-%b-%YT%H:%M:%S")
Insert cell
data1 = {
let data = dataRead.data.map(function (d) {
let thisDateTime = d.orderDate.split(" ");
let tempdate = thisDateTime[0] + "T" + thisDateTime[1];
d.orderDate = dateparser(tempdate); //dateparser(tempdate);
d.total = +d.total;
d.day = d.orderDate.toLocaleString(undefined, { weekday: "short" });
d.hour = d.orderDate.toLocaleString(undefined, { hour: "numeric" });
d.dayNo =
theWeek[d.orderDate.toLocaleString(undefined, { weekday: "short" })];
return d;
});
return data;
}
Insert cell
theWeek = {
let theWeek = { Sun: 0, Mon: 1, Tue: 2, Wed: 3, Thu: 4, Fri: 5, Sat: 6 };
return theWeek;
}
Insert cell
theWeek["Mon"]
Insert cell
data2 = olympians
Insert cell
data2
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Plot.plot({
marks: [
Plot.rectY(olympians, Plot.binX({y: "count"}, {x: "weight"})),
Plot.ruleY([0])
]
})
Insert cell
data1
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Plot.plot({
marks: [
Plot.rectY(data1, { x: "orderDate", y: "total", interval: d3.utcDay }),
Plot.ruleY([0])
]
})
Insert cell
data1
X
day
Y
sum
total
Color
Size
Facet X
Facet Y
Mark
bar
Type Chart, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
moment = require("https://momentjs.com/downloads/moment-timezone-with-data.js")
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