Published
Edited
Jul 13, 2020
2 forks
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
stockChart([
'NDAQ',
'SHOP',
'NVDA',
'AMD',
'NFLX',
'BRKB',
'ARKW',
'ARKK',
'ARKG',
'ARKQ'
])
Insert cell
Insert cell
Insert cell
stockChart(['ZM', 'AMZN', 'GOOGL', 'PTON', 'SHOP', 'NFLX', 'FB'])
Insert cell
Insert cell
stockChart(['UBER', 'BYND', 'DIS', 'SPCE'])
Insert cell
Insert cell
stockChart(['FORD', 'TM', 'VWAGY', 'HMC', 'FUJHY'])
Insert cell
Insert cell
stockChart([
'BA',
'EADSY',
'JETS',
'DAL',
'AAL',
'LUV',
'UAL',
'SKYW',
'ALK',
'SAVE',
'JBLU'
])
Insert cell
Insert cell
stockChart(['CCL', 'NCLH', 'RCL', 'MGM'])
Insert cell
Insert cell
stockChart(['H', 'WYND', 'HLT', 'MAR'])
Insert cell
Insert cell
stockChart(['HGV', 'VAC'])
Insert cell
Insert cell
stockChart(['RPAI', 'XRT', 'NNN', 'SBUX', 'BBBY', 'PLAY', 'GPS', 'M', 'AMC'])
Insert cell
Insert cell
stockChart(['BP', 'UCO', 'CVX', 'MRO', 'XOM', 'USO'])
Insert cell
Insert cell
stockChart(['CGC', 'CRON', 'ACB'])
Insert cell
Insert cell
stockChart(['IVR', 'NRZ'])
Insert cell
Insert cell
stockChart(['GE', 'LMT', 'RTX'])
Insert cell
Insert cell
stockChart = async symbols => {
const data = await symbols.reduce(async (result, symbol) => {
const data = await getQuoteHistory(symbol, range);
return [
...(await result),
...data.map(({ date, close }) => ({
symbol,
date: new Date(date.getFullYear(), date.getMonth(), date.getDate()),
close
}))
];
}, Promise.resolve([]));
const element = lineChart(data);
element.value = data;
return element;
}
Insert cell
lineChart = data => {
const hover = vl
.selectSingle()
.encodings('x')
.on('mouseover')
.nearest(true)
.empty('none');
const line = vl
.markLine()
.encode(
vl.x().fieldT('date'),
vl.y().fieldQ('close'),
vl.color().fieldN('symbol')
);
const base = line.transform(vl.filter(hover));
const label = { align: 'left', dx: 5, dy: -5 };
const white = { stroke: 'white', strokeWidth: 2 };
return vl
.data(data)
.layer(
line.select(
vl
.selectInterval()
.bind('scales')
.encodings('x')
),
vl
.markRule({ color: '#aaa' })
.transform(vl.filter(hover))
.encode(vl.x().fieldT('date')),
line
.markCircle()
.select(hover)
.encode(
vl
.opacity()
.if(hover, vl.value(1))
.value(0)
),
base.markText(label, white).encode(vl.text().fieldQ('close')),
base.markText(label).encode(vl.text().fieldQ('close'))
)
.width(width - 120)
.height(400)
.render();
}
Insert cell
import { getQuote, getQuoteHistory } from '@gnestor/yahoo-finance'
Insert cell
import {select} from '@jashkenas/inputs'
Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
d3 = require('d3')
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