Published
Edited
Oct 5, 2022
1 fork
2 stars
Also listed in…
mapping
reusable
Insert cell
Insert cell
Insert cell
Insert cell
chart
Insert cell
Insert cell
map_filter = {
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 > chart[0].getTime()
&& d.datum.properties.time < chart[1].getTime())
? "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 ${my_data.length} earthquakes are visible on the map.`
}
Insert cell
d3 = require("d3@6")
Insert cell
Insert cell
myquakes = quakes
Insert cell
Insert cell
Insert cell
my_data = quakes.map(d => [d.datum.properties.time, d.datum.properties.mag])
Insert cell
//import {viewof chart} with {my_data as data} from "@pbogden/click-to-recenter-brush-ii"
import {viewof chart} with {my_data as data} from "c3701ebacf0454b1"
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