@@ -163,6 +163,8 @@ function render_pipeline_graph() {
163163 unitCount . set ( unit . name , count + 1 ) ;
164164 }
165165
166+ const presentSections = new Set ( ) ;
167+
166168 // Draw the blocks.
167169 for ( i = 0 ; i < units . length ; i ++ ) {
168170 let unit = units [ i ] ;
@@ -180,6 +182,7 @@ function render_pipeline_graph() {
180182 ctx . fillStyle = get_section_color ( section . name ) ;
181183 roundedRect ( ctx , section . start , y , section . width , BOX_HEIGHT , RADIUS ) ;
182184 ctx . fill ( ) ;
185+ presentSections . add ( section . name ) ;
183186 }
184187 ctx . fillStyle = TEXT_COLOR ;
185188 ctx . textAlign = 'start' ;
@@ -195,6 +198,32 @@ function render_pipeline_graph() {
195198 draw_dep_lines ( ctx , unit . i , false ) ;
196199 }
197200 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 ( ) ;
198227}
199228
200229// Draw a legend at the current position of the ctx.
@@ -206,7 +235,9 @@ function render_pipeline_graph() {
206235// }
207236function draw_legend ( ctx , width , entries ) {
208237 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 ;
210241
211242 // Draw background
212243 ctx . fillStyle = BG_COLOR ;
@@ -231,7 +262,7 @@ function draw_legend(ctx, width, entries) {
231262 const mark_width = 45 ;
232263
233264 // Draw legend entries
234- let y = 10 ;
265+ let y = 12 ;
235266 for ( const entry of entries ) {
236267 ctx . beginPath ( ) ;
237268
0 commit comments