Public
Edited
Mar 29, 2023
1 fork
Importers
Also listed in…
earthquakes
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

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