@@ -160,10 +160,10 @@ function resetHeatmap(message = HEATMAP_DEFAULT_STREAM_MESSAGE) {
160160 heatmapState . windowX = 0 ;
161161 heatmapState . windowY = 0 ;
162162 heatmapState . slice = 0 ;
163- heatmapState . autoMin = undefined ;
164- heatmapState . autoMax = undefined ;
165- heatmapState . sliceMinBound = undefined ;
166- heatmapState . sliceMaxBound = undefined ;
163+ heatmapState . viewMin = undefined ;
164+ heatmapState . viewMax = undefined ;
165+ heatmapState . sliceMin = undefined ;
166+ heatmapState . sliceMax = undefined ;
167167 heatmapState . scaleMin = - 1 ;
168168 heatmapState . scaleMax = 1 ;
169169 heatmapState . scaleInitialized = false ;
@@ -213,12 +213,12 @@ function layoutFromTensor(tensor) {
213213
214214 if ( ! Number . isFinite ( width ) || width <= 0 ) {
215215 if ( Array . isArray ( tensor . shape ) && tensor . shape . length > 0 ) {
216- width = tensor . shape [ tensor . shape . length - 1 ] ;
216+ width = Number ( tensor . shape [ 0 ] ) ;
217217 }
218218 }
219219 if ( ! Number . isFinite ( height ) || height <= 0 ) {
220220 if ( Array . isArray ( tensor . shape ) && tensor . shape . length > 1 ) {
221- height = tensor . shape [ tensor . shape . length - 2 ] ;
221+ height = Number ( tensor . shape [ 1 ] ) ;
222222 } else {
223223 height = 1 ;
224224 }
@@ -274,7 +274,7 @@ function updateHeatmapHeader() {
274274 const coverageTotal = heatmapState . viewWidth * heatmapState . viewHeight ;
275275 const coverageText = coverageTotal > 0 ? `${ heatmapState . valid } /${ coverageTotal } ` : "0/0" ;
276276 const statusParts = [
277- `Layout ${ layoutHeight } x ${ layoutWidth } ` ,
277+ `Layout ${ layoutWidth } x ${ layoutHeight } ` ,
278278 `X ${ x0 } - ${ x1 } ` ,
279279 `Y ${ y0 } - ${ y1 } ` ,
280280 `Cells ${ coverageText } ` ,
@@ -603,13 +603,13 @@ async function fetchHeatmapWindow() {
603603 void fetchHistogram ( ) ;
604604 }
605605
606- heatmapState . autoMin = typeof data . min === "number" ? data . min : undefined ;
607- heatmapState . autoMax = typeof data . max === "number" ? data . max : undefined ;
608- heatmapState . sliceMinBound = typeof data . sliceMin === "number" ? data . sliceMin : undefined ;
609- heatmapState . sliceMaxBound = typeof data . sliceMax === "number" ? data . sliceMax : undefined ;
606+ heatmapState . viewMin = typeof data . min === "number" ? data . min : undefined ;
607+ heatmapState . viewMax = typeof data . max === "number" ? data . max : undefined ;
608+ heatmapState . sliceMin = typeof data . sliceMin === "number" ? data . sliceMin : undefined ;
609+ heatmapState . sliceMax = typeof data . sliceMax === "number" ? data . sliceMax : undefined ;
610610
611611 if ( ! heatmapState . scaleInitialized ) {
612- setHeatmapScale ( heatmapState . autoMin , heatmapState . autoMax , { reapply : false , sync : false } ) ;
612+ setHeatmapScale ( heatmapState . viewMin , heatmapState . viewMax , { reapply : false , sync : false } ) ;
613613 } else {
614614 const clamped = sanitizeScale ( heatmapState . scaleMin , heatmapState . scaleMax ) ;
615615 heatmapState . scaleMin = clamped . min ;
@@ -770,16 +770,32 @@ function openHeatmap(nameEncoded, options = {}) {
770770}
771771
772772
773+ function handleTensorAction ( target ) {
774+ if ( ! target || target . tagName !== "BUTTON" || ! target . dataset . name ) {
775+ return ;
776+ }
777+
778+ const action = target . dataset . action || "heatmap" ;
779+ const destination = action === "statistics" ? "statistics" : "heatmap" ;
780+ const current = normalizePageId ( window . location . hash . slice ( 1 ) ) ;
781+ if ( current !== destination ) {
782+ window . location . hash = destination ;
783+ }
784+ openHeatmap ( target . dataset . name ) ;
785+ }
786+
773787tensorBody . addEventListener ( "click" , ( event ) => {
774788 const target = event . target ;
775- if ( target . tagName === "BUTTON" && target . dataset . name ) {
776- if ( normalizePageId ( window . location . hash . slice ( 1 ) ) !== "heatmap" ) {
777- window . location . hash = "heatmap" ;
778- }
779- openHeatmap ( target . dataset . name ) ;
780- }
789+ handleTensorAction ( target ) ;
781790} ) ;
782791
792+ if ( architectureContent ) {
793+ architectureContent . addEventListener ( "click" , ( event ) => {
794+ const target = event . target ;
795+ handleTensorAction ( target ) ;
796+ } ) ;
797+ }
798+
783799function commitSliceInput ( ) {
784800 if ( ! heatmapSliceInput || ! heatmapState . tensor ) {
785801 return ;
@@ -867,15 +883,15 @@ if (heatmapMaxInput) {
867883 } ) ;
868884}
869885
870- if ( heatmapAutoButton ) {
871- heatmapAutoButton . addEventListener ( "click" , ( ) => {
886+ if ( heatmapSliceButton ) {
887+ heatmapSliceButton . addEventListener ( "click" , ( ) => {
872888 if ( ! heatmapState . tensor ) {
873889 return ;
874890 }
875- if ( ! Number . isFinite ( heatmapState . autoMin ) || ! Number . isFinite ( heatmapState . autoMax ) ) {
891+ if ( ! Number . isFinite ( heatmapState . sliceMin ) || ! Number . isFinite ( heatmapState . sliceMax ) ) {
876892 return ;
877893 }
878- setHeatmapScale ( heatmapState . autoMin , heatmapState . autoMax ) ;
894+ setHeatmapScale ( heatmapState . sliceMin , heatmapState . sliceMax ) ;
879895 } ) ;
880896}
881897
0 commit comments