Skip to content

fix(viz): choropleth --geojson implies geojson-id; trim locations, float ids, bad census vintage - #4877

Merged
jqnatividad merged 2 commits into
masterfrom
fix/viz-choropleth-location-handling
Oct 22, 2026
Merged

jqnatividad merged 2 commits into
masterfrom
fix/viz-choropleth-location-handling

Conversation

@jqnatividad

Copy link
Copy Markdown
Collaborator

Summary

viz choropleth --locations X --geojson <file|auto|census:*> without --location-mode drew a blank map while exiting 0. --location-mode carried a docopt [default: iso3], so the trace emitted "locationmode":"ISO-3" beside the geojson, and plotly only reads geojson in geojson-id mode. This hit the help text's own --geojson auto example and has been there since the choropleth landed (#4086). The existing tests all passed --location-mode geojson-id explicitly, so the suite never covered the default. --map and the viz smart dashboards (choroplethmap) were unaffected.

Found in a whole-file review of viz.rs, along with three smaller location bugs on the same path:

  • Location-mode default is now resolved in code: an explicit --location-mode wins; otherwise --geojson (without --geocode) → geojson-id; otherwise iso3. --geocode keeps iso3 because it yields ISO-3/US-state codes.
  • Trim location cells in the built-in iso3/usa-states modes (no RegionMatcher there): PA no longer splits from PA, and --denominator census finds padded codes.
  • Integral float feature ids ("FIPS": 6037.0, common in geopandas exports) are stringified as plotly does (6037), not as serde_json does (6037.0, which matched no region).
  • --denominator census@<bad-year> is a clear usage error up front, instead of being resolved as a column (on choropleth, only after fetching boundaries).

Verification

  • Headless Chrome: the no-mode --geojson repro drew 0 regions before and draws 2 now.
  • 5 regression tests in tests/test_viz.rs. Each was mutation-checked (revert the fix → its test fails; 5/5 killed).
  • test_viz* suite: 678 passed. Clippy: no new warnings. double-run-check.py --check OK.
  • Regenerated docs/help/viz.md and the qsv-viz skill JSON. Entries in CHANGELOG and the skills CHANGELOG.

🤖 Generated with Claude Code

jqnatividad and others added 2 commits October 21, 2026 23:27
…oat ids, bad census vintage

`--location-mode` carried a docopt `[default: iso3]`, so `viz choropleth --locations X
--geojson ...` without an explicit mode emitted `"locationmode":"ISO-3"` beside the geojson.
plotly then ignores the geojson and shades nothing, while qsv exits 0 -- including the help
text's own `--geojson auto` example. The default is now resolved in code: an explicit
`--location-mode` wins, a `--geojson` (without `--geocode`) implies geojson-id, else iso3.

Related location fixes on the same path:
- trim location cells in the built-in iso3/usa-states modes (`PA ` no longer splits from
  `PA`, and `--denominator census` finds padded codes)
- stringify integral float feature ids as plotly does (`6037.0` -> `6037`)
- reject a mistyped `--denominator census@<year>` up front instead of resolving it as a
  column after fetching boundaries

Regenerated docs/help/viz.md and the qsv-viz skill JSON.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@jqnatividad
jqnatividad merged commit 2e0ac90 into master Oct 22, 2026
31 checks passed
@jqnatividad
jqnatividad deleted the fix/viz-choropleth-location-handling branch October 22, 2026 10:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant