Public
Edited
Mar 29, 2023
1 fork
Importers
Insert cell
Insert cell
mymap = map
Insert cell
mychart = viewof chart
Insert cell
myinitialize = initialize
Insert cell
Insert cell
map_filter = {
const [t0, t1] = [chart[0][0].getTime(), chart[1][0].getTime()];
const [m1, m0] = [chart[0][1], chart[1][1]];
d3.select(map).selectAll("circle")
.attr("r", d => d.datum.properties.mag)
.attr("fill-opacity", 0.5)
.attr("stroke", "#f00")
.attr("visibility", d => (d.datum.properties.time > t0 && d.datum.properties.time < t1
&& d.datum.properties.mag > m0 && d.datum.properties.mag < m1)
? "visible" : "hidden");
// Count the visible earthquakes on the map
const n = d3.select(map).selectAll("circle")
.filter(function() { return d3.select(this).attr("visibility") == "visible" })
.nodes().length;
return md`${n} out of ${data.length} earthquakes are visible on the map.`
}
Insert cell
d3 = require("d3@6")
Insert cell
Insert cell
import {map, quakes} from "@pbogden/earthquakes"
Insert cell
myquakes = quakes // Expose "myquakes" for observable-jupyter users
Insert cell
Insert cell
data = quakes.map(d => [d.datum.properties.time, d.datum.properties.mag, d.datum])
Insert cell
// import {viewof chart} with {data as data} from "@pbogden/click-to-recenter-brush-iii"
import {viewof chart, initialize} with {data as data} from "5ecef56b3c75b0e6"
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