@@ -220,6 +220,7 @@ export default class Goban extends Component {
220
220
paintMap = [ ] ,
221
221
analysis,
222
222
analysisType,
223
+ showAnalysis,
223
224
highlightVertices = [ ] ,
224
225
dimmedStones = [ ] ,
225
226
@@ -409,41 +410,59 @@ export default class Goban extends Component {
409
410
410
411
let heatMap = [ ]
411
412
412
- if ( drawHeatMap && analysis != null ) {
413
- let maxVisitsWin = Math . max (
414
- ...analysis . variations . map ( x => x . visits * x . winrate )
415
- )
416
- heatMap = board . signMap . map ( row => row . map ( _ => null ) )
417
-
418
- for ( let {
419
- vertex : [ x , y ] ,
420
- visits,
421
- winrate,
422
- scoreLead
423
- } of analysis . variations ) {
424
- let strength = Math . round ( ( visits * winrate * 8 ) / maxVisitsWin ) + 1
425
-
426
- winrate =
427
- strength <= 3 ? Math . floor ( winrate ) : Math . floor ( winrate * 10 ) / 10
428
- scoreLead = scoreLead == null ? null : Math . round ( scoreLead * 10 ) / 10
429
- if ( scoreLead === 0 ) scoreLead = 0 // Avoid -0
430
-
431
- heatMap [ y ] [ x ] = {
432
- strength,
433
- text :
434
- visits < 10
435
- ? ''
436
- : [
437
- analysisType === 'winrate'
438
- ? i18n . formatNumber ( winrate ) +
439
- ( Math . floor ( winrate ) === winrate ? '%' : '' )
440
- : analysisType === 'scoreLead' && scoreLead != null
441
- ? ( scoreLead >= 0 ? '+' : '' ) + i18n . formatNumber ( scoreLead )
442
- : '–' ,
443
- visits < 1000
444
- ? i18n . formatNumber ( visits )
445
- : i18n . formatNumber ( Math . round ( visits / 100 ) / 10 ) + 'k'
446
- ] . join ( '\n' )
413
+ if ( drawHeatMap && showAnalysis ) {
414
+ let variations
415
+
416
+ if ( analysis != null ) {
417
+ variations = analysis . variations
418
+ } else {
419
+ variations = [ ]
420
+ for ( const v in board . childrenInfo ) {
421
+ const [ x , y ] = v . split ( ',' ) . map ( x => + x )
422
+ const { visits, winrate, scoreLead} = board . childrenInfo [ v ]
423
+ if ( isFinite ( visits ) && isFinite ( winrate ) ) {
424
+ variations . push ( { vertex : [ x , y ] , visits, winrate, scoreLead} )
425
+ }
426
+ }
427
+ }
428
+
429
+ if ( variations . length ) {
430
+ let maxVisitsWin = Math . max (
431
+ ...variations . map ( x => x . visits * x . winrate )
432
+ )
433
+ heatMap = board . signMap . map ( row => row . map ( _ => null ) )
434
+
435
+ for ( let {
436
+ vertex : [ x , y ] ,
437
+ visits,
438
+ winrate,
439
+ scoreLead
440
+ } of variations ) {
441
+ let strength = Math . round ( ( visits * winrate * 8 ) / maxVisitsWin ) + 1
442
+
443
+ winrate =
444
+ strength <= 3 ? Math . floor ( winrate ) : Math . floor ( winrate * 10 ) / 10
445
+ scoreLead = scoreLead == null ? null : Math . round ( scoreLead * 10 ) / 10
446
+ if ( scoreLead === 0 ) scoreLead = 0 // Avoid -0
447
+
448
+ heatMap [ y ] [ x ] = {
449
+ strength,
450
+ text :
451
+ visits < 10
452
+ ? ''
453
+ : [
454
+ analysisType === 'winrate'
455
+ ? i18n . formatNumber ( winrate ) +
456
+ ( Math . floor ( winrate ) === winrate ? '%' : '' )
457
+ : analysisType === 'scoreLead' && scoreLead != null
458
+ ? ( scoreLead >= 0 ? '+' : '' ) +
459
+ i18n . formatNumber ( scoreLead )
460
+ : '–' ,
461
+ visits < 1000
462
+ ? i18n . formatNumber ( visits )
463
+ : i18n . formatNumber ( Math . round ( visits / 100 ) / 10 ) + 'k'
464
+ ] . join ( '\n' )
465
+ }
447
466
}
448
467
}
449
468
}
0 commit comments