Public
Edited
May 1, 2023
1 fork
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
#b33a52
Size
Facet X
Facet Y
Mark
Auto
Type Chart, then Shift-Enter. Ctrl-space for more options.

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

Insert cell
Plot.auto(data, {
x: "Date",
y: "Close",
color: "#b33a52",
mark: "area"
}).plot()
Insert cell
Insert cell
Insert cell
Plot.auto(data, {
x: "Date",
y: "Close",
color: "#b33a52",
mark: "area"
}).plot()
Insert cell
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.ruleY([0]),
Plot.lineY(data, {x: "Date", y: "Close"})
]
})
Insert cell
// ... your code here
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
y: {
grid: true
},
x: {
grid: true
},
marks: [
Plot.ruleY([0]),
Plot.lineY(data, {x: "Date", y: "Close", stroke: "red"})
]
})
Insert cell
Insert cell
Insert cell
Plot.plot({
marginLeft: 100,
y: {
grid: true
},
x: {
grid: true
},
marks: [
Plot.ruleY([0]),
Plot.lineY(data, {
x: "Date",
y: "Close",
stroke: "red"}),
Plot.ruleY([0]),
Plot.lineY(data, {
x: "Date",
y: d => d["Volume"]/1_000_000_000,
stroke: "blue"})
],
})
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})
.derive({CloseStandardized: d => ( d.Close - op.mean(d.Close) ) / op.stdev(d.Close) || 0})
.objects()
Insert cell
Insert cell
Inputs.table(data_standardized)
Insert cell
Insert cell
Plot.plot({
marginLeft: 100,
y: {
grid: true,
label: "⬆︎Z-score"
},
x: {
grid: true
},
marks: [
Plot.ruleY([0]),
Plot.lineY(data_standardized, {
x: "Date",
y: "CloseStandardized",
stroke: "red"}),
Plot.ruleY([0]),
Plot.lineY(data_standardized, {
x: "Date",
y: "VolumeStandardized",
stroke: "blue"})
],
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Plot.plot({
marginLeft: 100,
y: {
grid: true,
label: "⬆︎Z-score"
},
x: {
grid: true
},
marks: [
Plot.ruleY([0]),
Plot.lineY(data_standardized, {
x: "Date",
y: "CloseStandardized",
stroke: "red"}),
Plot.ruleY([0]),
Plot.lineY(data_standardized, {
x: "Date",
y: "VolumeStandardized",
stroke: "blue"})
],
})
Insert cell
Insert cell
startYear_slider
Insert cell
aq.from(data_standardized)
.filter(aq.escape (d => d["Date"] > 1185877562903))
.object()
Insert cell
Insert cell
Insert cell
data_standardized[0].Date.constructor.name
Insert cell
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_standardized_filtered= aq.from(data_standardized)
.filter(aq.escape(d => d["Date"]>startYear_slider_asTimeObject))
.objects()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Uncomment to activate

import {Plot} from "@mkfreeman/plot-tooltip"
Insert cell
Plot.plot({
color: {
legend: true
},
y:{
grid: true,
nice: true,
label: "Z-Score"
},
x:{
grid: true,
nice: true
},
marks: [
Plot.lineY(data_standardized_filtered, {
x: "Date",
y: "CloseStandardized",
stroke:"salmon",
title: "CloseStandardized"
}),
Plot.lineY(data_standardized_filtered, {
x: "Date",
y: "VolumeStandardized",
stroke:"dodgerblue",
curve: "step",
title: d=> d3.format(".4s")(d["Volume"])
}
)]
})
Insert cell
Insert cell
Insert cell
Plot.plot({
color: {
legend: true
},
y:{
grid: true,
nice: true,
label: "Z-Score"
},
x:{
grid: true,
nice: true
},
marks: [
Plot.lineY(data_standardized_filtered, {
x: "Date",
y: "CloseStandardized",
stroke:"salmon",
title: d =>
` Close: ${ d3.format('.4s')(d["Close"]) }
Open: ${ d3.format('.4s')(d["Open"]) }
High: ${ d3.format('.4s')(d["High"]) }
Low: ${ d3.format('.4s')(d["Low"]) }`
}),
Plot.lineY(data_standardized_filtered, {
x: "Date",
y: "VolumeStandardized",
stroke:"dodgerblue",
curve: "step",
title: d =>
`Close: ${ d3.format('.4s')(d["Close"]) }
Open: ${ d3.format('.4s')(d["Open"]) }
High: ${ d3.format('.4s')(d["High"]) }
Low: ${ d3.format('.4s')(d["Low"]) }`
}
)]
})
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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more