Repository navigation
Charts: Download CSV on every chart card - #86
Merged
Merged
Conversation
Each chart component registers a table builder with its ChartCard through Svelte context (charts/csv.ts); the card shows a Download CSV button after hydration and builds the file on click. Explicit ChartCard tables take precedence. Closes #31 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #31.
What
src/lib/components/charts/csv.tsprovidescollectCsv()(called by ChartCard) andregisterCsv()(called by each chart component). Both work through Svelte context, so all ~134 chart cards get the button without touching any call site.Every chart type exports a sensible table:
ci_low/ci_highwhen the chart has error barsx_labelwhen the chart formats x), ybin_start,bin_end, one count column per seriesIf a card passes an explicit
table, that table becomes the CSV instead.The button appears after hydration (it needs JS) and builds the file client-side from data already on the page. There's no server endpoint, so no extra queries and no new CSP rules. File names look like
physioshark-<chart-title>.csv.Checks
pnpm lint,pnpm checkpass.pnpm testpasses (41 tests, including the newcsv.test.tsfor quoting, blanks, rounding and multiple tables).pnpm buildandpnpm test:e2epass (29, axe light/dark).🤖 Generated with Claude Code