Published unlisted
Edited
Dec 6, 2019
Insert cell
Insert cell
viewof inpA = html`<input type="range">A`
Insert cell
viewof inpB = html`<input type="range">B`
Insert cell
viewof reset = html`<button>Reset counts`
Insert cell
{
reset;
const state = { A: 0, B: 0 };
const divs = {
A: html`<div>A triggered 0 times.`,
B: html`<div>B triggered 0 times.`
};
const updateState = s => () =>
(divs[s].innerText = `${s} triggered ${++state[s]} times.`);
viewof inpA.addEventListener('input', updateState('A'));
viewof inpB.addEventListener('input', updateState('B'));
return html`${divs.A}${divs.B}`;
}
Insert cell
viewof zoomLevel = radio({
options: [
{ label: "Health District", value: "District" },
{ label: "City / County", value: "CityCounty" },
{ label: "ZCTA", value: "ZCTA" }
],
value: "ZCTA"
})
Insert cell
viewof ageGroup = radio({
options: [
{ label: 'Adult', value: 'Adult' },
{ label: 'Child', value: 'Child' }
],
value: 'Child'
})
Insert cell
{
viewof zoomLevel.addEventListener('input', updateDuration('zoomLevel'));
viewof ageGroup.addEventListener('input', updateDuration('ageGroup'));
}
Insert cell
updateDuration = function(s) {
if (s == 'zoomLevel') {
duration = 0;
}
duration = 600;
}
Insert cell
duration = 0
Insert cell
duration
Insert cell
import { select, radio } from "@jashkenas/inputs"
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