@@ -163,6 +163,8 @@ function render_pipeline_graph() {
163
163
unitCount . set ( unit . name , count + 1 ) ;
164
164
}
165
165
166
+ const presentSections = new Set ( ) ;
167
+
166
168
// Draw the blocks.
167
169
for ( i = 0 ; i < units . length ; i ++ ) {
168
170
let unit = units [ i ] ;
@@ -180,6 +182,7 @@ function render_pipeline_graph() {
180
182
ctx . fillStyle = get_section_color ( section . name ) ;
181
183
roundedRect ( ctx , section . start , y , section . width , BOX_HEIGHT , RADIUS ) ;
182
184
ctx . fill ( ) ;
185
+ presentSections . add ( section . name ) ;
183
186
}
184
187
ctx . fillStyle = TEXT_COLOR ;
185
188
ctx . textAlign = 'start' ;
@@ -195,6 +198,32 @@ function render_pipeline_graph() {
195
198
draw_dep_lines ( ctx , unit . i , false ) ;
196
199
}
197
200
ctx . restore ( ) ;
201
+
202
+ // Draw a legend.
203
+ ctx . save ( ) ;
204
+ ctx . translate ( canvas_width - 200 , MARGIN ) ;
205
+
206
+ const legend_entries = [ {
207
+ name : "Frontend/rest" ,
208
+ color : NOT_CUSTOM_BUILD_COLOR ,
209
+ line : false
210
+ } ] ;
211
+ if ( presentSections . has ( "codegen" ) ) {
212
+ legend_entries . push ( {
213
+ name : "Codegen" ,
214
+ color : CODEGEN_COLOR ,
215
+ line : false
216
+ } ) ;
217
+ }
218
+ if ( presentSections . has ( "link" ) ) {
219
+ legend_entries . push ( {
220
+ name : "Linking" ,
221
+ color : LINK_COLOR ,
222
+ line : false
223
+ } ) ;
224
+ }
225
+ draw_legend ( ctx , 160 , legend_entries ) ;
226
+ ctx . restore ( ) ;
198
227
}
199
228
200
229
// Draw a legend at the current position of the ctx.
@@ -206,7 +235,9 @@ function render_pipeline_graph() {
206
235
// }
207
236
function draw_legend ( ctx , width , entries ) {
208
237
const entry_height = 20 ;
209
- const height = entries . length * entry_height + 2 ; // Add a bit of margin to the bottom
238
+
239
+ // Add a bit of margin to the bottom and top
240
+ const height = entries . length * entry_height + 4 ;
210
241
211
242
// Draw background
212
243
ctx . fillStyle = BG_COLOR ;
@@ -231,7 +262,7 @@ function draw_legend(ctx, width, entries) {
231
262
const mark_width = 45 ;
232
263
233
264
// Draw legend entries
234
- let y = 10 ;
265
+ let y = 12 ;
235
266
for ( const entry of entries ) {
236
267
ctx . beginPath ( ) ;
237
268
0 commit comments