Skip to content

d3js visualization fails to render in jupyter notebook #308

@hackl

Description

@hackl

Interactive plot visualizations fail to render in a Jupyter Notebook environment. Interestingly, the plots rendered correctly immediately after installing pathpyG, but after subsequent usage (within the same virtual environment), none of the interactive plots worked anymore.

The issue appears to be related to how pathpyG determines whether to use a CDN-hosted vs. local copy of d3js.

Symptoms

Jupyter shows the following warning:

[W 2026-02-02 20:05:48.718 ServerApp] 404 GET /Users/juergen/cloud/teaching/code/.venv/lib/python3.13/site-packages/pathpyG/visualisations/_d3js/templates/d3.v7.min.js (142c0658ab904379a00fa378ed728aba@::1) 1.29ms referer=http://localhost:8888/notebooks/test.ipynb

As a result, interactive plots do not render.

Observation:

The d3.js backend checks CDN availability and falls back to a local copy:

try:
   urllib.request.urlopen(_CDN_URL, timeout=2)
   self.config["d3js_local"] = self.config.get("d3js_local", False)
except (urllib.error.URLError, urllib.error.HTTPError):
   self.config["d3js_local"] = self.config.get("d3js_local", True)

It appears that the HTTPS request to https://d3js.org/d3.v7.min.js fails in my environment, which triggers fallback to the local file. However, the referenced local file cannot be loaded (404), leading to broken rendering.

Current Workaround

Forcing CDN usage makes the plots render correctly:

self.config["d3js_local"] = False

Additional Issue: Config Override

Even when explicitly setting:

import pathpyG as pp
pp.config["d3js_local"] = False

the value appears to be overwritten later by the exception-handling logic. This is unexpected: user-provided configuration should take precedence over automatic detection.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions