(data)
| 77 | } |
| 78 | |
| 79 | function loadAndRenderData(data) { |
| 80 | archiveProgramIds = Array.isArray(data.archive) ? data.archive : []; |
| 81 | lastDataStr = JSON.stringify(data); |
| 82 | renderGraph(data); |
| 83 | renderNodeList(data.nodes); |
| 84 | document.getElementById('checkpoint-label').textContent = |
| 85 | "Checkpoint: " + (data.checkpoint_dir || 'static export'); |
| 86 | const metricSelect = document.getElementById('metric-select'); |
| 87 | const prevMetric = metricSelect.value || localStorage.getItem('selectedMetric') || null; |
| 88 | metricSelect.innerHTML = ''; |
| 89 | const metrics = new Set(); |
| 90 | data.nodes.forEach(node => { |
| 91 | if (node.metrics) { |
| 92 | Object.keys(node.metrics).forEach(metric => metrics.add(metric)); |
| 93 | } |
| 94 | }); |
| 95 | metrics.forEach(metric => { |
| 96 | const option = document.createElement('option'); |
| 97 | option.value = metric; |
| 98 | option.textContent = metric; |
| 99 | metricSelect.appendChild(option); |
| 100 | }); |
| 101 | if (prevMetric && metrics.has(prevMetric)) { |
| 102 | metricSelect.value = prevMetric; |
| 103 | } else if (metricSelect.options.length > 0) { |
| 104 | metricSelect.selectedIndex = 0; |
| 105 | } |
| 106 | metricSelect.addEventListener('change', function() { |
| 107 | localStorage.setItem('selectedMetric', metricSelect.value); |
| 108 | }); |
| 109 | const perfTab = document.getElementById('tab-performance'); |
| 110 | const perfView = document.getElementById('view-performance'); |
| 111 | if (perfTab && perfView && (perfTab.classList.contains('active') || perfView.style.display !== 'none')) { |
| 112 | if (window.updatePerformanceGraph) { |
| 113 | window.updatePerformanceGraph(data.nodes); |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | if (window.STATIC_DATA) { |
| 119 | loadAndRenderData(window.STATIC_DATA); |
no test coverage detected