Skip to content

viz: link the localized gallery examples, and fix the two dashboard bugs they exposed - #4317

Merged
jqnatividad merged 3 commits into
masterfrom
docs/viz-gallery-localized-examples
Aug 1, 2026
Merged

viz: link the localized gallery examples, and fix the two dashboard bugs they exposed#4317
jqnatividad merged 3 commits into
masterfrom
docs/viz-gallery-localized-examples

Conversation

@jqnatividad

@jqnatividad jqnatividad commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Both localized smart dashboards were already deployed to GitHub Pages — the viz-gallery-pages workflow stages examples/viz wholesale — but gallery.html never linked them, so they were reachable only by direct URL. The commits that added them (5a2ba093e, d498b8873) didn't touch gen_gallery.py, so the generator had no entry to render.

Fixing that surfaced two dashboard bugs, which are the second commit.

1. Gallery entries (b2d74cda0)

Added as SCREENSHOTS link-outs rather than embedded iframes: at 17.0 MB and 5.0 MB they're far past the 0.1–1.5 MB range of the embedded figures, so embedding would have added ~22 MB to every gallery page load. Matches the existing Pittsburgh/Boston treatment. Neither dataset is committed, so both carry a verbatim cmd.

README.md was stale on two counts gen_gallery.py's own consistency check flags — the link-out count (three → five) and the page size range (3.6–6.9 MB → 3.9–20.6 MB) — plus the dictionary table was presented as a complete list while omitting both new dictionaries.

2. Notable Characteristics rendered in English (637001ba5)

Inside otherwise fully Spanish/Portuguese dictionary drawers.

The obvious fix would have broken OKF export. okf_short_description (describegpt.rs:5513) finds that exact English literal to cut the lead prose it needs for OKF's frontmatter description: key. The string is load-bearing and has to survive in the stored schema — prompting the model to translate it would silently break OKF short-description extraction on every non-English run.

So it's localized at render time, after all marker parsing: localize_dict_heading swaps the one structural literal for a curated catalog string at the single ATX heading render site. Verified on the Colombia dashboard — 0 occurrences of the English heading in its HTML, 1 still in its schema. Uncurated locales and reworded headings fall through to English, i.e. to today's behavior.

3. KPI tile labels collided with their neighbours

wrap_kpi_label wraps against a character budget fixed at generation time, but the KPI row spans ~550px to ~1800px on the same page — narrow windows, and the --dict-info drawer opening, which shrinks the plot with no window resize event. No character count is right at both ends.

KPI_REWRAP_SCRIPT re-wraps against the tile's measured pixel width on every resize, via a ResizeObserver on the plot div (a window listener would miss the drawer case). It finds its labels by a name marker rather than annotation index, since the two emission sites produce different index layouts, and derives tile width from the pitch between adjacent label centers so nothing extra is serialized. The Rust wrap stays as the pre-JS baseline, ceiling lowered 36 → 28 (measured: ~6.7 px/char, tiles ~183px at the narrow case).

Verified in-browser, not just compiled

condition plot tile result
1070px, drawer open 549px 183px no overlap; widest label 171px ≤ 183px
2360px, drawer open 1808px ~600px labels re-join into single lines

The wide case is what proves the JS is doing the work — the static wrap alone would leave them wrapped forever.

Regenerated artifacts

The Colombia dashboard, its preview image, and the embedded gallery figures, so the fixes are live in the published examples. Per page the diff is the script block, a Compiled: timestamp, and name attributes only where a KPI row exists — confirmed byte-exact on three pages. Colombia's extra 26 characters are two new <br>s from the tightened baseline wrap.

Not included

Six committed artifacts still render the English Notable Characteristics, because gen_gallery.py cannot refresh them without their uncommitted source data: pitt311data, smart_boston_311_2025, smart_dict_sunburst, smart_dict_treemap, smart_geospatial, smart_world_choropleth. Two of those (pitt311data, smart_boston_311_2025) are link-out dashboards reachable from the gallery, so this is a user-visible residual gap, not just an internal one. Refreshing them needs the datasets and each entry's cmd.

Testing

295 unit + 395 integration viz tests pass; cargo clippy --bin qsv -F all_features clean.

One test needed a fix worth noting: render_dict_markdown_atx_headings began failing by returning Italian — localizing that render path made the assertion locale-sensitive, and it wasn't holding the english_locale() mutex against concurrently-running tests. Added the guard plus two new tests covering the localization (including that non-marker headings pass through untouched) and the marker/script agreement.

🤖 Generated with Claude Code

jqnatividad and others added 2 commits August 1, 2026 18:03
…allery

