Skip to content

BUG: Conflict with Require.js in Exported HTML Versions of Jupyter Notebooks #66

Closed

Description

@hcpchris

Steps to encounter the bug:

  1. Create a Jupyter Notebook using Highcharts for Python. The notebook should include the rendering of a chart via chart.display().
  2. Create a static HTML export of the notebook using either the Jupyter Notebook's Export functionality, or using the jupyter nbconvert terminal command.
  3. Open the file locally in your browser.
  4. The chart does not render.

However! When you remove the <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"/> from the HTML file produced by jupyter nbconvert, the chart renders correctly.

You can see this behavior in this JS Fiddle. When require.min.js is loaded from the CDN, the chart does not render. When it is removed from the CDN (in the Fiddle), the chart renders fine.

Activity

  1. added
    bug
    on Jun 29, 2023
  2. self-assigned this
    on Jun 29, 2023
  3. hcpchris commented on Jun 29, 2023

    @hcpchris
    CollaboratorAuthor

    POSSIBLE WORKAROUND UNTIL THIS BUG IS RESOLVED:

    Remove the line <script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.1.10/require.min.js"/> from the HTML produced by jupyter nbconvert. This may have unintended consequences, depending on what else you are doing within your Jupyter Notebook, but it should be a reasonable workaround in the short-term for most use cases.

  4. hcpchris commented on Jun 29, 2023

    @hcpchris
    CollaboratorAuthor

    POSSIBLE SOLUTION, THOUGH SOMEWHAT INELEGANT:

    In Chart._jupyter_include_scripts(), modify the JS code returned to check if require.js is present.

    • If it is not present, use the current approach.
    • If it is present, then use the require() function call method documented at the end of the section here.

    This approach should ensure that the chart will continue to render properly in an interactive Jupyter Notebook context (without introducing new conflicts, which forcing inclusion of require.js in that interactive Jupyter context might do), as well as in a static HTML context where require.js has been included.

  5. added this to the v.1.4 milestone on Sep 21, 2023
  6. moved this from In Progress to Awaiting Release in Highcharts for Python Roadmapon Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions