Public
Edited
Nov 1, 2022
1 fork
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// data = {
// map.update(stinky.length > 0 ? stinky : [])

// return d3.select(map).selectAll("circle").data();
// }
Insert cell
stinky = {
// https://observablehq.com/@mbostock/fetch-error-handling
const url='https://raw.githubusercontent.com/ds5110/stinky2/main/sample_data/smc_data.csv';

const response = await fetch(url);
if (!response.ok) {
return []
// throw new Error("sorry about that...unable to fetch");
}
return d3.csvParse(await response.text()).map(d => [+d.longitude, +d.latitude]);
}
Insert cell
data = {
const wind = {N:0, NE:45, E:90, SE:135, S:180, SW:225, W:270, NW:315};
const csv = await d3.csv('https://raw.githubusercontent.com/ds5110/stinky2/main/sample_data/merged_data.csv');

return csv.map(d => [new Date((+d.date.slice(0,4)), +d.date.slice(5,7)-1,+d.date.slice(8,10)), wind[d.wind_direction], [+d.longitude, +d.latitude]]
);
}
Insert cell
Insert cell
styling = {
d3.select(brush).select(".x-axis").attr("font-size", 15);
d3.select(brush).select(".y-axis").attr("font-size", 15);
}
Insert cell
url = (x, y, z) => `https://${"abc"[Math.abs(x + y) % 3]}.basemaps.cartocdn.com/rastertiles/voyager/${z}/${x}/${y}${devicePixelRatio > 1 ? "@2x" : ""}.png`
Insert cell
// url = (x, y, z) => `https://${"abc"[Math.abs(x + y) % 3]}.basemaps.cartocdn.com/light_all/${z}/${x}/${y}${devicePixelRatio > 1 ? "@2x" : ""}.png`
Insert cell
x = d3.scaleLinear(d3.extent(data, d => d[0]), [margin.left, width - margin.right])
Insert cell
margin = ({top: 30, right: 50, bottom: 30, left: 80})
Insert cell
height = 500
Insert cell
// initialCenter = [-69.4455, 45.2538] // Maine is 45.2538° N, 69.4455° W -- use with initial scale 1 << 15
initialCenter = [-70.2568, 43.645] // Portland, Maine 43.6591° N, 70.2568° W
Insert cell
initialScale = 1 << 21
Insert cell
features = d3.json("https://cdn.jsdelivr.net/npm/us-atlas@3/states-10m.json").then(topology => topojson.feature(topology, topology.objects.states))
Insert cell
topojson = require("topojson-client@3")
Insert cell
//import {viewof chart} with {data, title, x, margin} from "@pbogden/click-to-recenter-brush-iii"
import {viewof chart} with {data, title, margin} from "@pbogden/click-to-recenter-brush-iii"
Insert cell
d3 = require("d3@6", "d3-tile@1")
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