Published
Edited
Nov 20, 2020
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
barCharts = {
const container = html`<div class="bar-charts-container">
<style>
.bar-charts-container {
width: ${width}px;
}
.bar-charts-container p {
font-family: sans-serif;
margin: 0;
}
.bar-charts-container > div {
padding: 12px;
}
</style>
</div>`;

for (const [state, data] of diseaseDataByState) {
const title = `${state} Prevalence of ${diseaseSelected} by Race / Ethnicity`;
const chart = drawRowChart({
data,
width: (width * 2) / 3,
height: (width * 1) / 5,
pct: true,
margin: { top: 12, right: 48, bottom: 24, left: 140 }
});
const dl = showDlButton
? DOM.download(() => serialize(chart), title, "Save as SVG")
: "";

container.append(html`<div class="state-chart-container">
<p style="font-weight:bold;">${title}</p>
${chart}
${dl}
</div>`);
}

return container;
}
Insert cell
Insert cell
Insert cell
diseaseSelected = diseasePickerOptions.find(d => d.value === diseasePicker)
.label
Insert cell
diseaseDataByState = new Map(
diseaseData.map(({ locationdesc, ...rest }) => [
locationdesc,
Object.entries(rest).map(([key, value]) => ({ name: key, value }))
])
)
Insert cell
diseaseData = pivotbyRaceTable.objects()
Insert cell
diseasePickerOptions = {
const questions = cdiQuestions.slice(1);
const diseases = ["Asthma", "COPD", "Diabetes"];

return questions.map((q, i) => ({ value: q, label: diseases[i] }));
}
Insert cell
Insert cell
import { drawRowChart } from "@clhenrick/reusable-row-chart"
Insert cell
import { pivotbyRaceTable, someQuestions as cdiQuestions } with {
diseasePicker as questionPicker
} from "@clhenrick/het-data-intake-u-s-chronic-disease-indicators-cdi-brfss"
Insert cell
import { serialize } from "@mbostock/saving-svg"
Insert cell
import { select, checkbox } from "@jashkenas/inputs"
Insert cell
d3 = require("d3@6")
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