Published
Edited
Feb 5, 2020
Insert cell
md`# #1: Using "viewof" function - can take many forms such as image, text, json, csv, etc... choosing files from local computers
`

Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
d3 = require('d3-dsv')
Insert cell
viewof f = html`<input type=file accept=".csv">`
Insert cell
first_data = d3.csvParse(await Files.text(f))
Insert cell
first_data
Insert cell
vl.markPoint()
.data(first_data)
.encode(
vl.y().average('sewer_and_water'),
vl.x().fieldN('power')
)
.render()
Insert cell
md`# #2: Using "await" function - upload csv files into observable and parse data
`


Insert cell
second_data = d3.csvParse(await FileAttachment("mc1-reports-data.csv").text())

Insert cell
second_data
Insert cell
vl.markPoint()
.data(second_data)
.encode(
vl.y().average('sewer_and_water'),
vl.x().fieldN('power')
)
.render()
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

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