Published
Edited
Dec 23, 2019
3 stars
Insert cell
Insert cell
//only chrome...
//labels spaz
Insert cell
Insert cell
{
await Lines(await visibility());
await Horizons();
await Areas();

await StackedArea();
await StreamAreas();

await OverlappingArea();
}
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
line(Symbols[0].values)
Insert cell
data = Symbols[0]
Insert cell
html`<style>

path{
fill:none;
stroke:black;
}

</style>`
Insert cell
svg = d3.select(SVG)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
series = d3
.stack()
.keys(keys)
.offset(d3.stackOffsetWiggle)
.order(d3.stackOrderReverse)(Symbols2)
Insert cell
Symbols2 = d3
.groups(csvData, d => +d.date)
.map(x => {
let obj = {};
obj.date = new Date(x[0]);
x[1].map(v => {
obj[v.symbol] = +v.price;
});
return obj;
})
Insert cell
values = d3.rollups(csvData, ([d]) => d.price, d => +d.date, d => d.symbol)

// values = Array.from(
// d3.rollup(csvData, ([d]) => d.price, d => +d.date, d => d.symbol)
// ).map(x => {
// x[0] = d3.timeParse('%Q')(x[0]);
// return x;
// })
Insert cell
Symbols.map((x, i) => {
x.values.map((v, ii) => {
let symbols = Symbols.filter((_, j) => j > i);
v.price0 = d3.sum(symbols.map(x => x.values[ii].price));
return v;
});
return x;
})
Insert cell
axis = d3
.line()
.x(({ date }) => x(date))
.y(h)
.curve(d3.curveNatural)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
keys = Symbols.map(x => x.key)
Insert cell
radius = 5
Insert cell
// symbolGroup = svg
// .selectAll(".symbol")
// .data(Symbols, d => d.key)
// .join("g")
// .attr("class", "symbol")
Insert cell
area(Symbols[0].values)
Insert cell
area = d3
.area()
.x(({ date }) => x(date))
.y1(({ price }) => y(price))
.curve(d3.curveNatural)
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