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

Does not export plotly to HTML #108

Open
lucasmsoares96 opened this issue Jun 1, 2023 · 1 comment
Open

Does not export plotly to HTML #108

lucasmsoares96 opened this issue Jun 1, 2023 · 1 comment

Comments

@lucasmsoares96
Copy link

lucasmsoares96 commented Jun 1, 2023

First of all, you guys are doing an amazing job here.

  • xeus-octave version:
    octave 7.3.0
    xeus-octave 0.1.0

  • Operating System:
    Debian

Description

I would like to export a notebook to HTML that contains a plot using graphics_toolkit("plotly"), but the plot does not appear in the generated HMTL. If you use graphics_toolkit("notebook") it works fine. For a Julia notebook the interactive graph is exported normally to HTML.

What I Did

graphics_toolkit("plotly")

[X,Y] = meshgrid(1:0.5:10,1:20);
Z = sin(X) + cos(Y);
surf(X,Y,Z)

Then:
File > Save and Export Notebook As... > HTML

@rapgenic
Copy link
Collaborator

Hi,

Thank you for reporting!

I can reproduce what you're seeing, and I think the reason for this is that when plotly is active xeus-octave produces an output with mimetype application/vnd.plotly.v1+json, which is automatically rendered by jupyterlab without intervention from the kernel.

I don't know about Julia, but I tried Python, and I found out that when showing a graph it outputs a text/html mimetype (in addition to the application/vnd.plotly.v1+json) which contains a pre baked html representation (made by the kernel) of the plot (bundling the plotly.js library and other things, already minified).

Unfortunately, at the moment the same thing is quite complicated to do for xeus-octave, because it cannot easily handle all the plotly libraries and prepare an html representation inside the kernel, so we must rely on jupyterlab doing this work for us.

I have seen that when you export to HTML, the plot is saved as an image, so it is probable that the plotly extension that jupyterlab uses for rendering the plot also gets to decide what format to output when exporting the notebook, so it might be possible to achieve what you need by adding an html output at conversion, but this goes beyond my knowledge.

Do you at least have the image output?

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

No branches or pull requests

2 participants