Skip to content

feat: Output Altair SVG charts as base64-encoded images#8443

Merged
mscolnick merged 1 commit intomarimo-team:mainfrom
daizutabi:feat-altair-svg-img
Feb 25, 2026
Merged

feat: Output Altair SVG charts as base64-encoded images#8443
mscolnick merged 1 commit intomarimo-team:mainfrom
daizutabi:feat-altair-svg-img

Conversation

@daizutabi
Copy link
Contributor

📝 Summary

This pull request modifies the AltairFormatter to output SVG charts as base64-encoded data URIs.

Currently, Altair SVG charts are rendered as raw <svg> elements, which prevents users from easily saving or dragging the chart as an image file. This change encodes the SVG output into a data:image/svg+xml;base64,... URI, which the frontend then renders as an <img> tag.

This improves the user experience by allowing Altair SVG charts to be dragged and dropped or saved as image files directly from the browser.

Note: This change only impacts users who explicitly opt-in with altair.renderers.enable("svg"). There is no change to the default behavior.

Closes #8400

🔍 Description of Changes

  • Modified marimo/_output/formatters/altair_formatters.py to base64-encode SVG string outputs and format them as a data URI.
  • Updated tests/_output/formatters/test_altair_formatters.py to assert the new data URI format.

Current behavior: Altair SVG as raw <svg> (lacks image context menu)

aa

After this PR: Altair SVG as Base64-encoded <img> (provides image context menu)

bb

📋 Checklist

  • I have read the contributor guidelines.
  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Tests have been added for the changes made.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Pull request title is a good summary of the changes - it will be used in the release notes.

@vercel
Copy link

vercel bot commented Feb 24, 2026

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

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Feb 24, 2026 10:36am

Request Review

@mscolnick mscolnick added the enhancement New feature or request label Feb 24, 2026
@mscolnick mscolnick merged commit 60d3635 into marimo-team:main Feb 25, 2026
31 of 41 checks passed
@daizutabi daizutabi deleted the feat-altair-svg-img branch February 25, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Output Altair SVG charts as <img>

2 participants