r"""
Circular drawing and the interactive HTML viewer
================================================

The circular drawing puts the vertices on a circle in seriated order and
draws every hyperedge as a hub with curved spokes. ``hv.to_html`` writes a
self-contained HTML page with draggable vertices, recomputed hulls, layout
switching, group toggles and SVG export — the browser successor of the
HyperGodot interface.
"""

# %%
import pathlib
import tempfile

import matplotlib.pyplot as plt

import hatvis as hv
from hatvis.plotting import draw_circular

H = hv.datasets.load_manufacturing_cps()
fig, axes = plt.subplots(1, 2, figsize=(12, 5.6))
draw_circular(H, ax=axes[0], order="seriation", title="seriated order")
draw_circular(H, ax=axes[1], order="given", title="original order")
plt.tight_layout()

# [snippet:html]
path = pathlib.Path(tempfile.mkdtemp()) / "production.html"
hv.to_html(H, path, group="group", title="Cyber-physical production (HyperGodot example)")
# [/snippet:html]
print(path.name, path.stat().st_size // 1024, "kB")
