@@ -38,6 +38,14 @@ export type Timing = Duration & {
38
38
* blocks.
39
39
*/
40
40
childrenCount : number ;
41
+ /**
42
+ * Timings should always be included in duration and timeline calculations.
43
+ * However, some timings, such as those for Coder resources, may not be
44
+ * valuable or can be too spammy to present to the user. Therefore, we hide
45
+ * these specific timings from the visualization while still including them in
46
+ * the calculations.
47
+ */
48
+ visible ?: boolean ;
41
49
color ?: BarColor ;
42
50
} ;
43
51
@@ -90,14 +98,16 @@ export const Chart: FC<ChartProps> = ({ data, onBarClick }) => {
90
98
< YAxisSection key = { section . name } >
91
99
< YAxisCaption > { section . name } </ YAxisCaption >
92
100
< YAxisLabels >
93
- { section . timings . map ( ( t ) => (
94
- < YAxisLabel
95
- key = { t . label }
96
- id = { `${ encodeURIComponent ( t . label ) } -label` }
97
- >
98
- { t . label }
99
- </ YAxisLabel >
100
- ) ) }
101
+ { section . timings
102
+ . filter ( ( t ) => t . visible )
103
+ . map ( ( t ) => (
104
+ < YAxisLabel
105
+ key = { t . label }
106
+ id = { `${ encodeURIComponent ( t . label ) } -label` }
107
+ >
108
+ { t . label }
109
+ </ YAxisLabel >
110
+ ) ) }
101
111
</ YAxisLabels >
102
112
</ YAxisSection >
103
113
) ;
@@ -110,33 +120,35 @@ export const Chart: FC<ChartProps> = ({ data, onBarClick }) => {
110
120
{ data . map ( ( section ) => {
111
121
return (
112
122
< div key = { section . name } css = { styles . bars } >
113
- { section . timings . map ( ( t ) => {
114
- const offset =
115
- t . startedAt . getTime ( ) - totalDuration . startedAt . getTime ( ) ;
116
- const size = calcSize ( durationTime ( t ) ) ;
117
- return (
118
- < Bar
119
- color = { t . color }
120
- key = { t . label }
121
- x = { calcSize ( offset ) }
122
- width = { size }
123
- afterLabel = { formatTime ( durationTime ( t ) ) }
124
- aria-labelledby = { `${ t . label } -label` }
125
- ref = { applyBarHeightToLabel }
126
- disabled = { t . childrenCount <= 1 }
127
- onClick = { ( ) => {
128
- if ( t . childrenCount <= 1 ) {
129
- return ;
130
- }
131
- onBarClick ( t . label , section . name ) ;
132
- } }
133
- >
134
- { t . childrenCount > 1 && (
135
- < TimingBlocks size = { size } count = { t . childrenCount } />
136
- ) }
137
- </ Bar >
138
- ) ;
139
- } ) }
123
+ { section . timings
124
+ . filter ( ( t ) => t . visible )
125
+ . map ( ( t ) => {
126
+ const offset =
127
+ t . startedAt . getTime ( ) - totalDuration . startedAt . getTime ( ) ;
128
+ const size = calcSize ( durationTime ( t ) ) ;
129
+ return (
130
+ < Bar
131
+ color = { t . color }
132
+ key = { t . label }
133
+ x = { calcSize ( offset ) }
134
+ width = { size }
135
+ afterLabel = { formatTime ( durationTime ( t ) ) }
136
+ aria-labelledby = { `${ t . label } -label` }
137
+ ref = { applyBarHeightToLabel }
138
+ disabled = { t . childrenCount <= 1 }
139
+ onClick = { ( ) => {
140
+ if ( t . childrenCount <= 1 ) {
141
+ return ;
142
+ }
143
+ onBarClick ( t . label , section . name ) ;
144
+ } }
145
+ >
146
+ { t . childrenCount > 1 && (
147
+ < TimingBlocks size = { size } count = { t . childrenCount } />
148
+ ) }
149
+ </ Bar >
150
+ ) ;
151
+ } ) }
140
152
</ div >
141
153
) ;
142
154
} ) }
0 commit comments