Public
Edited
May 16
4 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// the mean of half of a bell curve
meanDeviation = Math.sqrt( 2 / Math.PI ) // * σ
Insert cell
Insert cell
Insert cell
Insert cell
ss_beneficiary_to_worker_ratio.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
ss__ratio_1945_to_2023 = ss_beneficiary_to_worker_ratio
Insert cell
UN_1950-2023@1.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
Insert cell
ss_data_1950_2023_v2 = {
let data = []
for( let i=1950; i<=2023; i++){
let r1 = ss__ratio_1945_to_2023.find(e=>e.year===i)
let r2 = ss_worker_beneficiary_numbers_v1.find(e=>e.date===i)
let retirement = retirement_age_1935_to_2030.find(e=>e.year===i-65)
retirement = retirement==undefined ? {year: i-65, age: "65.00", text: "65"} : retirement
data.push({
year:i,
retirement:retirement,
pyramid:us_population_1950_to_2023 .filter(e=>e.year===i),
ratio: {year:r1.year, ratio:r1.ratio, workers:r2.workers, beneficiaries:r2.beneficiaries}
})
}
return data
}
Insert cell
ss_worker_beneficiary_numbers_v3.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
ratioData = workerBeneficiaryNumberRatio
Insert cell
Insert cell
ss_worker_beneficiary_numbers_v1.csv
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
ss_worker_beneficiary_numbers = ss_worker_beneficiary_numbers_v1
Insert cell
{
// Data
const data = [
{id: "A0", category: "A", value: 74.7},
{id: "B0", category: "B", value: 95.3},
{id: "B1", category: "B", value: 10},
{id: "C0", category: "C", value: 35.7},
{id: "C1", category: "C", value: 39.6},
{id: "D0", category: "D", value: 35.1},
{id: "D1", category: "D", value: 95.3},
{id: "D2", category: "D", value: 10},
{id: "D3", category: "D", value: 16.9},
];
// Create a stacked bar chart
return Plot.plot({
marginLeft: 60,
height: 400,
width: 600,
marks: [
Plot.barY(data, {
x: "category",
y: "value",
fill: "id",
stack: true
}),
Plot.ruleY([0])
],
x: {
label: "Category"
},
y: {
label: "Value"
},
color: {
legend: true
}
})
}
Insert cell
retirementAge= d3.scaleLinear()
.domain([1940, 2002, 2008, 2020, 2026])
.range([65, 65, 66, 66, 67])
Insert cell
retirementAge(2005)
Insert cell
Insert cell
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