Public
Edited
Sep 13, 2023
Fork of Marimekko
1 fork
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
colorScale = d3
.scaleOrdinal(d3.schemeCategory10)
.domain(chartData.map((d) => d.cat2Name))
Insert cell
chartData = {
let result = [];
for (let cat1 of allClassifications[inputClassification].categories) {
if (cat1.id == "-8") continue;
censusData[inputClassification + ".json"][cat1.id][
outputClassification
].count.forEach((d, i) => {
const cat2Name =
outputClassificationsDetails[outputClassification].categories[i].label;
result.push({ cat1Name: cat1.label, cat2Name, value: d });
});
}
return result;
}
Insert cell
inputClassifications = FileAttachment("input-classifications.json").json()
Insert cell
outputClassifications = FileAttachment("output-classifications.json").json()
Insert cell
allClassifications = FileAttachment("all-classifications.json").json()
Insert cell
censusData = FileAttachment("census-data.json").json()
Insert cell
outputClassificationsDetails = FileAttachment(
"output-classification-details-dict.json"
).json()
Insert cell
import { Legend, Swatches } from "@d3/color-legend"
Insert cell
import { wrap } from "@jtrim-ons/svg-text-wrapping"
Insert cell
labelplacer = import("labelplacer@0.0.0")
Insert cell
leaderlines = import("leaderlines@0.0.1")
Insert cell
rectOpacity = 0.5
Insert cell
htl.html`
<style>
.legend-swatch {
width: 15px;
height: 15px;
margin-right: 0.5em;
flex-shrink: 0;
opacity: ${rectOpacity};
}
.legend-item {
font: 12px sans-serif;
display: flex;
align-items: center;
}
.legend {
display: grid;
grid-template-columns: repeat(5, 1fr);
grid-column-gap: 5px;
grid-row-gap: 5px;
}
</style>
`
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