Spaces:
Sleeping
Sleeping
feat: add PNG screenshot button — saves network canvas as image
Browse files- build_network.py +16 -1
build_network.py
CHANGED
|
@@ -305,9 +305,11 @@ body {{ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans
|
|
| 305 |
.canvas-wrap {{ position: relative; flex: 1; }}
|
| 306 |
#mynetwork {{ width: 100%; height: 100%; background: #fff; }}
|
| 307 |
|
| 308 |
-
.status-bar {{ position: absolute; top: 12px; right: 16px; z-index: 10; display: flex; gap:
|
| 309 |
.stat {{ font-size: 12px; color: #aaa; background: rgba(255,255,255,0.9); padding: 4px 10px; border-radius: 4px; border: 1px solid #eee; }}
|
| 310 |
.stat strong {{ color: #555; }}
|
|
|
|
|
|
|
| 311 |
|
| 312 |
.tabs {{ position: absolute; bottom: 16px; left: 24px; z-index: 10; display: flex; gap: 4px; }}
|
| 313 |
.tab-btn {{ padding: 6px 14px; font-size: 12px; font-weight: 500; border: 1px solid #ddd; background: #fff; border-radius: 6px; cursor: pointer; color: #555; transition: all 0.15s; }}
|
|
@@ -516,6 +518,15 @@ function closeProfile() {{
|
|
| 516 |
document.getElementById('profilePanel').classList.remove('open');
|
| 517 |
}}
|
| 518 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 519 |
function highlightSidebarRow(id) {{
|
| 520 |
var rows = document.querySelectorAll('.attr-row');
|
| 521 |
rows.forEach(function(r) {{ r.classList.remove('selected'); }});
|
|
@@ -615,6 +626,10 @@ document.addEventListener('DOMContentLoaded', function() {{
|
|
| 615 |
<div class="status-bar">
|
| 616 |
<span class="stat">Attributes: <strong id="nodeCount">0</strong></span>
|
| 617 |
<span class="stat">Connections: <strong id="edgeCount">0</strong></span>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 618 |
</div>
|
| 619 |
<div id="mynetwork"></div>
|
| 620 |
<div class="profile-panel" id="profilePanel">
|
|
|
|
| 305 |
.canvas-wrap {{ position: relative; flex: 1; }}
|
| 306 |
#mynetwork {{ width: 100%; height: 100%; background: #fff; }}
|
| 307 |
|
| 308 |
+
.status-bar {{ position: absolute; top: 12px; right: 16px; z-index: 10; display: flex; gap: 8px; align-items: center; }}
|
| 309 |
.stat {{ font-size: 12px; color: #aaa; background: rgba(255,255,255,0.9); padding: 4px 10px; border-radius: 4px; border: 1px solid #eee; }}
|
| 310 |
.stat strong {{ color: #555; }}
|
| 311 |
+
.screenshot-btn {{ background: rgba(255,255,255,0.9); border: 1px solid #eee; border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 12px; color: #aaa; transition: all 0.15s; display: flex; align-items: center; gap: 4px; }}
|
| 312 |
+
.screenshot-btn:hover {{ background: #fff; color: #555; border-color: #ccc; }}
|
| 313 |
|
| 314 |
.tabs {{ position: absolute; bottom: 16px; left: 24px; z-index: 10; display: flex; gap: 4px; }}
|
| 315 |
.tab-btn {{ padding: 6px 14px; font-size: 12px; font-weight: 500; border: 1px solid #ddd; background: #fff; border-radius: 6px; cursor: pointer; color: #555; transition: all 0.15s; }}
|
|
|
|
| 518 |
document.getElementById('profilePanel').classList.remove('open');
|
| 519 |
}}
|
| 520 |
|
| 521 |
+
function saveScreenshot() {{
|
| 522 |
+
var canvas = document.getElementById('mynetwork').getElementsByTagName('canvas')[0];
|
| 523 |
+
if (!canvas) return;
|
| 524 |
+
var link = document.createElement('a');
|
| 525 |
+
link.download = '{chart_title}_network.png';
|
| 526 |
+
link.href = canvas.toDataURL('image/png');
|
| 527 |
+
link.click();
|
| 528 |
+
}}
|
| 529 |
+
|
| 530 |
function highlightSidebarRow(id) {{
|
| 531 |
var rows = document.querySelectorAll('.attr-row');
|
| 532 |
rows.forEach(function(r) {{ r.classList.remove('selected'); }});
|
|
|
|
| 626 |
<div class="status-bar">
|
| 627 |
<span class="stat">Attributes: <strong id="nodeCount">0</strong></span>
|
| 628 |
<span class="stat">Connections: <strong id="edgeCount">0</strong></span>
|
| 629 |
+
<button class="screenshot-btn" onclick="saveScreenshot()" title="Save as PNG">
|
| 630 |
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z"/><circle cx="12" cy="13" r="4"/></svg>
|
| 631 |
+
PNG
|
| 632 |
+
</button>
|
| 633 |
</div>
|
| 634 |
<div id="mynetwork"></div>
|
| 635 |
<div class="profile-panel" id="profilePanel">
|