Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Open in Vega Editor" does not work in VS Code Notebooks #2875

Closed
JannisKoeksel opened this issue Feb 6, 2023 · 6 comments
Closed

"Open in Vega Editor" does not work in VS Code Notebooks #2875

JannisKoeksel opened this issue Feb 6, 2023 · 6 comments
Labels

Comments

@JannisKoeksel
Copy link

The actions View Source, View Compiled Vega and Open in Vega Editor provided next to the plot do not work in VS Code.
The links redirect to the top of the notebook, so I'm guessing the event handlers do not work as intended.
I am using Version 4.2.2.

@mattijn
Copy link
Contributor

mattijn commented Feb 6, 2023

Thanks for raising @JannisKoeksel! I noticed the same. Are you able to figure out why this is not working? Is there documentation by MS VSCode that can support this issue how we could improve this?

@ChristopherDavisUCI
Copy link
Contributor

Does this look related? microsoft/vscode-jupyter#11294

@JannisKoeksel
Copy link
Author

So there are two problems:

  1. Opening links from VS Code via window.open does not work. I have not found any documentation about this, but all my attempts have failed.
  2. Vega Editor gets its definition via window.postMessage

Problem one could be solved by by e.g. using ipywidgets.widgets.Button and displaying them instead of the vega-embed actions. Then using python webbrowser to open a new tab.
Although I personally find the widgets aesthetically unpleasing they should work for "View Source" and "View Compiled Vega".

Regarding the second issue, the only viable solution I can think of is to dynamically write a html file or use data: base64 encoding with the definition and embedding vega editor as an iframe. Then the postMessage mechanism should work again.
There seams to be an issue with opening data-links and vscode-remote-links thought. And I have not found a solution that does not include running a server on the remote host or syncing files.
Sadly I am not very familiar with the internals of VS Code so best I can do is guessing.

@ChristopherDavisUCI yes is seams to be the same issue. I would really like to use this feature so disabling it is my least favorite solution.

@ChristopherDavisUCI
Copy link
Contributor

This definitely seems worth looking into.

As a not-very-satisfying workaround, do you know about c.to_json() or print(c.to_json()) or pprint(c.to_json()), where c is the Altair Chart? That should produce something that can be pasted into the Vega Editor.

@JannisKoeksel
Copy link
Author

No I wasn't aware, but print(c.to_json()) works for me. For my use case the extra steps required aren't to bad either.

@joelostblom
Copy link
Contributor

I opened microsoft/vscode-jupyter#13261 where we can continue this discussion. Since it is an issue with VS Code and not with Altair, I will close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants