Public
Edited
Mar 7, 2023
Insert cell
Insert cell
Insert cell
plot_by_year = Plot.plot({
marks: [
Plot.barY(ms_by_year, {x: "year", y: "count_tests", fill: "nth_test"}),
Plot.ruleY([0])
],
x: {
type: "band",
labelOffset: 40,
label: "Year"
},
y: {
grid: true,
label: "N. people"
},
color: {
type: "categorical",
domain: [1, 2],
range: [palette.accent, palette.softAccent],
legend: "ramp"
},
style: commonStyle,
marginLeft: 130,
marginTop: 30,
marginBottom: 50
})
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
plot_by_year_ckd = Plot.plot({
marks: [
Plot.barY(ckd_by_year_cumulative, {x: "year", y: "count_tests", fill: "nth_test"}),
Plot.ruleY([0])
],
x: {
type: "band",
labelOffset: 40,
label: "Year"
},
y: {
grid: true,
label: "N. people (cumulative)",
domain: [0, 400000]
},
color: {
type: "categorical",
domain: ["1", "2–9", "10–39", "40–99", "100+"],
//scheme: "rdpu",
range: [palettePink.accent, palettePink.softAccent, palettePink.softAccent2, palettePink.softAccent3, palettePink.softAccent4],
legend: "ramp"
},
style: commonStyle,
marginLeft: 130,
marginTop: 30,
marginBottom: 50
})
Insert cell
Insert cell
palette = paletteBlue
Insert cell
Insert cell
paletteBlue = {return {
neutral: "#a3acb2",
softNeutral: "#d0d0d0",
accent: "#3e94b9",
softAccent: "#afcfe0"
}}
Insert cell
Insert cell
palettePink = {return {
neutral: "#b3a8aa",
softNeutral: "#d0d0d0",
accent: "#551665",
softAccent: "#9152a3",
softAccent2: "#b37ec4",
softAccent3: "#d1addc",
softAccent4: "#f6d9ff"
}}
Insert cell
commonStyle = {return {
fontFamily: "Open Sans",
fontSize: "14px"
}}
Insert cell
Insert cell
smallStudiesG6_msLileukNthTestByYear = FileAttachment("small-studies@1.G6_MS.LiLeuk.nth-test-by-year.json").json()
Insert cell
funnel = smallStudiesG6_msLileukFunnel
Insert cell
smallStudiesG6_msLileukFunnel = FileAttachment("small-studies@7.G6_MS.LiLeuk.funnel.json").json()
Insert cell
smallStudiesN14_chronkidneydisFunnel = FileAttachment("small-studies@3.N14_CHRONKIDNEYDIS.funnel.json").json()
Insert cell
by_year = ckd_by_year
Insert cell
ckd_by_year = FileAttachment("small-studies.N14_CHRONKIDNEYDIS.P-Krea.nth-test-by-year.csv").csv()
.then(data => {
return data.map(row => ({
year: row.year,
nth_test: agg_nth_test(Number(row.nth_test)),
count_tests: Number(row.cnt_tests)
}))
})
Insert cell
ckd_by_year_cumulative = FileAttachment("small-studies.N14_CHRONKIDNEYDIS.P-Krea.nth-test-by-year.with-cumulative.csv").csv()
.then(data => {
return data.map(row => ({
year: row.year,
nth_test: agg_nth_test(Number(row.nth_test)),
count_tests: Number(row.cnt_tests_cumulative)
}))
})
Insert cell
function agg_nth_test(n) {
if (n == 1) {
return "1"
} else if (n >= 2 && n < 10) {
return "2–9"
} else if (n >= 10 && n < 40) {
return "10–39"
} else if (n >= 40 && n < 100) {
return "40–99"
} else if (n >= 100) {
return "100+"
}
}
Insert cell
ms_by_year = FileAttachment("small-studies.G6_MS.Li-Leuk.nth-test-by-year.csv").csv()
.then(data => {
return data.map(row => ({
year: row.year,
nth_test: Number(row.nth_test),
count_tests: Number(row.cnt_tests)
}))
})
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