Public
Edited
Jun 26, 2024
Paused
1 star
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
import {Plot} from "@mkfreeman/plot-tooltip"
Insert cell
all_counts@3.parquet
with topfields as (
select concept, sum(n)::int as n, threshold::string as thresh
from all_counts c
where s2fieldsofstudy = ${select_fos}
AND thresh = ${radios}
GROUP BY (concept, thresh)
ORDER BY n DESC
LIMIT ${range}
)

select a.year as date, a.concept, sum(a.n)::int as n, a.threshold::string as thresh, joined
from all_counts a
JOIN topfields b ON a.concept = b.concept
WHERE a.s2fieldsofstudy = ${select_fos}
AND a.threshold = ${radios}
AND date >= 1960
AND date <= 2020
GROUP BY (date, a.concept, a.threshold, joined)
ORDER BY date
Insert cell
propdata = {
const tot_first = d3.sum(count_data.filter(d => d.date == form.option1).map(d => d.n))
const tot_last = d3.sum(count_data.filter(d => d.date == form.option2).map(d => d.n))
const out = []
for (let i = 0; i < count_data.length; ++i) {
if (count_data[i]['date'] == form.option1 || count_data[i]['date'] == form.option2 ) {
const inner_out = {}
inner_out['concept'] = count_data[i]['concept']
if (count_data[i]['date'] == form.option1) {
inner_out['type'] = `${form.option1}`
inner_out['value'] = parseInt((count_data[i]['n'] / tot_first*100).toPrecision(2))
} else if (count_data[i]['date'] == form.option2) {
inner_out['type'] = `${form.option2}`
inner_out['value'] = parseInt((count_data[i]['n'] / tot_last*100).toPrecision(2))
}
out.push(inner_out)
}
}

return out
}
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