@@ -7,6 +7,7 @@ let invertedData = null;
77let currentThreadFilter = 'all' ;
88let isInverted = false ;
99let useModuleNames = true ;
10+ let zoomedNodeValue = null ;
1011
1112// Heat colors are now defined in CSS variables (--heat-1 through --heat-8)
1213// and automatically switch with theme changes - no JS color arrays needed!
@@ -316,6 +317,7 @@ function createPythonTooltip(data) {
316317 const selfSamples = d . data . self || 0 ;
317318 const selfMs = ( selfSamples / 1000 ) . toFixed ( 2 ) ;
318319 const percentage = ( ( d . data . value / data . value ) * 100 ) . toFixed ( 2 ) ;
320+ const relativePercentage = Math . min ( 100 , ( ( d . data . value / ( zoomedNodeValue ?? data . value ) ) * 100 ) ) . toFixed ( 2 ) ;
319321 const calls = d . data . calls || 0 ;
320322 const childCount = d . children ? d . children . length : 0 ;
321323 const source = d . data . source ;
@@ -439,6 +441,11 @@ function createPythonTooltip(data) {
439441 <span class="tooltip-stat-label">Percentage:</span>
440442 <span class="tooltip-stat-value accent">${ percentage } %</span>
441443
444+ ${ relativePercentage != percentage && relativePercentage != "100.00" ? `
445+ <span class="tooltip-stat-label">Relative Percentage:</span>
446+ <span class="tooltip-stat-value accent">${ relativePercentage } %</span>
447+ ` : '' }
448+
442449 ${ calls > 0 ? `
443450 <span class="tooltip-stat-label">Function Calls:</span>
444451 <span class="tooltip-stat-value">${ calls . toLocaleString ( ) } </span>
@@ -620,6 +627,9 @@ function createFlamegraph(tooltip, rootValue, data) {
620627 const percentage = d . data . value / rootValue ;
621628 const level = getHeatLevel ( percentage ) ;
622629 return heatColors [ level ] ;
630+ } )
631+ . onClick ( function ( d ) {
632+ zoomedNodeValue = d . data . value ;
623633 } ) ;
624634
625635 return chart ;
@@ -629,6 +639,7 @@ function renderFlamegraph(chart, data) {
629639 d3 . select ( "#chart" ) . datum ( data ) . call ( chart ) ;
630640 window . flamegraphChart = chart ;
631641 window . flamegraphData = data ;
642+ zoomedNodeValue = null ;
632643 populateStats ( data ) ;
633644}
634645
@@ -1269,6 +1280,7 @@ function filterDataByThread(data, threadId) {
12691280
12701281function resetZoom ( ) {
12711282 if ( window . flamegraphChart ) {
1283+ zoomedNodeValue = null ;
12721284 window . flamegraphChart . resetZoom ( ) ;
12731285 }
12741286}
0 commit comments