Spaces:
Sleeping
Sleeping
Create ingest/coverage.py
Browse files- ingest/coverage.py +29 -9
ingest/coverage.py
CHANGED
|
@@ -1,9 +1,29 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import plotly.graph_objects as go
|
| 2 |
+
|
| 3 |
+
AGENCY_STATE_MAP = {
|
| 4 |
+
"CIA FOIA Reading Room": "VA",
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
def build_coverage_heatmap(counts):
|
| 8 |
+
return counts
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def build_agency_map(counts):
|
| 12 |
+
states = []
|
| 13 |
+
values = []
|
| 14 |
+
|
| 15 |
+
for agency, count in counts.items():
|
| 16 |
+
if agency in AGENCY_STATE_MAP:
|
| 17 |
+
states.append(AGENCY_STATE_MAP[agency])
|
| 18 |
+
values.append(count)
|
| 19 |
+
|
| 20 |
+
fig = go.Figure(
|
| 21 |
+
go.Choropleth(
|
| 22 |
+
locations=states,
|
| 23 |
+
locationmode="USA-states",
|
| 24 |
+
z=values,
|
| 25 |
+
colorscale="Blues",
|
| 26 |
+
)
|
| 27 |
+
)
|
| 28 |
+
fig.update_layout(title="Agency FOIA Coverage (US)")
|
| 29 |
+
return fig
|