Skip to content

Conversation

@terapyon
Copy link
Member

New Features

  • HTML Export API: Export visualizations as self-contained HTML files

    • Plotter.export_html() method for saving graphs as standalone HTML
    • Works offline without internet connection or JupyterLab
    • Preserves all interactive features (zoom, pan, node selection, drag)
  • Export Customization:

    • Custom title and description for HTML documents
    • Configurable container width (CSS values) and height (pixels)
    • Default responsive layout (100% width x 600px height)
  • Flexible Output Options:

    • File export with automatic .html extension
    • Automatic parent directory creation
    • HTML string return for programmatic use
    • Browser download trigger for remote environments (JupyterHub, Google Colab)

API Examples

from net_vis import Plotter
import networkx as nx

G = nx.karate_club_graph()
plotter = Plotter(title="Karate Club")
plotter.add_networkx(G)

# Export to file
path = plotter.export_html("my_graph.html")

# Export with customization
plotter.export_html(
    "report.html",
    title="Network Analysis",
    description="Karate club social network",
    width="800px",
    height=700
)

# Get HTML string
html = plotter.export_html()

# Remote environment download
plotter.export_html("graph.html", download=True)

Implementation Details

  • HTMLExporter: Template-based HTML generation using string.Template
  • Standalone Bundle: D3.js + rendering code bundled via webpack (~280KB)
  • Test Coverage: 26 new tests covering all export functionality
  • Error Handling: Proper exception propagation for file system errors

Compatibility

  • All modern browsers (Chrome, Firefox, Safari, Edge)
  • Offline capable (no CDN or internet dependency)
  • JupyterLab: 3.x and 4.x
  • Python: 3.10+

@terapyon terapyon marked this pull request as ready for review December 25, 2025 07:21
@terapyon terapyon merged commit ef6f2cf into main Dec 25, 2025
33 checks passed
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

Successfully merging this pull request may close these issues.

2 participants