Public
Edited
Feb 24, 2023
1 fork
Insert cell
Insert cell
viewof index = Inputs.radio([2019, 2050], {label: "Show what year?", value: 2019})
Insert cell
viewof radiusRange = rangeSlider({
min: 0.0005,
max: 50,
// Note that values must be specified as array of length 2.
value: this ? this.value : [1, 25],
// Custom slider CSS, replaces all styles.
// theme: themes[theme],
// Overrides the range color. Support for range colors is up to the theme.
title: 'Circle radius',
description: 'Control minimum and maximum radius',
})
Insert cell
Insert cell
map = {
worldMap.select("#cities").remove()
worldMap.select("#connections").remove()
worldMap.select("#names").remove()

worldMap.append("g")
.attr("id", "cities")
.selectAll("circle")
.data(data.nodes)
.join("circle")
.attr("transform", d => `translate(${mapProjection([d[lngBase], d[latBase]])})`)
.attr('r', d => radiusFxn(parseFloat(d[radBase])))
.attr('fill', d => colorScale(d[colorBase]))
.attr("stroke", d => colorScale(d[colorBase]) === '#000000' ? 'white' : 'black')
.attr("stroke-width", 0.5)

return worldMap.node()
}
Insert cell
Insert cell
data.nodes[0]
Insert cell
radBase = index === 2019 ? "total_flights" : 'total_flights_2050';
Insert cell
colorBase = index === 2019 ? "community" : 'community_all_combined';
Insert cell
lngBase = 'city_lng'
Insert cell
latBase = 'city_lat'
Insert cell
colorScale = d3.scaleOrdinal().domain(communityDomain).range(['#e6194b', '#3cb44b', '#ffe119', '#4363d8', '#f58231', '#911eb4', '#46f0f0', '#f032e6', '#bcf60c', '#fabebe', '#008080', '#e6beff', '#9a6324', '#fffac8', '#800000', '#aaffc3', '#808000', '#ffd8b1', '#000075', '#808080', '#ffffff', '#000000']);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
new_edges = FileAttachment("new-all-city-year-edges-small.csv").csv({typed: true})
Insert cell
old_nodes = FileAttachment("all-whole-year-city-nodes.csv").csv({typed: true})
Insert cell
old_edges = FileAttachment("all-whole-year-city-edges.csv").csv({typed: true})
Insert cell
Insert cell
import {legend, Swatches} from "@d3/color-legend"
Insert cell
import {rangeSlider} from '@mootari/range-slider'
Insert cell
import {mapProjection, activeColorScheme, worldMap} from "b3a0a78984d6df2e"
Insert cell
import {slider} from "@jashkenas/inputs"
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