microsoft / vscode-jupyter

VS Code Jupyter extension
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter
MIT License
1.26k stars 277 forks source link

Allow copy of charts from the output cell area #15322

Open joelostblom opened 4 months ago

joelostblom commented 4 months ago

In jupyterlab I can copy a chart by shift + right-clicking the chart image, which brings up the browser menu. In VS Code, it shift + right click does nothing. Some charting libraries seems to render a save button in VS Code, so I guess there is some logic to detect whether the output is an image. However, other libraries produce both and image and and interactive chart, and it seems like the VS logic fail for those.

E.g. the matplotlib code from this example seem to work fine as three small button show up to the right when I hover the image (copy, open in new tab, save to disk). However this altair example does not show any buttons when hovered over and there seems to be no way for me to copy the image other than taking a screenshot. In jupyterlab (and directly in the browser), I can shift + right click and copy the altair chart as well.

Maybe related to https://github.com/microsoft/vscode-jupyter/issues/13453 and https://github.com/microsoft/vscode/pull/190768

Version: 1.88.0-insider
Commit: 61187a0b6547df5911a0ee259f7afda46bac7ec3
Date: 2024-03-04T05:46:08.286Z
Electron: 28.2.2
ElectronBuildId: 26836304
Chromium: 120.0.6099.276
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Linux x64 6.6.10-76060610-generic
amunger commented 4 months ago

Looks like there is a canvas element that we could likely copy in the altair example:

image

joelostblom commented 4 months ago

Copying the canvas element sounds like a good idea :+1: