Published
Edited
Sep 29, 2022
1 fork
Insert cell
Insert cell
viewof sortSelection = {
const sortForm = radio({
title: 'Sort By',
description: 'Select value to sort by (descending)',
options: [
{ label: 'Average Acceptance', value: 'avgAcceptance' },
{ label: 'Acceptance by the Relgious', value: 'religious' },
{ label: 'Acceptance by the non-Religious', value: 'nonReligious' },
],
value: 'nonReligious'
});
return sortForm;
}
Insert cell
chart = {
const svg = d3.create("svg")
.attr("viewBox", [0, 0, width, height])
// add x axis
buildXAxis(svg);
// add y axis
buildYAxis(svg)
// add group for chart area
createChartGroup(svg)

// create group for bars
plotBars(svg)
// create group for 'Very Important' dots
plotDotsImportant(svg)
// create group for dot 'Not Very Important' dots
plotDotsNotImportant(svg)
// create legend at top
buildLegend(svg);

let updateYAxis = () => {
yScale.domain(sortedData.map(d => d.country)).transition().duration(100)
}
viewof sortSelection.addEventListener("input", updateYAxis)

return svg.node();
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

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