Skip to content

fix: combine repeated chart exports into single image#492

Open
ObservedObserver wants to merge 1 commit intomainfrom
codex/fix-image-export-for-multiple-charts
Open

fix: combine repeated chart exports into single image#492
ObservedObserver wants to merge 1 commit intomainfrom
codex/fix-image-export-for-multiple-charts

Conversation

@ObservedObserver
Copy link
Member

@ObservedObserver ObservedObserver commented Dec 5, 2025

Summary

  • merge repeated Vega chart canvases into a single combined image when exporting
  • ensure data-url exports use the merged image data across chart entries

Testing

  • not run (not requested)

Codex Task


Note

Combine multiple Vega chart canvases into one merged PNG for data-url and download exports, propagating the merged data across chart entries.

  • Utils:
    • Add concatCanvases to stitch multiple chart canvas elements into a grid based on IVegaChartRef (x, y), computing column widths, row heights, and offsets.
  • Export API (useVegaExportApi):
    • getCanvasData/downloadPNG: generate a single merged PNG via concatCanvases; return/download one image instead of per-chart files.
    • exportChart (mode data-url): assign the merged image data to all res.charts entries; SVG export remains unchanged.

Written by Cursor Bugbot for commit 75ea542. Configure here.

@vercel
Copy link

vercel bot commented Dec 5, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
graphic-walker Ready Ready Preview Comment Dec 5, 2025 2:09am

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

return item.view.toCanvas(2);
}));
return canvases.map(canvas => canvas.toDataURL('image/png', 1));
const merged = concatCanvases(canvases, viewsRef.current);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Stale ref used after async canvas generation

In getCanvasData() and downloadPNG(), viewsRef.current is read once before the async Promise.all() to generate canvases, then read again after the await to pass to concatCanvases. If viewsRef.current changes during the async operation (e.g., due to re-render), the canvases array and refs array could have different lengths or orderings, causing concatCanvases to access undefined ref elements and throw a TypeError when accessing ref.x or ref.y.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant