Skip to content

Refactor chart export to use SVG to canvas PNG pipeline#667

Open
bencap wants to merge 1 commit intorelease-2026.2.1from
bugfix/bencap/chart-export-omnibus
Open

Refactor chart export to use SVG to canvas PNG pipeline#667
bencap wants to merge 1 commit intorelease-2026.2.1from
bugfix/bencap/chart-export-omnibus

Conversation

@bencap
Copy link
Copy Markdown
Collaborator

@bencap bencap commented May 1, 2026

This pull request refactors and improves the chart export functionality for histograms and heatmaps in the score set view. It replaces the old single-action export buttons with split buttons for SVG and PNG export, adds user feedback (spinners) during export operations, and centralizes export logic with a new composable. It also removes unused dependencies from package.json.

This pipeline improvement to chart export fixes bugs related to chart coloring on exported images, SVG validity in common editing programs, and browser to browser nuances in ability to export while adding back PNG export as an option.

Chart Export Refactor and UI Improvements:

  • Replaces single export buttons with split buttons (SplitButton) that allow users to export charts as either SVG or PNG, and displays a spinner during export operations for better user feedback. (src/components/screens/ScoreSetView.vue [1] [2] [3]
  • Refactors export logic in ScoreSetHistogram.vue and ScoreSetHeatmap.vue to provide both SVG and PNG export functions via a new buildExportFns method, replacing the old single exportChart method. (src/components/score-set/ScoreSetHistogram.vue [1] [2] [3]; src/components/score-set/ScoreSetHeatmap.vue [4] [5] [6]
  • Removes histogram and heatmap export buttons from the downloads section, consolidating export actions in the main chart headers. (src/components/score-set/ScoreSetDownloads.vue [1] [2] [3]; src/components/screens/ScoreSetView.vue [4] [5] [6]

Centralized Export Logic:

  • Introduces a new composable, useChartExport, which manages in-progress state and export methods, ensuring UI updates (like spinners) are visible before heavy export work starts. (src/composables/use-chart-export.ts src/composables/use-chart-export.tsR1-R81)
  • Updates component state and props to use the new composable and export function objects. (src/components/screens/ScoreSetView.vue [1] [2] [3]

Dependency Cleanup:

  • Removes unused dependencies dom-to-image and native-file-system-adapter from package.json. [1] [2]

- Remove dom-to-image dependency; rewrite saveChartAsPng using a
  native SVG serialization → <img> → canvas → blob pipeline
- Parse canvas dimensions from SVG width/height attrs and viewBox
  to fix incorrect sizing on clipped scroll-container heatmaps
- Add scale guard (MAX_CANVAS_DIMENSION / MAX_CANVAS_AREA) to
  prevent allocation overflow on large charts
- Add useChartExport composable with reactive svgInProgress /
  pngInProgress state and yieldToRenderer() to guarantee a painted
  frame before blocking export work runs
- Replace single Export PButtons in ScoreSetView with SplitButtons
  (SVG primary action, PNG dropdown) wired to the new composable;
  show spinner while export is in progress
- Move chart export buttons out of ScoreSetDownloads; panel now
  only handles file downloads; remove histogramExportFn,
  heatmapExportFn, heatmapExists props
- Resolve CSS custom properties in histogram shader gradients via
  getComputedStyle so SVG <stop> colors render correctly on export
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.

Histogram export loses coloring for score thresholds SVG histograms won't open in common programs PNG Export Unavailable in Certain Browsers

1 participant