feat: restore Altair SVG output as base64-encoded Data URLs#9104
feat: restore Altair SVG output as base64-encoded Data URLs#9104Light2Dark merged 6 commits intomarimo-team:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This would still be a regression and loss of a used feature. Is there a workaround? Or can we opt out when there are external resources? |
|
I understand the concern regarding the regression. However, I believe that restoring Data URL output is the correct path.
Indeed, it is essentially a self-contradiction to use a chart that depends on external resources while specifically opting for a static image format. For users who require external resource support, the default renderer remains the appropriate and intended tool. Personally, I don't think it's right to sacrifice standard and expected image functionality for a specific edge case that is already well-supported by the default renderer and the action menu. |
|
@daizutabi your arguments make sense. im following up on #9013, to make sure users can actually opt for the |
1bb27d0 to
5f475b8
Compare
|
Hi @mscolnick, Following up on our discussion regarding SVG output, I’ve refined the implementation to provide a clean opt-out mechanism for users. Here are the key points of the updated approach:
I'd appreciate your thoughts on this!
|
|
I want to share a critical productivity feature enabled by Data URL output, especially for those of us working with a browser running inside a VDI (Virtual Desktop Infrastructure) window. The browser is located entirely within a remote Linux environment, siloed from the local host (typically Windows). Because the browser is "inside" the remote window, standard file downloads are trapped on the remote filesystem. A standout feature of marimo is that it implements its own "Copy Image" action in the UI. When charts are output as Data URLs, marimo's implementation can push the actual image data to the remote system clipboard. Why this is essential:
Without Data URLs, marimo's custom "Copy Image" feature wouldn't be able to treat the SVG as an image, breaking this vital cross-OS workflow. |
|
@daizutabi thank you for the thoughtful explanation, this sounds fine to me. I'm currently tied up to dig deeper, so I'm going to tag in @Light2Dark who may have opinions to on the change and implementation |
|
Thanks @daizutabi . From my understanding doing this would be more aligned with how svgs should be presented.
|
|
Also, something I didn't realize, this PR only affects users who have Seems we are swallowing that error of that package not being installed. Looks like a separate issue. |
## 📝 Summary <!-- If this PR closes any issues, list them here by number (e.g., Closes #123). Detail the specific changes made in this pull request. Explain the problem addressed and how it was resolved. If applicable, provide before and after comparisons, screenshots, or any relevant details to help reviewers understand the changes easily. --> We swallowed errors when imports were not installed / configurations were incorrect when rendering altair charts. This can lead to user confusion because their settings were not being respected. I noticed this when testing #9104 and did not have `vl-convert-python` installed. I'm hoping this isn't too noisy, I've tried several altair notebooks. <img width="817" height="39" alt="image" src="https://github.com/user-attachments/assets/6d553fd2-6a5e-4ca3-82cf-23ab1f331aad" /> ## 📋 Pre-Review Checklist <!-- These checks need to be completed before a PR is reviewed --> - [ ] For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on [Discord](https://marimo.io/discord?ref=pr), or the community [discussions](https://github.com/marimo-team/marimo/discussions) (Please provide a link if applicable). - [ ] Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it. - [ ] Video or media evidence is provided for any visual changes (optional). <!-- PR is more likely to be merged if evidence is provided for changes made --> ## ✅ Merge Checklist - [x] I have read the [contributor guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md). - [ ] Documentation has been updated where applicable, including docstrings for API changes. - [ ] Tests have been added for the changes made.
…r data URL encoding
5f475b8 to
1e1152c
Compare
|
I've updated the implementation based on the feedback!
|

📝 Summary
This PR restores the behavior of outputting Altair SVG charts as base64-encoded Data URLs, following the improvements made to marimo's layout rendering.
Background and Justification
mo.vstack) reported in Altair SVG doesn't render with layouts #9015 has been addressed in fix: SVG data URL rendering in layout elements #9043. By wrapping SVG Data URLs in<img>tags withinmime_to_html, they now render correctly across all layout components.mark_image) from loading due to browser security restrictions, this is consistent with the behavior in JupyterLab. It is a limitation of the SVG-as-image format itself rather than a bug in marimo's formatter.Changes
marimo/_output/formatters/altair_formatters.pyto encodeimage/svg+xmlstring responses into base64 Data URLs.tests/_output/formatters/test_altair_formatters.pyto reflect the change in the expected output format.📋 Pre-Review Checklist
✅ Merge Checklist