Public
Edited
Feb 28, 2023
Insert cell
Insert cell
pdfView(await FileAttachment("buddhism-final.pdf").url(), {
backgroundColor: "#776EA7",
fontColor: "#BDC6FF",
scale: 2
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
FileAttachment("slide1.png").image()
Insert cell
Insert cell
bgis-csv@1.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Plot.plot({
marks: [
Plot.dot(bgisCsv1, {x: "NEW_LAT", y: "NEW_LONG"})
]
})
Insert cell
FileAttachment("slide2.png").image()
Insert cell
Plot.plot({
marks: [
Plot.barY(bgisCsv1, {x: "TYPE_ENG", y: "OBJECTID", sort: {x: "y", reverse: true}}),
Plot.ruleY([0,100000]),
// Plot.color(field: "TYPE_ENG", type: "nominal", scale: {scheme: "category10"})
]
})
Insert cell
germanMorals = FileAttachment("german-morals.png").image()
Insert cell
Insert cell
Insert cell
Insert cell
printTable(germanyResponses)
Insert cell
printTable(ukResponses.splice(1,20))
Insert cell
FileAttachment("uk-bvc.png").image()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
{
const type_eng = vl
// .markPoint({ color: "#ec6833", size: 90, filled: true })
.data(bgis)
.encode(vl.x().fieldN("TYPE_ENG"), vl.tooltip(["TYPE_END"]));
}
Insert cell
stateProps = [
{ state: "Alabama", population: 2555 },
{ state: "Alaska", population: 3100 },
{ state: "Arizona", population: 6530 },
{ state: "Arkansas", population: 1555 },
{ state: "California", population: 73940 },
{ state: "Colorado", population: 5040 },
{ state: "Connecticut", population: 3770 },
{ state: "Delaware", population: 1505 },
{ state: "District of Columbia", population: 1515 },
{ state: "Florida", population: 10100 },
{ state: "Georgia", population: 4840 },
{ state: "Hawaii", population: 24960 },
{ state: "Idaho", population: 1600 },
{ state: "Illinois", population: 13260 },
{ state: "Indiana", population: 3270 },
{ state: "Iowa", population: 1650 },
{ state: "Kansas", population: 3070 },
{ state: "Kentucky", population: 2195 },
{ state: "Louisiana", population: 4650 },
{ state: "Maine", population: 3030 },
{ state: "Maryland", population: 6440 },
{ state: "Massachusetts", population: 7040 },
{ state: "Michigan", population: 9820 },
{ state: "Minnesota", population: 2815 },
{ state: "Mississippi", population: 1545 },
{ state: "Missouri", population: 6420 },
{ state: "Montana", population: 3120 },
{ state: "Nebraska", population: 3120 },
{ state: "Nevada", population: 1570 },
{ state: "New Hampshire", population: 1515 },
{ state: "New Jersey", population: 4430 },
{ state: "New Mexico", population: 3120 },
{ state: "New York", population: 19660 },
{ state: "North Carolina", population: 5110 },
{ state: "North Dakota", population: 1690 },
{ state: "Ohio", population: 11320 },
{ state: "Oklahoma", population: 1955 },
{ state: "Oregon", population: 2095 },
{ state: "Pennsylvania", population: 6830 },
{ state: "Rhode Island", population: 1525 },
{ state: "South Carolina", population: 2475 },
{ state: "South Dakota", population: 3050 },
{ state: "Tennessee", population: 6610 },
{ state: "Texas", population: 25350 },
{ state: "Utah", population: 3150 },
{ state: "Vermont", population: 3060 },
{ state: "Virginia", population: 8820 },
{ state: "Washington", population: 7140 },
{ state: "West Virginia", population: 1545 },
{ state: "Wisconsin", population: 3000 },
{ state: "Wyoming", population: 3160 }
]
Insert cell
printTable(stateProps.splice(1, 5))
Insert cell
vegaDatasets = (await require("vega-datasets@1.21.1")).default
Insert cell
embed = require("vega-embed@3")
Insert cell
projection = d3.geoAlbersUsa().scale(1300).translate([487.5, 305])
Insert cell
path = d3.geoPath()
Insert cell
us = FileAttachment("counties-albers-10m.json").json()
Insert cell
topojson = require("topojson-client@3")
Insert cell
colorScale = d3.scaleSequential(d3.interpolatePurples)
.domain([d3.min(data,d => d.value),
d3.max(data,d => d.value)])
// .range(["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"])

Insert cell
color = d3.scaleQuantize([43434, 83385], d3.schemePurples[9])
Insert cell
Insert cell
Insert cell
Insert cell
import {VegaLite} from 'vega-lite';
Insert cell
import {vega} from 'vega';
Insert cell


const spec = {
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"values": [
{"year": 2014, "tier": "a", "value": 29},
{"year": 2007, "tier": "a", "value": 39},
{"year": 2014, "tier": "b", "value": 29},
{"year": 2007, "tier": "b", "value": 28},
{"year": 2014, "tier": "c", "value": 10},
{"year": 2007, "tier": "c", "value": 7},
{"year": 2014, "tier": "d", "value": 1},
{"year": 2007, "tier": "d", "value": 1},
{"year": 2014, "tier": "e", "value": 27},
{"year": 2007, "tier": "e", "value": 19},
{"year": 2014, "tier": "f", "value": 4},
{"year": 2007, "tier": "f", "value": 6}
]
},
"mark": {"type": "bar", "cornerRadiusEnd": 3},
"encoding": {
"y": {"field": "tier", "type": "nominal", "sort": ["a", "b", "c", "d", "e", "f"]},
"x": {"field": "value", "type": "quantitative", "axis": {"title": "%"}},
"color": {
"field": "year",
"type": "nominal",
"scale": {"range": ["#4c78a8", "#f58518"]},
"legend": {"title": "Year"}
}
},
"width": 500,
"height": 150,
"title": "Comparison of Tiers by Year"
};

const runtime = new VegaLite.Runtime();
const view = new VegaLite.View(runtime, spec, {renderer: "svg"});

const svg = view.toSVG();

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more