Both smart dashboards were already deployed to GitHub Pages by the
viz-gallery-pages workflow -- it stages examples/viz wholesale -- but
gallery.html never linked them. The commits that added them (5a2ba09,
d498b88) did not touch gen_gallery.py, so the generator had no entry
to render and the pages were only reachable by direct URL.

Add them as SCREENSHOTS link-outs rather than embedded iframes: at
17.0 MB and 5.0 MB they are far past the 0.1-1.5 MB range of the
embedded smart_*.html figures, so embedding would have added ~22 MB to
every gallery page load. This matches the existing Pittsburgh/Boston
treatment. Neither dataset is committed, so both entries carry a
verbatim `cmd` and are reused as-is rather than regenerated per run.

Preview images are captured at 2140x2482 to match the existing three.

README.md was stale on two counts that gen_gallery.py's own consistency
check flags: the link-out count (three -> five) and the page size range
(3.6-6.9 MB -> 3.9-20.6 MB).

The regenerated smart_*.html pages carry a new Compiled: timestamp, and
smart_nyc311.html a re-encoded stats sidecar and popup id.
smart_allegheny_dogs.html additionally picks up the GeoJSON ring-winding
normalization from 8c854c9, which fixed viz.rs but refreshed only the
Colombia dashboard.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…bels responsively

Two dashboard fixes surfaced while adding the localized gallery examples.

1. `Notable Characteristics` rendered in English inside otherwise fully
   Spanish/Portuguese dictionary drawers.

   The obvious fix -- have describegpt emit the heading in the target
   language -- would have broken OKF export: `okf_short_description`
   (describegpt.rs) finds that exact English literal to cut the lead prose
   it needs for OKF's frontmatter `description:` key. The literal is
   load-bearing and must survive in the stored schema.

   So localize at RENDER time instead, after all marker parsing:
   `localize_dict_heading` swaps the one structural literal for a curated
   catalog string at the single ATX heading render site. The schema and
   describegpt's parser are untouched -- verified on the Colombia dashboard,
   which now has 0 occurrences of the English heading in its HTML and 1 in
   its schema. Uncurated locales and reworded headings fall through to
   English, i.e. to today's behavior.

2. KPI tile labels collided with their neighbours.

   `wrap_kpi_label` wraps against a CHARACTER budget fixed at generation
   time, but the KPI row spans ~550px to ~1800px on the same page -- narrow
   windows, and the --dict-info drawer opening, which shrinks the plot with
   no window resize event. No character count is right at both ends.

   `KPI_REWRAP_SCRIPT` re-wraps against the tile's measured pixel width and
   re-applies on every resize, via a ResizeObserver on the plot div (a
   window listener would miss the drawer case). It finds its labels by a
   `name` marker rather than annotation index, since the two emission sites
   produce different index layouts. Tile width comes from the pitch between
   adjacent label centers, so nothing extra is serialized.

   The Rust wrap stays as the pre-JS baseline, with its ceiling lowered
   36 -> 28 (measured: labels run ~6.7px/char, tiles ~183px at the narrow
   case).

Verified in-browser on the regenerated Colombia dashboard: at 1070px with
the drawer open (plot 549px, tiles 183px) no label overlaps and none is
wider than its tile; widened to 2360px they re-join into single lines,
which the static wrap alone would never do.

Regenerates the Colombia dashboard, its preview image, and the embedded
gallery figures so the fixes are live in the published examples. Per-page
the diff is the script block, a Compiled: timestamp, and `name` attributes
only where a KPI row exists -- confirmed byte-exact on three pages.

Also adds the two new dictionaries to the README table, which was
presented as a complete list (roborev).

Co-Authored-By: Claude Opus 4.7 (1M context) <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.

…ed heading

The Brazil link-out was left on the pre-fix binary in 637001b on the
grounds that it has no KPI row, so it would gain only the inert re-wrap
script. That reasoning covered the KPI fix but missed the other one: its
dictionary drawer still rendered the English `Notable Characteristics`
inside an otherwise fully Portuguese dashboard.

Regenerated with the same command the entry documents. The drawer now
reads `Características notáveis`, while the schema keeps the English
literal that describegpt's `okf_short_description` cuts on -- 0 English
headings in the HTML, 1 in the schema, matching Colombia.

Confirms the KPI reasoning too: the page carries exactly one occurrence of
the marker string (the script's own constant) and no `name` attributes,
i.e. no KPI tiles to tag, and its plotly data line is unchanged.

Preview image re-captured since the heading is visible in it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jqnatividad
jqnatividad merged commit 1d80902 into master Aug 1, 2026
15 of 16 checks passed
@jqnatividad
jqnatividad deleted the docs/viz-gallery-localized-examples branch August 1, 2026 09:51
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