microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
164.47k stars 29.36k forks source link

How to hide lines generated with calls from IPython's `publish_display_data` function? #214886

Closed DonJayamanne closed 4 months ago

DonJayamanne commented 8 months ago

Discussed in https://github.com/microsoft/vscode-jupyter/discussions/15303

Originally posted by **maximlt** March 6, 2024 Hi all, I'm one of the maintainers of the plotting library [hvPlot](https://github.com/holoviz/[hvplot](https://github.com/holoviz/hvplot)). The library depends on the dashboarding library [Panel](https://github.com/holoviz/panel) to handle layouts and to enable interactive plot exploration. When hvPlot is imported, Panel injects some JS and styling into the notebook using IPython's [publish_display_data](https://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html#IPython.display.publish_display_data) function, calling it three times. This is required to enable some interactivity. Doing so in a VSCode notebook displays three empty rows. Is there a way to hide these empty lines? image In Jupyterlab, this only displays a small empty line (which is a bit less annoying): image For reference: https://github.com/holoviz/hvplot/issues/1284
michaelaye commented 5 months ago

@amunger can you help?

amunger commented 5 months ago

thanks for the ping, looks like this never got assigned.

It looks like the output that we try to render is some javascript code:

"outputs": [
    {
     "data": {
      "application/javascript": "(function(root) {\n  function now() {\n ...
      "application/vnd.holoviews_load.v0+json": ""
     },

And since it's three separate outputs, we render an output menu for each one. We might be able to check if the output content is empty after the renderer finishes and optionally hide it if so.