Skip to content

Commit 789151c

Browse files
committed
wip: puma map new york cbsa
1 parent c6a3134 commit 789151c

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed
Binary file not shown.

docs/new-york-area.md

+17-6
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ const stateCodeToName = {
3333

3434
// Fetch PUMA details, including state names based on the hardcoded map
3535
const pumaDetails = await db.query(`
36-
SELECT DISTINCT puma, puma_name, state_code FROM data WHERE year = ${selectedYear}
36+
SELECT DISTINCT puma, FIRST(puma_name) AS puma_name, state_code
37+
FROM data
38+
GROUP BY puma, state_code
3739
`).then(data => data.map(d => ({
3840
puma: d.puma,
3941
stateCode: d.state_code,
@@ -42,14 +44,12 @@ const pumaDetails = await db.query(`
4244

4345
console.log("PUMA Details:", pumaDetails);
4446

45-
// Sort pumaDetails alphabetically by state name and then by PUMA code
47+
// Sort pumaDetails alphabetically by state name and then by PUMA name
4648
pumaDetails.sort((a, b) => {
4749
const stateCompare = stateCodeToName[a.stateCode].localeCompare(stateCodeToName[b.stateCode]);
4850
if (stateCompare !== 0) return stateCompare;
49-
return a.puma.localeCompare(b.puma);
51+
return a.label.localeCompare(b.label);
5052
});
51-
52-
console.log("Sorted PUMA Details:", pumaDetails);
5353
```
5454

5555
```js
@@ -84,13 +84,23 @@ const income = await db.query(`
8484
`);
8585
```
8686

87+
<!-- ```js
88+
const medianIncome = await db.query(`
89+
SELECT
90+
quantile_cont(0.5) WITHIN GROUP (ORDER BY income) AS median_income
91+
FROM data
92+
WHERE year = ${selectedYear} AND puma = '${selectedPUMA}' AND state_code = '${selectedStateCode}';
93+
`);
94+
``` -->
95+
8796
```js
8897
function incomeChart(income, width) {
8998
// Create a histogram with a logarithmic base.
9099
return Plot.plot({
91100
width,
92101
marginLeft: 60,
93-
x: { type: "log" },
102+
x: { type: "log", domain: [5000, 500000], // Set the domain of the x-axis to be fixed between 1000 and 500,000
103+
},
94104
y: { axis: null }, // Hide the y-axis
95105
color: { legend: "swatches", columns: 6, domain: orderSectors },
96106
marks: [
@@ -110,6 +120,7 @@ function incomeChart(income, width) {
110120
}
111121
)
112122
),
123+
// Plot.ruleX([medianIncome], {stroke: "red", strokeWidth: 2})
113124
],
114125
});
115126
}

0 commit comments

Comments
 (0)