RFC 0060 — Exporting a chart: an image, a picture to paste, the data
Status: implemented (2026-11-27) · Target: 0.60.0 · builds on RFC 0058, RFC 0059 and files · see Decisions
Summary
A chart in a desktop app is something people take with them: into a report, an email or a slide. Today they screenshot it. RFC 0058 and 0059 both left export out as "worth doing, separately".
This RFC lets every chart in @elyra/charts save itself or copy itself, from
a menu the user already knows, with no code in the app:
right-click a chart (or Shift+F10 on it):
Copy as image
Save as PNG…
Save as SVG…
─────────────
Copy data
Save data as CSV…
<!-- On by default; off where a chart shouldn't leave the app -->
<SankeyChart {nodes} {links} exportable={false} />
<!-- Or from the app's own button -->
<script>
let chart;
</script>
<LineChart bind:this={chart} {series} {categories} />
<Button onclick={() => chart.save("png")}>Export</Button>
- Images:
- SVG is the chart as it's drawn.
- PNG is that same SVG at twice the pixels.
- Both have the theme's surface behind them, so a dark chart stays readable on a white page.
- Copy as image puts a PNG on the system clipboard, ready to paste into Word, Keynote or Mail.
- The data is the hidden table the screen reader and the assistant already read, as CSV in the app's locale. Norwegian gets decimal commas, with semicolons between the fields.
- The file is written where the user chose in the save dialog, and nowhere else. The page only gets to write to a file the user picked.
Motivation
- A report is where a chart ends up. Today the user screenshots it, and gets a blurry crop with the window's edges.
- The table is already there. "Copy data" reuses what the screen reader and the assistant read (RFC 0058), with no export code per chart.
- Every app would build the same menu. It should be built once, and in the app's language.
Current state (0.59)
dialog.savegives the page aChosenFilegrant of kindsave. A Rust command can write to it, but the page itself can't. Every export would need a command of its own.clipboard.writeTextexists, but there's nothing for images.arboard, which the shell already uses for text, can also hold images.contextMenu(event, items)in the runtime draws the themed menu.- ECharts can give an SVG string (
renderToSVGString, with the SVG renderer) or a data URL.
Design
In the runtime
// Save bytes where the user chooses: the dialog, then the write. The path, or null.
files.save(data: Blob | Uint8Array | string, options: SaveDialogOptions): Promise<string | null>;
// An image on the clipboard: PNG bytes.
clipboard.writeImage(png: Blob | Uint8Array): Promise<void>;
files.save is dialog.save followed by a new shell route,
/__system/file.write { id, bytes }. That route writes only to a grant of
kind save from this run, once. Any other id is refused, as a path the
user didn't choose can't be passed today. It needs Capability::System,
like the dialogs, and the system feature.
clipboard.writeImage decodes the PNG in the shell and hands RGBA to
arboard.
In @elyra/charts
- The menu:
ChartBaseopens it oncontextmenu, and on Shift+F10 or the Menu key when the chart has focus.- Its words are
elyra.charts.*. - Its items follow what the shell can do. Without the
systemfeature, only "Copy data" is offered (the page's own clipboard), so the menu never offers something that fails.
- The images:
- SVG: an SVG-rendered chart gives its own SVG. A canvas or 3D chart can't give an SVG, so it doesn't offer one.
- PNG: the SVG is drawn onto a canvas at 2× scale. A canvas-rendered chart gives its own PNG.
- Behind the image: the theme's
--elyra-surface, and for an SVG the font's family too.
- The data:
- The table, its caption as the first line, then the head row and the rows.
- In the app's locale:
- numbers as the table writes them, which for Norwegian means decimal commas;
- semicolons between the fields where the locale's decimal sign is a comma, otherwise commas;
- quoted per RFC 4180.
- The file name is the chart's
label, else its summary's first words, else "chart", plus the date, for exampleRevenue 2026-11-27.png. - For the app:
exportable={false}turns the menu off.bind:thisgivessave(format),copy()andcsv()for the app's own buttons.
Testing
files.saveand/__system/file.write:- a save grant is written, once;
- an open grant, an unknown id or a second write are refused.
clipboard.writeImage: PNG in, RGBA out, in the shell's own test of the decode.@elyra/charts:- the menu's items with and without the system feature;
- the CSV in English and Norwegian;
- the file name;
- SVG with the surface behind it;
- PNG from the SVG, with a fake canvas.
- A browser check: Save as PNG on a chart in the gallery writes a PNG of the size asked.
Implementation plan
/__system/file.writeandfiles.save;clipboard.writeImage.@elyra/charts: the export functions, the menu,exportable, the component methods, the words.- The gallery's charts with the menu; docs (
charts.md,system.md), CHANGELOG.
Open questions
Answered in Decisions.
- A context menu, or a visible button on every chart?
Recommendation: the context menu, with Shift+F10 and the Menu key.
It's where a desktop user looks, and it doesn't crowd a dashboard of
small charts. An app that wants a button calls
chart.save(). - On by default?
Recommendation: yes. A chart the user can see they can screenshot
anyway;
exportable={false}is for the rare one that shouldn't leave. files.saveas a general runtime API, not just the charts'? Recommendation: yes. "Save this as a file" is what every export needs (a report, an invoice PDF made in the page), and it's safe the same waydialog.saveis.- CSV in the app's locale, or always comma and point? Recommendation: the app's locale. A Norwegian user opens it in Excel, which reads semicolons and decimal commas in a Norwegian setup.
- Images on the clipboard on every platform?
Recommendation: yes, through
arboard(its defaultimage-data), on macOS, Windows and X11; on Wayland it needs arboard'swayland-data-controlfeature, which the shell turns on for Linux. Where it still fails, the item says so in a toast rather than disappearing.
Not in this RFC
- PDF: an image in a PDF is the app's report's business;
files.savetakes the bytes. - Exporting several charts at once (a dashboard).
- Drag a chart out onto the desktop or into another app.
Alternatives considered
- ECharts' toolbox
saveAsImage: it downloads through the browser, which a webview turns into nothing or a file in Downloads without asking, and it's English, unthemed and one more thing in every chart's corner. - A command per export in Rust: every app writes the same command, and the page still has to hand it the bytes.
As built
/__sys/file.write(files::write_saved) writes to a save grant from this run and spends it; an open, folder or document grant, an unknown id and a second write are refused. It's underCapability::System, and a read-only window can't reach it. The bytes come as MessagePackbin(a smallBytestype reads them, noserde_bytes).clipboard.imagedecodes the PNG with thepngcrate the shell already has, to RGBA forarboard;wayland-data-controlis on for Linux.- The menu asks the shell once (
paths()) whether it has the system feature; a failure is a toast in the app's language. - The CSV isn't the hidden table's text: the table formats numbers for
reading (
1 200,5, or the chart'sformat), so the CSV is described again with plain numbers, no grouping, the locale's decimal sign. - Found on the way:
contextMenuwasn't a menu to the keyboard or a screen reader; it is now, as Shift+F10 needs.- A chart's SVG was invalid XML whenever the font token named a font in
double quotes (the default does:
"Segoe UI"), which ECharts writes intostyle="…"unescaped. The PNG, drawn from it, failed with it; a browser check found it, happy-dom didn't.
Decisions
- A context menu, with Shift+F10 and the Menu key;
save(),copy()andcsv()for an app's own button. - On by default;
exportable={false}turns it off. files.saveis a general runtime API.- CSV in the app's locale.
- Images on the clipboard everywhere, with arboard's
wayland-data-controlon Linux, and a toast where it still fails.