()
| 1404 | // ============================================================================ |
| 1405 | |
| 1406 | function initFlamegraph() { |
| 1407 | ensureLibraryLoaded(); |
| 1408 | restoreUIState(); |
| 1409 | setupLogos(); |
| 1410 | |
| 1411 | if (EMBEDDED_DATA.strings) { |
| 1412 | stringTable = EMBEDDED_DATA.strings; |
| 1413 | normalData = resolveStringIndices(EMBEDDED_DATA, EMBEDDED_DATA.strings); |
| 1414 | } else { |
| 1415 | normalData = EMBEDDED_DATA; |
| 1416 | } |
| 1417 | |
| 1418 | // Initialize opcode mapping from embedded data |
| 1419 | initOpcodeMapping(EMBEDDED_DATA); |
| 1420 | |
| 1421 | // Inverted data will be built on first toggle |
| 1422 | invertedData = null; |
| 1423 | |
| 1424 | initThreadFilter(normalData); |
| 1425 | |
| 1426 | // Toggle legend based on differential mode |
| 1427 | const isDifferential = normalData && normalData.stats && normalData.stats.is_differential; |
| 1428 | const heatmapLegend = document.getElementById('heatmap-legend-section'); |
| 1429 | const diffLegend = document.getElementById('diff-legend-section'); |
| 1430 | if (isDifferential) { |
| 1431 | if (heatmapLegend) heatmapLegend.style.display = 'none'; |
| 1432 | if (diffLegend) diffLegend.style.display = 'block'; |
| 1433 | } else { |
| 1434 | if (heatmapLegend) heatmapLegend.style.display = 'block'; |
| 1435 | if (diffLegend) diffLegend.style.display = 'none'; |
| 1436 | } |
| 1437 | |
| 1438 | const tooltip = createPythonTooltip(normalData); |
| 1439 | const chart = createFlamegraph(tooltip, normalData.value, normalData); |
| 1440 | renderFlamegraph(chart, normalData); |
| 1441 | initSearchHandlers(); |
| 1442 | initSidebarResize(); |
| 1443 | handleResize(); |
| 1444 | |
| 1445 | const toggleInvertBtn = document.getElementById('toggle-invert'); |
| 1446 | if (toggleInvertBtn) { |
| 1447 | toggleInvertBtn.addEventListener('click', toggleInvert); |
| 1448 | } |
| 1449 | } |
| 1450 | |
| 1451 | // Keyboard shortcut: Enter/Space activates toggle switches |
| 1452 | document.addEventListener('keydown', function(e) { |
no test coverage detected
searching dependent graphs…