Public
Edited
Oct 20, 2022
Fork of DS3 intro
Insert cell
# DS3 intro
Insert cell
Insert cell
bandcampOneday = FileAttachment("bandcamp-oneday.csv").csv()
Insert cell
data= bandcampOneday;

Insert cell
Insert cell
Inputs.table(data)
Insert cell
Insert cell
itmpr=data.map(d => d.item_price)
Insert cell
Insert cell
d3.sum(data, d => d.item_price)
Insert cell
Insert cell
Insert cell
import { SummaryTable } from "@observablehq/summary-table"
Insert cell
Insert cell
// Create a view of the summary statistics
viewof summary_data = SummaryTable(data, {label: "artist_name"})
Insert cell
Insert cell
Insert cell
// See the data again
Inputs.table(data)
Insert cell
//Filter data set
sample = data.filter(d => d.country == "Netherlands")
Insert cell
Insert cell
// type your code here:Plot.plot({
Plot.plot({
marks: [
Plot.dot(sample, {x: "utc_timestamp", y: "amount_paid", fill:"blue" }),
Plot.dot(sample, {x: "utc_timestamp", y: "item_price", fill:"green"}),
]
})
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.dot(sample, {x: "utc_timestamp", y: "item_price", stroke: "orange"}),
Plot.arrow(sample, { x1: "utc_timestamp", y1: "item_price", x2: "utc_timestamp", y2: "amount_paid" })
]
})
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.dot(sample, {x: "utc_timestamp", y: d => d.amount_paid - d.item_price, stroke: "orange"})

]
})

Insert cell
Insert cell
viewof groupby = Inputs.select(["type", "country"], {label: "group by"})
Insert cell
Insert cell
viewof color = Inputs.radio(["red", "green", "blue"], {label: "color"})
Insert cell
Insert cell
countries = new Set(data.map(d => d.country))
Insert cell
Insert cell
viewof country = Inputs.select(countries, { label: "select a country" })
Insert cell
Plot.barX(data.filter(d => d.country == country), Plot.groupY({x: "sum"}, {
x: "amount_paid",
y: "type",
sort: { y: "x", reverse: true, limit: 10 }
}))
.plot({
marginLeft: 100
})
Insert cell
Insert cell
import {Scatterplot} from "@d3/scatterplot"
Insert cell
Insert cell
randoms = Array.from({length: 1000}, () => Math.random() * Math.random())
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