File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -412,17 +412,21 @@ export interface Box {
412412export function labelBox ( n : PlacedNode ) : Box | null {
413413 const cajas : Box [ ] = [ ]
414414
415+ // El texto crece hacia la izquierda cuando va alineado al final.
416+ const horizontal = ( w : number ) : { x1 : number ; x2 : number } =>
417+ n . labelAlign === 'end' ? { x1 : n . labelX - w , x2 : n . labelX } : { x1 : n . labelX - w / 2 , x2 : n . labelX + w / 2 }
418+
415419 if ( n . outside && n . lines . length > 0 ) {
416420 const w = Math . max ( ...n . lines . map ( ( l ) => l . length ) ) * CHAR_W + 6
417421 const h = n . lines . length * LINE_H + 4
418422 const y1 = n . labelAbove ? n . cy - n . h / 2 - 6 - h : n . cy + n . h / 2 + 4
419- cajas . push ( { x1 : n . cx - w / 2 , x2 : n . cx + w / 2 , y1, y2 : y1 + h } )
423+ cajas . push ( { ... horizontal ( w ) , y1, y2 : y1 + h } )
420424 }
421425
422426 if ( n . duracion ) {
423427 const w = n . duracion . length * CHAR_W + 10
424428 const y1 = duracionY ( n ) - 9
425- cajas . push ( { x1 : n . cx - w / 2 , x2 : n . cx + w / 2 , y1, y2 : y1 + 15 } )
429+ cajas . push ( { ... horizontal ( w ) , y1, y2 : y1 + 15 } )
426430 }
427431
428432 if ( cajas . length === 0 ) return null
You can’t perform that action at this time.
0 commit comments