@@ -15,6 +15,7 @@ import {
1515 ModalMessageComponent ,
1616 DialogInfo ,
1717} from '../modal-message/modal-message.component' ;
18+ import { ThemeService } from '../../service/theme.service' ;
1819
1920export interface activitySchema {
2021 uuid : string ;
@@ -63,27 +64,56 @@ export class CircularHeatmapComponent implements OnInit {
6364 showOverlay : boolean ;
6465 showFilters : boolean ;
6566 markdown : md = md ( ) ;
67+ theme : string ;
68+ theme_colors ! : Record < string , string > ;
6669
6770 constructor (
6871 private yaml : ymlService ,
6972 private router : Router ,
73+ private themeService : ThemeService ,
7074 public modal : ModalMessageComponent
7175 ) {
7276 this . showOverlay = false ;
7377 this . showFilters = true ;
78+ this . theme = this . themeService . getTheme ( ) ;
7479 }
7580
7681 ngOnInit ( ) : void {
77- console . log ( `${ this . perfNow ( ) } s: ngOnInit` ) ;
78- // Ensure that Levels and Teams load before MaturityData
79- // using promises, since ngOnInit does not support async/await
80- this . LoadMaturityLevels ( )
81- . then ( ( ) => this . LoadTeamsFromMetaYaml ( ) )
82- . then ( ( ) => this . LoadMaturityDataFromGeneratedYaml ( ) )
83- . then ( ( ) => {
84- console . log ( `${ this . perfNow ( ) } s: set filters: ${ this . chips ?. length } ` ) ;
85- this . matChipsArray = this . chips . toArray ( ) ;
86- } ) ;
82+ const savedTheme = this . themeService . getTheme ( ) || 'light' ;
83+ this . themeService . setTheme ( savedTheme ) ; // sets .light-theme or .dark-theme
84+
85+ requestAnimationFrame ( ( ) => {
86+ // Now the DOM has the correct class and CSS vars are live
87+ const css = getComputedStyle ( document . body ) ;
88+ this . theme_colors = {
89+ background : css . getPropertyValue ( '--heatmap-background' ) . trim ( ) ,
90+ filled : css . getPropertyValue ( '--heatmap-filled' ) . trim ( ) ,
91+ disabled : css . getPropertyValue ( '--heatmap-disabled' ) . trim ( ) ,
92+ cursor : css . getPropertyValue ( '--heatmap-cursor' ) . trim ( ) ,
93+ stroke : css . getPropertyValue ( '--heatmap-stroke' ) . trim ( ) ,
94+ } ;
95+
96+ this . LoadMaturityLevels ( )
97+ . then ( ( ) => this . LoadTeamsFromMetaYaml ( ) )
98+ . then ( ( ) => this . LoadMaturityDataFromGeneratedYaml ( ) )
99+ . then ( ( ) => {
100+ this . matChipsArray = this . chips . toArray ( ) ;
101+ } ) ;
102+ } ) ;
103+
104+ // Reactively handle theme changes (if user toggles later)
105+ this . themeService . theme$ . subscribe ( ( theme : string ) => {
106+ const css = getComputedStyle ( document . body ) ;
107+ this . theme_colors = {
108+ background : css . getPropertyValue ( '--heatmap-background' ) . trim ( ) ,
109+ filled : css . getPropertyValue ( '--heatmap-filled' ) . trim ( ) ,
110+ disabled : css . getPropertyValue ( '--heatmap-disabled' ) . trim ( ) ,
111+ cursor : css . getPropertyValue ( '--heatmap-cursor' ) . trim ( ) ,
112+ stroke : css . getPropertyValue ( '--heatmap-stroke' ) . trim ( ) ,
113+ } ;
114+
115+ this . reColorHeatmap ( ) ; // repaint segments with new theme
116+ } ) ;
87117 }
88118
89119 @ViewChildren ( MatChip ) chips ! : QueryList < MatChip > ;
@@ -405,7 +435,6 @@ export class CircularHeatmapComponent implements OnInit {
405435 . innerRadius ( innerRadius )
406436 . segmentHeight ( segmentHeight )
407437 . domain ( [ 0 , 1 ] )
408- . range ( [ 'white' , 'green' ] )
409438 . radialLabels ( radial_labels )
410439 . segmentLabels ( segment_labels ) ;
411440
@@ -498,6 +527,7 @@ export class CircularHeatmapComponent implements OnInit {
498527 var segmentLabels : any [ ] = [ ] ;
499528
500529 //console.log(segmentLabels)
530+ let _self : any = this ;
501531
502532 function chart ( selection : any ) {
503533 selection . each ( function ( this : any , data : any ) {
@@ -548,7 +578,7 @@ export class CircularHeatmapComponent implements OnInit {
548578 . startAngle ( sa )
549579 . endAngle ( ea )
550580 )
551- . attr ( 'stroke' , '#252525' )
581+ . attr ( 'stroke' , _self . theme_colors [ 'stroke' ] )
552582 . attr ( 'fill' , function ( d ) {
553583 return color ( accessor ( d ) ) ;
554584 } ) ;
@@ -610,17 +640,11 @@ export class CircularHeatmapComponent implements OnInit {
610640 cursors
611641 . append ( 'path' )
612642 . attr ( 'id' , 'hover' )
613- . attr ( 'pointer-events' , 'none' )
614- . attr ( 'stroke' , 'green' )
615- . attr ( 'stroke-width' , '7' )
616- . attr ( 'fill' , 'transparent' ) ;
643+ . attr ( 'pointer-events' , 'none' ) ;
617644 cursors
618645 . append ( 'path' )
619646 . attr ( 'id' , 'selected' )
620- . attr ( 'pointer-events' , 'none' )
621- . attr ( 'stroke' , '#232323' )
622- . attr ( 'stroke-width' , '4' )
623- . attr ( 'fill' , 'transparent' ) ;
647+ . attr ( 'pointer-events' , 'none' ) ;
624648 } ) ;
625649 }
626650
@@ -716,7 +740,7 @@ export class CircularHeatmapComponent implements OnInit {
716740 noActivitytoGrey ( ) : void {
717741 for ( var x = 0 ; x < this . ALL_CARD_DATA . length ; x ++ ) {
718742 if ( this . ALL_CARD_DATA [ x ] [ 'Done%' ] == - 1 ) {
719- d3 . select ( '#index-' + x ) . attr ( 'fill' , '#DCDCDC' ) ;
743+ d3 . select ( '#index-' + x ) . attr ( 'fill' , this . theme_colors [ 'disabled' ] ) ;
720744 }
721745 }
722746 }
@@ -822,7 +846,7 @@ export class CircularHeatmapComponent implements OnInit {
822846 var colorSector = d3
823847 . scaleLinear < string , string > ( )
824848 . domain ( [ 0 , 1 ] )
825- . range ( [ 'white' , 'green' ] ) ;
849+ . range ( [ this . theme_colors [ 'background' ] , this . theme_colors [ 'filled' ] ] ) ;
826850
827851 if ( cntAll !== 0 ) {
828852 this . ALL_CARD_DATA [ index ] [ 'Done%' ] = cntTrue / cntAll ;
@@ -833,7 +857,10 @@ export class CircularHeatmapComponent implements OnInit {
833857 } else {
834858 this . ALL_CARD_DATA [ index ] [ 'Done%' ] = - 1 ;
835859 // console.log(`${this.ALL_CARD_DATA[index].SubDimension} ${this.ALL_CARD_DATA[index].Level} None`);
836- d3 . select ( '#index-' + index ) . attr ( 'fill' , '#DCDCDC' ) ;
860+ d3 . select ( '#index-' + index ) . attr (
861+ 'fill' ,
862+ this . theme_colors [ 'disabled' ]
863+ ) ;
837864 }
838865 }
839866 }
0 commit comments