Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

US dams example dashboard #1350

Merged
merged 55 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
a99aba6
us-dams example
May 15, 2024
ce4c89f
update table, chart heights, some org
May 15, 2024
6d3649c
update condition order in histogram
May 15, 2024
60e3217
remove unrelated examples/hotel-bookings/dist
Fil May 15, 2024
8e5f23a
clean up overview a bit
May 15, 2024
83db21f
Merge branch 'allison/dams-example' of https://github.com/observableh…
May 15, 2024
60fb29a
fix path for dams example
allisonhorst May 16, 2024
60db5ed
fix path in us-states loader
allisonhorst May 16, 2024
2d558e6
Reorder condition: Satisfactory better than Fair (per data dictionary…
pettiross May 16, 2024
ad06359
deck.gl dams map tinkering
allisonhorst May 16, 2024
73bd374
deck.gl hexagon layer updates
allisonhorst May 16, 2024
89e3a9e
start adding charts to index
allisonhorst May 17, 2024
7396d38
Color and format tweaks on Plots
pettiross May 17, 2024
8753466
map updates, add overview charts, incorporate Jeff's changes
May 17, 2024
46bb7e8
Update nationwide overview charts, incorporate Jeff changes
May 17, 2024
63541c3
add search to table, finish homepage layout
May 17, 2024
fc33e91
switch homepage map to scatter with fill by condition
May 17, 2024
06ba8e8
update legend in nationwide map
May 17, 2024
2e6d68a
edits
May 17, 2024
8d08d63
update overview page and by-state dashboard
May 20, 2024
902ac5a
fix text color and add tooltips in purpose chart
May 20, 2024
3ad46e7
overview back to 3d hexbin map
May 21, 2024
12ad749
clean up code, delete unused, add comments, update ReadMe
May 21, 2024
9d4353a
Merge branch 'main' into allison/dams-example
May 21, 2024
8942ce0
Update ReadMe based on other examples, incorporate Fil feedback
May 21, 2024
b2e3a31
fix map re-run code to avoid overlap on selection
May 21, 2024
e079cea
Merge branch 'main' into allison/dams-example
May 22, 2024
aa86900
gets polygons from us-atlas, calculates centroids
May 22, 2024
11475a8
Update examples/us-dams/package.json
allisonhorst May 22, 2024
35cc8d1
Update examples/us-dams/package.json
allisonhorst May 22, 2024
9153ab6
Update examples/us-dams/README.md
allisonhorst May 22, 2024
6b6d566
moves dam data to data loader, updates data descriptions in ReadMe
May 22, 2024
d1420bb
Merge branch 'allison/dams-example' of https://github.com/observableh…
May 22, 2024
7cd39eb
update config file to match other examples
May 22, 2024
1da2c24
remove leftover display
May 22, 2024
4240927
adds sidebar back
May 22, 2024
6bd68a9
title change
May 22, 2024
ce706d4
fix conditionHeatmap height
Fil May 28, 2024
b194aa2
Merge branch 'main' into allison/dams-example
allisonhorst Jun 4, 2024
81e16f1
Add description to examples ReadMe, add webp images
allisonhorst Jun 4, 2024
5b37367
Merge branch 'allison/dams-example' of https://github.com/observableh…
allisonhorst Jun 4, 2024
2c32427
Apply suggestions from code review
allisonhorst Jun 5, 2024
846b179
match bubble chart orders to nationwide page
allisonhorst Jun 5, 2024
8fa54ea
code formatting, updates purpose barchart labels
allisonhorst Jun 5, 2024
ca32b88
update config keeping sidebar
allisonhorst Jun 5, 2024
d15077f
fine tune conditional text
allisonhorst Jun 5, 2024
03f06e7
Merge branch 'main' into allison/dams-example
allisonhorst Jun 14, 2024
9dabdc9
clean up unused columns in loader
allisonhorst Jun 14, 2024
e013faf
Merge branch 'main' into allison/dams-example
Fil Jun 18, 2024
074b81a
small edits
Fil Jun 18, 2024
4632622
condition
Fil Jun 18, 2024
0662a38
Merge branch 'main' into allison/dams-example
allisonhorst Jun 18, 2024
c0e5e22
Merge branch 'main' into allison/dams-example
allisonhorst Jun 18, 2024
bb0ce9a
update example readme, data directly from NID API
allisonhorst Jun 18, 2024
9520d50
resize webp thumbnails
allisonhorst Jun 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/assets/us-dams-dark.webp
Binary file not shown.
Binary file added docs/assets/us-dams.webp
Binary file not shown.
6 changes: 6 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@

[Source](./mortgage-rates) · This dashboard visualizes Freddie Mac’s historical mortgage rates data. The included data loader demonstrates how to retrieve CSV data from Freddie Mac and visualize the result as a zoomable chart with Observable Plot. The larger time-series line chart at the bottom allows brushing to select an arbitrary time range, while the smaller visualization above zooms to show the selected range.

### [`us-dams`](https://observablehq.observablehq.cloud/framework-example-us-dams/) - U.S. dam conditions

<a href="https://observablehq.observablehq.cloud/framework-example-us-dams/"><img src="../docs/assets/us-dams.webp" alt="U.S. dams" width="312" height="237"></a>

[Source](./us-dams) · This dashboard visualizes locations and conditions for 90k+ dams in the U.S. with data from the National Inventory of Dams (NID). An R data loader accesses the data directly from the NID and generates a simplified CSV. Maps created with deck.gl allow a user to zoom and scroll while exploring dam locations nationwide, or by state. Bar and bubble charts made in Observable Plot highlight dam conditions and hazard potential.

## Technique examples 🛠️

### Charts
Expand Down
8 changes: 8 additions & 0 deletions examples/us-dams/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
dist/
src/.observablehq/cache/
node_modules/
yarn-error.log
src/.observablehq/deploy.json
.Rhistory
.Rdata
39 changes: 39 additions & 0 deletions examples/us-dams/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[Framework examples →](../)

# U.S. dams

View live: <https://observablehq.observablehq.cloud/framework-example-us-dams/>

This Observable Framework example explores data for 90,000+ dams in the United States from the [National Inventory of Dams](https://nid.sec.usace.army.mil/) (NID).

The pages feature nationwide and state-by-state summaries of dam locations, highlighting dam conditions and hazard assessment.

Interactive maps are created with [deck.gl](https://deck.gl/)). To create your own maps with deck.gl in Observable Framework, see our [documentation](https://observablehq.com/framework/lib/deckgl). All other charts built with [Observable Plot](https://observablehq.com/plot/), and searchable tables are created with Observable Inputs by combining [Inputs.search and Inputs.table](https://observablehq.com/framework/inputs/search).

## Implementation

```
.
├── README.md
├── observablehq.config.js
├── package.json
└── src
├── data
│   ├── county_fips_master.csv
│   ├── dam-simple.csv.R
│   └── us-state-capitals.csv
├── by-state.md
└── index.md
```

The R data loader `dam-simple.csv.R` accesses data directly from the NID (at https://nid.sec.usace.army.mil/api/nation/csv) and generates the `dam-simple.csv` file used in both pages. To run the data loader, you need to have [R](https://www.r-project.org/) installed, along with the [data.table](https://github.com/Rdatatable/data.table), [dplyr](https://github.com/tidyverse/dplyr), and [readr](https://github.com/tidyverse/readr) packages (e.g. with `install.packages("dplyr")`).

### Data

- Dam records are downloaded from the NID as a CSV, then minimally wrangled, by the `dam-simple.csv.R` data loader to produce the static file with dam records used in our dashboard (`dam-simple.csv`)

- County FIPS codes (`src/data/county_fips_master.csv`)are from: https://github.com/kjhealy/fips-codes/blob/master/county_fips_master.csv

- US state capitals and locations (`src/data/us-state-capitals.csv`) are from: https://github.com/jasperdebie/VisInfo/blob/master/us-state-capitals.csv

- County, state, and nation-level spatial polygons are accessed from the [us-atlas](https://www.npmjs.com/package/us-atlas?activeTab=readme) repository
61 changes: 61 additions & 0 deletions examples/us-dams/observablehq.config.js
allisonhorst marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
export default {
root: "src",

// Shared Observable example configuration; feel free to remove this.
title: "U.S. dams overview",
pager: false,
toc: false,
sidebar: true,
head:
process.env.CI &&
`<script type="module" async src="https://events.observablehq.com/client.js?pageLoad"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=G-9B88TP6PKQ"></script>
<script>window.dataLayer=window.dataLayer||[];\nfunction gtag(){dataLayer.push(arguments);}\ngtag('js',new Date());\ngtag('config','G-9B88TP6PKQ');</script>`,
header: `<style>

#observablehq-header a[href] {
color: inherit;
}

#observablehq-header a[target="_blank"] {
display: flex;
align-items: center;
gap: 0.25rem;
text-decoration: none;
}

#observablehq-header a[target="_blank"]:hover span {
text-decoration: underline;
}

#observablehq-header a[target="_blank"]::after {
content: "\\2197";
}

#observablehq-header a[target="_blank"]:not(:hover, :focus)::after {
color: var(--theme-foreground-muted);
}

@container not (min-width: 640px) {
.hide-if-small {
display: none;
}
}

</style>
<div style="display: flex; align-items: center; gap: 0.5rem; height: 2.2rem; margin: -1.5rem -2rem 2rem -2rem; padding: 0.5rem 2rem; border-bottom: solid 1px var(--theme-foreground-faintest); font: 500 16px var(--sans-serif);">
<a href="https://observablehq.com/" target="_self" rel="" style="display: flex; align-items: center;">
<svg width="22" height="22" viewBox="0 0 21.92930030822754 22.68549919128418" fill="currentColor">
<path d="M10.9646 18.9046C9.95224 18.9046 9.07507 18.6853 8.33313 18.2467C7.59386 17.8098 7.0028 17.1909 6.62722 16.4604C6.22789 15.7003 5.93558 14.8965 5.75735 14.0684C5.56825 13.1704 5.47613 12.2574 5.48232 11.3427C5.48232 10.6185 5.52984 9.92616 5.62578 9.26408C5.7208 8.60284 5.89715 7.93067 6.15391 7.24843C6.41066 6.56618 6.74143 5.97468 7.14438 5.47308C7.56389 4.9592 8.1063 4.54092 8.72969 4.25059C9.38391 3.93719 10.1277 3.78091 10.9646 3.78091C11.977 3.78091 12.8542 4.00021 13.5962 4.43879C14.3354 4.87564 14.9265 5.49454 15.3021 6.22506C15.6986 6.97704 15.9883 7.7744 16.1719 8.61712C16.3547 9.459 16.447 10.3681 16.447 11.3427C16.447 12.067 16.3995 12.7593 16.3035 13.4214C16.2013 14.1088 16.0206 14.7844 15.7644 15.437C15.4994 16.1193 15.1705 16.7108 14.7739 17.2124C14.3774 17.714 13.8529 18.1215 13.1996 18.4349C12.5463 18.7483 11.8016 18.9046 10.9646 18.9046ZM12.8999 13.3447C13.4242 12.8211 13.7159 12.0966 13.7058 11.3427C13.7058 10.5639 13.4436 9.89654 12.92 9.34074C12.3955 8.78495 11.7441 8.50705 10.9646 8.50705C10.1852 8.50705 9.53376 8.78495 9.00928 9.34074C8.49569 9.87018 8.21207 10.5928 8.22348 11.3427C8.22348 12.1216 8.48572 12.7889 9.00928 13.3447C9.53376 13.9005 10.1852 14.1784 10.9646 14.1784C11.7441 14.1784 12.3891 13.9005 12.8999 13.3447ZM10.9646 22.6855C17.0199 22.6855 21.9293 17.6068 21.9293 11.3427C21.9293 5.07871 17.0199 0 10.9646 0C4.90942 0 0 5.07871 0 11.3427C0 17.6068 4.90942 22.6855 10.9646 22.6855Z"></path>
</svg>
</a>
<div style="display: flex; flex-grow: 1; justify-content: space-between; align-items: baseline;">
<a href="https://observablehq.com/framework/" target="_self" rel="">
<span class="hide-if-small">Observable</span> Framework
</a>
<span style="display: flex; align-items: baseline; gap: 0.5rem; font-size: 14px;">
<a target="_blank" href="https://github.com/observablehq/framework/tree/main/examples/us-dams"><span>View source</span></a>
</span>
</div>
</div>`
};
allisonhorst marked this conversation as resolved.
Show resolved Hide resolved
24 changes: 24 additions & 0 deletions examples/us-dams/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"type": "module",
"private": true,
"scripts": {
"clean": "rimraf src/.observablehq/cache",
"build": "rimraf dist && observable build",
"dev": "observable preview",
"deploy": "observable deploy",
"observable": "observable"
},
"dependencies": {
"@observablehq/framework": "^1.7.1",
"d3-dsv": "^3.0.1",
"d3-time-format": "^4.1.0",
"topojson-client": "^3.1.0",
"topojson-simplify": "^3.0.3"
},
"devDependencies": {
"rimraf": "^5.0.5"
},
"engines": {
"node": ">=18"
}
}
Loading