Published
Edited
Feb 2, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = FileAttachment("heart.csv").csv()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
series = d3.stack().keys(newData.columns.slice(1))(newData)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
grouped = d3.rollup(data, v => d3.count(v, d => d["cp"]), d => +d["cp"])
Insert cell
y = d3
.scaleLinear()
.domain([0, d3.max(grouped, d => d[1])])
.range([height - margin.bottom, margin.top])
Insert cell
x = d3
.scaleLinear()
.domain([d3.min(data, d => +d["cp"]), d3.max(data, d => +d["cp"]) + 1])
.range([margin.left, width - margin.right])
Insert cell
yAxis = g =>
g.attr("transform", `translate(${margin.left},0)`).call(d3.axisLeft(y))
Insert cell
xAxis = g =>
g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(x).ticks(5))
Insert cell
Insert cell
sales = FileAttachment("sales.csv").csv()
Insert cell
d3.map(sales, d => {
return d["Year"], d["NA_Sales"];
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ySales = d3
.scaleLinear()
.domain([
0,
d3.max(
[
d3.max(sales, d => +d["Global_Sales"]),
d3.max(sales, d => +d["NA_Sales"])
],
d => d
)
])
.range([height - margin.bottom, margin.top])
Insert cell
xSales = d3
.scaleLinear()
.domain([d3.min(sales, d => +d["Year"]), d3.max(sales, d => +d["Year"])])
.range([margin.left, width - margin.right])
Insert cell
yAxisSales = g =>
g.attr("transform", `translate(${margin.left},0)`).call(d3.axisLeft(ySales))
Insert cell
xAxisSales = g =>
g
.attr("transform", `translate(0,${height - margin.bottom})`)
.call(d3.axisBottom(xSales).tickFormat(d3.format("")))
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import {
displayCaution,
assignment_instructions,
observable_challenges
} from "@uw-info474/utilities"
Insert cell
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