Public
Edited
Aug 20, 2022
Importers
Insert cell
Insert cell
Insert cell
Insert cell
y = x * 3
Insert cell
x = 67
Insert cell
z = 67
Insert cell
We can link the cells using dollar and curly bracket syntax

I am calculating the three multiple for ${x}, which is ${y}
Insert cell
Insert cell
<p style="font-size: 24px; color: red"> I am calculating the three multiple for ${x}, which is ${y} </p>
Insert cell
Insert cell
Insert cell
text = "hello"
Insert cell
Insert cell
// Here we are pasting our data
data = `area,sales,profit
north,5,2
east,25,8
west,15,6
south,20,5
central,10,3`
Insert cell
Insert cell
manualData = d3.csvParse(data, d3.autoType)
Insert cell
Insert cell
url = "https://docs.google.com/spreadsheets/d/e/2PACX-1vTPCMJ8uhkpU11KCRyov3p0uy5Tazcumq-al0HcMx-4fx3cvxZTYJ2WBqy5yGZUFoDo8TK5BC-4rS-c/pub?gid=0&single=true&output=csv"
Insert cell
sheetsData = d3.csv(url, d3.autoType)
Insert cell
Inputs.table(sheetsData, { width: 400 })
Insert cell
Insert cell
// Mark: barY
// Channel x: area
// Channel y: sales

Plot.barY(sheetsData, { x: "area", y: "sales" }).plot()
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.barY(sheetsData, { x: "area", y: "profit", fill: color }),
Plot.barY(sheetsData, { x: "area", y: "sales", opacity: 0.5 })
]
})
Insert cell
viewof color = Inputs.radio(["red", "green", "yellow"], {
label: "Choose a color",
value: "red"
})
Insert cell
// Mark: barY
// Channel x: area
// Channel y: sales
// Channel color: red

Plot.barY(sheetsData, {
x: "area",
y: "sales",
fill: "profit",
opacity: 0.5,
stroke: "black"
}).plot()
Insert cell
Plot.dot(sheetsData, { x: "profit", y: "sales" }).plot()
Insert cell
Insert cell
foldedData = aq.from(sheetsData).fold(["sales", "profit"]).objects()
Insert cell
Inputs.table(foldedData, { width: 400 })
Insert cell
vegaEmbed({
width: 600,
height: 400,
data: { values: foldedData },
mark: "bar",
encoding: {
x: { field: "area", type: "nominal", axis: { labelAngle: 0 } },
y: { field: "value", type: "quantitative" },
xOffset: { field: "key" },
color: { field: "key" }
}
})
Insert cell
vegaEmbed = require("vega-embed")
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