@@ -109,6 +109,24 @@ function getXAxisLabelMap(data: _Value[]): { [x: string]: string } {
109109 return result
110110}
111111
112+ const titleText = ( totalHours : number ) => t ( msg => totalHours
113+ ? msg . dashboard . heatMap . title0
114+ : msg . dashboard . heatMap . title1 ,
115+ { hour : totalHours }
116+ )
117+
118+ type HeatmapItem = HeatmapSeriesOption [ "data" ] [ number ]
119+
120+ const cvtHeatmapItem = ( d : _Value ) : HeatmapItem => {
121+ let item : HeatmapItem = { value : d , itemStyle : undefined , label : undefined , emphasis : undefined }
122+ const minutes = d [ 2 ]
123+ if ( ! minutes ) {
124+ item . itemStyle = { color : 'transparent' }
125+ item . emphasis = { disabled : true }
126+ }
127+ return item
128+ }
129+
112130function optionOf ( data : _Value [ ] , days : string [ ] ) : EcOption {
113131 const totalMinutes = data . map ( d => d [ 2 ] || 0 ) . reduce ( ( a , b ) => a + b , 0 )
114132 const totalHours = Math . floor ( totalMinutes / 60 )
@@ -117,15 +135,8 @@ function optionOf(data: _Value[], days: string[]): EcOption {
117135 return {
118136 title : {
119137 ...BASE_TITLE_OPTION ,
120- text : t ( msg => totalHours
121- ? msg . dashboard . heatMap . title0
122- : msg . dashboard . heatMap . title1 ,
123- { hour : totalHours }
124- ) ,
125- textStyle : {
126- fontSize : '14px' ,
127- color : textColor
128- }
138+ text : titleText ( totalHours ) ,
139+ textStyle : { fontSize : '14px' , color : textColor }
129140 } ,
130141 tooltip : {
131142 position : 'top' ,
@@ -145,16 +156,13 @@ function optionOf(data: _Value[], days: string[]): EcOption {
145156 formatter : ( x : string ) => xAxisLabelMap [ x ] || '' ,
146157 interval : 0 ,
147158 margin : 14 ,
148- color : textColor
159+ color : textColor ,
149160 } ,
150161 } ,
151162 yAxis : {
152163 type : 'category' ,
153164 data : days ,
154- axisLabel : {
155- padding : /* T R B L */ [ 0 , 12 , 0 , 0 ] ,
156- color : textColor
157- } ,
165+ axisLabel : { padding : /* T R B L */ [ 0 , 12 , 0 , 0 ] , color : textColor } ,
158166 axisLine : { show : false } ,
159167 axisTick : { show : false , alignWithLabel : true }
160168 } ,
@@ -168,28 +176,12 @@ function optionOf(data: _Value[], days: string[]): EcOption {
168176 right : '2%' ,
169177 top : 'center' ,
170178 dimension : 2 ,
171- textStyle : {
172- color : textColor
173- }
179+ textStyle : { color : textColor }
174180 } ] ,
175181 series : [ {
176182 name : 'Daily Focus' ,
177183 type : 'heatmap' ,
178- data : data . map ( d => {
179- let item = { value : d , itemStyle : undefined , label : undefined , emphasis : undefined , tooltip : undefined , silent : false }
180- const minutes = d [ 2 ]
181- if ( minutes ) {
182- } else {
183- item . itemStyle = {
184- color : 'transparent' ,
185- }
186- item . emphasis = {
187- disabled : true
188- }
189- item . silent = true
190- }
191- return item
192- } ) ,
184+ data : data . map ( cvtHeatmapItem ) ,
193185 progressive : 5 ,
194186 progressiveThreshold : 10 ,
195187 } ]
0 commit comments