Public
Edited
Nov 4, 2023
Insert cell
Insert cell
select
Insert cell
Insert cell
Plot.plot({
width,
y: {
type: "log",
domain: [0.1, 6],
grid: true
},
color: {
legend: true
},
marks: [
Plot.line(
indices2,
Plot.normalizeY({
basis: "first",
x: "Date",
y: "Close",
z: "Symbol",
stroke: (d) => (d.Symbol === select ? "steelblue" : "lightgrey"),
strokeOpacity: (d) => (d.Symbol === select ? 1 : 0.5),
strokeWidth: 5,
marker: true,
tip: true
// stroke: "Symbol"
})
),
Plot.frame()
]
})
Insert cell
Insert cell
viewof select = Inputs.select([...new Set(indices.map((d) => d.Symbol))], {
label: "Select one"
})
Insert cell
Plot.plot({
width,
y: {
type: "log",
domain: [0.1, 6],
grid: true
},
color: {
legend: true
},
marks: [
Plot.line(
indices2,
Plot.normalizeY({
basis: "first",
x: "Date",
y: "Close",
z: "Symbol",
filter: (d) => d.Symbol !== select,
stroke: (d) => (d.Symbol === select ? "steelblue" : "lightgrey"),
strokeOpacity: (d) => (d.Symbol === select ? 1 : 0.5),
strokeWidth: 5,
marker: true,
tip: true
// stroke: "Symbol"
})
),
Plot.line(
indices2,
Plot.normalizeY({
basis: "first",
x: "Date",
y: "Close",
z: "Symbol",
filter: (d) => d.Symbol === select,
stroke: (d) => (d.Symbol === select ? "steelblue" : "lightgrey"),
strokeOpacity: (d) => (d.Symbol === select ? 1 : 0.5),
strokeWidth: 5,
marker: true,
tip: true
// stroke: "Symbol"
})
),
Plot.frame()
]
})
Insert cell
Insert cell
Plot.plot({
width,
y: {
type: "log",
domain: [0.1, 6],
grid: true
},
color: {
legend: true
},
marks: [
Plot.line(
indicesSorted,
Plot.normalizeY({
basis: "first",
x: "Date",
y: "Close",
z: "Symbol",
stroke: (d) => (d.Symbol === select ? "steelblue" : "lightgrey"),
strokeOpacity: (d) => (d.Symbol === select ? 1 : 0.5),
strokeWidth: 5,
marker: true,
tip: true
// stroke: "Symbol"
})
),
Plot.frame()
]
})
Insert cell
indicesSorted = indices2.toSorted(mysort)
Insert cell
function mysort(a, b) {
if (a.Symbol === select && b.Symbol !== select) {
return 1;
}
if (b.Symbol === select && a.Symbol !== select) {
return -1;
}
return 0;
}
Insert cell
indices2 = indices.filter((d, i) => i % 30 === 0)
Insert cell
indices
Insert cell
import { indices } from "@d3/index-chart"
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