Published
Edited
Apr 10, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
letter_selected = Generators.observe(
// selection_caught will (yield) a value promise with the selected letters
initialize_f
)
Insert cell
function initialize_f(change_) {
// creating an event listener (ie a function to attach to some DOM element)
const signaled = (name, value) => change_(value);

// attaching the event listener and naming it "test_selection"
barChart.addSignalListener("test_selection", signaled);

// check the doc ... https://github.com/observablehq/stdlib
change_(barChart.signal("test_selection"));

function dispose_f() {
return barChart.removeSignalListener("test_selection", signaled);
}

return dispose_f;
}
Insert cell
Insert cell
// a function to reshape the data as the original one
restaured_data = d3
.zip(letter_selected.a, letter_selected.b)
.map(d => ({ a: d[0], b: d[1] }))
Insert cell
Insert cell
viewof linked_chart = vl2({
$schema: "https://vega.github.io/schema/vega-lite/v4.json",
description: "A simple bar chart with embedded data.",
data: { values: restaured_data },
mark: "bar",
encoding: {
x: { field: "a", type: "ordinal", axis: { labelAngle: 0 } },
y: { field: "b", type: "quantitative" }
}
})
Insert cell
Insert cell
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