Skip to content

Render the trend chart instead of the placeholder - #32

Open
marvinm2 wants to merge 2 commits into
RECETOX:mainfrom
marvinm2:chart-trend
Open

Render the trend chart instead of the placeholder#32
marvinm2 wants to merge 2 commits into
RECETOX:mainfrom
marvinm2:chart-trend

Conversation

@marvinm2

Copy link
Copy Markdown

Closes #27.

The trend chart section now draws a chart instead of the placeholder. One Vega-Lite spec per data source is built in dashboard.py from the same long-form records the table already uses, and the template renders whichever source is selected. Clicking a summary card switches the chart, reusing the currentFilter hook that was already in the script but unused.

Some choices worth explaining.

Stacked bars rather than lines. load_tsv drops rows with a count of zero, so a period with no data is absent rather than zero, and a line mark would draw straight through the gap and show numbers that were never reported. Bars leave the gap visible.

Series are capped at the six busiest packages, with the rest grouped as Other. galaxy_runs.tsv has 17 packages and github_views.tsv 14, and no categorical colour scale stays readable at that width. The cap hides very little: over the committed 2026 reports the top six carry 99% of PyPI downloads, 93% of GitHub views, 98% of Galaxy runs and 93% of Bioconda downloads. The table below still lists every package.

Periods stay ordinal with an explicit chronological sort, which is what the earlier implementation did. The reports mix 2026-02 with 2026-W01 and Vega-Lite cannot parse the ISO week form as a date. The sort key returns a last-place key for an unrecognised label rather than raising, so one odd row cannot reorder a series.

Colours moved into CSS custom properties at the top of the template, so the palette can be changed in one place. The series colours are Okabe-Ito with yellow and black dropped and orange and sky darkened, so every bar fill clears 3:1 against the white card.

The banner now carries the MUNI RECETOX wordmark and is light rather than the Bootstrap blue gradient. The wordmark is blue on an opaque white ground, and on a dark banner it measures 1.4:1 and cannot be read. The image is committed rather than linked from the brand portal so the page does not depend on a preview URL. It is the 1000x preview export; if there is an official SVG that would be better, and I am happy to drop the logo entirely if you would rather it was not there.

Vega, Vega-Lite and Vega-Embed load from jsDelivr with pinned versions and SRI hashes, matching how Bootstrap is already loaded. Each hash is reproducible with curl -sL <url> | openssl dgst -sha384 -binary | openssl base64 -A.

docs/index.html is regenerated and included, so the chart appears on the live site when this merges. Without it the chart would not show up until #25 is sorted out, because the weekly commit cannot trigger a deploy. The file grows from 170KB to 212KB, and nearly all of that is one long line of inline chart data.

Two things to flag. The Galaxy Runs card in this branch still reads 123,958, which is the double counting in #26 rather than anything the chart does; #31 fixes it and the two branches merge cleanly. And the GitHub Views chart stops at 2026-W14, which is #28.

Two small changes I made while in the files, happy to pull either out. The unused import json is removed, which ruff was already flagging on main. And the summary cards get role="button", tabindex="0" and a keydown handler, since they were click-only and unreachable from a keyboard.

Tested with python -m unittest discover -s tests from the repo root: 28 tests in test_dashboard.py, 15 of them new, all passing, and ruff check src tests clean. I also loaded the generated page and checked each source renders, that the ISO-week axis orders correctly across the 2025/2026 boundary, that Show All shows a message rather than an empty axis, and that the chart still draws at a 340px container width.

One observation I did not act on: altair==6.0.0 is pinned but never imported. It is worth keeping anyway, because it is what pulls in jinja2, which the template rendering needs and which is not declared directly.

Builds one Vega-Lite spec per data source from the same long-form records the
table is rendered from, and draws it into the existing #trend-chart element.
Clicking a summary card switches the chart, reusing the currentFilter hook that
was already there but unused.

Stacked bars rather than lines: load_tsv drops zero rows, so a period with no
data is absent rather than zero, and a line would interpolate through the gap
and show numbers that were never reported. Series are capped at the six busiest
packages with the rest grouped as Other, which covers 93-99% of the total in
every current report; galaxy_runs carries 17 packages and no categorical scale
stays readable at that width.

Periods stay ordinal with an explicit chronological sort. The reports mix
2026-02 with 2026-W01 and Vega-Lite cannot parse the ISO week form as a date.
The sort key tolerates an unrecognised label rather than raising.

Colours move into CSS custom properties, so the palette can be changed in one
place. The series colours are Okabe-Ito with yellow and black dropped and
orange and sky darkened, so every bar fill clears 3:1 against the card.

Also removes an unused json import, which ruff was already flagging, and makes
the summary cards reachable from the keyboard.
The wordmark is blue on an opaque white ground, with no transparency, so it
needs a light banner: on the previous dark one it measures 1.4:1 against the
background and cannot be read.

The image is committed rather than linked from the brand portal, so the page
does not depend on a preview URL that may be rotated. It is the 1000x preview
export; if there is an official SVG in the brand portal that would be better.
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.

Trend chart on the dashboard is still a placeholder

1 participant