Public
Edited
May 1, 2023
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
AAPL.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
data
X
Date
Y
Close
Color
#ff5375
Size
Facet X
Facet Y
Mark
line
Type Chart, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
data
X
Date
Y
Close
Color
#ff5375
Size
Facet X
Facet Y
Mark
area
Type Chart, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
Insert cell
Plot.auto(data, {
x: "Date",
y: "Close",
color: "#ff5375",
mark: "line"
}).plot()
Insert cell
Insert cell
Insert cell
Plot.plot({
marks: [Plot.ruleY([0]), Plot.lineY(data, { x: "Date", y: "Close" })]
})
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
x: {
grid: true
},
y: {
grid: true
},
marks: [
Plot.ruleY([0]),
Plot.lineY(data, {
x: "Date",
y: "Close",
stroke: "salmon"
})
]
})
Insert cell
Insert cell
Insert cell
Plot.plot({
x: {
grid: true
},
y: {
grid: true
},
marks: [
Plot.ruleY([0]),
Plot.lineY(data, {
x: "Date",
y: "Close",
stroke: "salmon"
}),
Plot.lineY(data, {
x: "Date",
y: (d) => d["Volume"] / 100_000_000,
stroke: "dodgerblue"
})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
// Uncomment to activate
// `Close` is standardized for you.
// You should do the `Volume` yourself

data_standardized = aq
.from(data)
.derive({
CloseStandardized: (d) =>
(d.Close - op.mean(d.Close)) / op.stdev(d.Close) || 0
})
.derive({
VolumeStandardized: (d) =>
(d.Volume - op.mean(d.Volume)) / op.stdev(d.Volume) || 0
})
.objects()
Insert cell
Insert cell
Inputs.table(data_standardized)
Insert cell
Insert cell
Plot.plot({
x: {
grid: true
},
y: {
grid: true
},
marks: [
Plot.lineY(data_standardized, {
x: "Date",
y: "CloseStandardized",
stroke: "salmon"
}),
Plot.lineY(data_standardized, {
x: "Date",
y: "VolumeStandardized",
stroke: "dodgerblue"
})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof startYear_slider = Inputs.range([1985, 2023], {
label: "Start Year",
step: 1
})
Insert cell
Insert cell
startYear_slider
Insert cell
Insert cell
// To use copied code replace "data" with your own variable
aq
.from(data_standardized)
.filter((d) => d["Date"] > 1078145679826.4642)
.objects() // Uncomment to return an array of objects
Insert cell
Insert cell
Insert cell
data_standardized[0].Date.constructor.name
Insert cell
Insert cell
data_standardized[0].Date.getTime()
Insert cell
Insert cell
Insert cell
Insert cell
startYear_slider_asTimeObject = new Date(startYearFixed_slider, 1).getTime()
Insert cell
Insert cell
data_standerdized_filtered = aq
.from(data_standardized)
.filter(aq.escape((d) => d["Date"] > startYear_slider_asTimeObject))
.objects() // Uncomment to return an array of objects
Insert cell
viewof startYearFixed_slider = Inputs.range([1985, 2023], {
label: "Start Year",
step: 1
})
Insert cell
Insert cell
Plot.plot({
x: {
grid: true
},
y: {
grid: true
},
marks: [
Plot.lineY(data_standerdized_filtered, {
x: "Date",
y: "CloseStandardized",
stroke: "salmon"
}),
Plot.lineY(data_standerdized_filtered, {
x: "Date",
y: "VolumeStandardized",
stroke: "dodgerblue"
})
]
})
Insert cell
Insert cell
Plot.plot({
x: {
grid: true
},
y: {
grid: true
},
marks: [
Plot.lineY(data_standerdized_filtered, {
x: "Date",
y: "CloseStandardized",
stroke: "salmon"
}),
Plot.lineY(data_standerdized_filtered, {
x: "Date",
y: "VolumeStandardized",
stroke: "dodgerblue",
curve: "step"
})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
color: {
legend: true
},
x: {
grid: true
},
y: {
grid: true
},
marks: [
Plot.lineY(data_standerdized_filtered, {
x: "Date",
y: "CloseStandardized",
stroke: "salmon"
}),
Plot.lineY(data_standerdized_filtered, {
x: "Date",
y: "VolumeStandardized",
stroke: "dodgerblue",
curve: "step"
})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
color: {
legend: true
},
x: {
grid: true,
nice: true
},
y: {
grid: true,
nice: true,
label: "↑Z-Score"
},
marks: [
Plot.lineY(data_standerdized_filtered, {
x: "Date",
y: "CloseStandardized",
stroke: "salmon"
}),
Plot.lineY(data_standerdized_filtered, {
x: "Date",
y: "VolumeStandardized",
stroke: "dodgerblue",
curve: "step"
})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
// Uncomment to activate

import { Plot } from "@mkfreeman/plot-tooltip"
Insert cell
Plot.plot({
color: {
legend: true
},
x: {
grid: true,
nice: true
},
y: {
grid: true,
nice: true,
label: "↑Z-Score"
},
marks: [
Plot.lineY(data_standerdized_filtered, {
x: "Date",
y: "CloseStandardized",
stroke: "salmon",
title: "Close"
}),
Plot.lineY(data_standerdized_filtered, {
x: "Date",
y: "VolumeStandardized",
stroke: "dodgerblue",
curve: "step",
title: "Volume"
})
]
})
Insert cell
Insert cell
Insert cell
Insert cell
// ... your code here
Insert cell
Insert cell
import {Wrangler, op} from "@observablehq/data-wrangler"
Insert cell
Insert cell
import {toc} from "@nebrius/indented-toc"
Insert cell
import {imageToDo} from "@clokman/student-blocks"
Insert cell
imageToDo
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