Skip to content

Commit

Permalink
Drawing text async in TLegend entries
Browse files Browse the repository at this point in the history
  • Loading branch information
linev committed Sep 26, 2024
1 parent 61b9477 commit f76ad1d
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions modules/hist/TPavePainter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -786,21 +786,19 @@ class TPavePainter extends ObjectPainter {
pos_x = x0 + padding_x;

if (entry.fLabel) {
let lbl_g = this.draw_g;
const textatt = this.createAttText({ attr: entry, std: false, attr_alt: legend });
const textatt = this.createAttText({ attr: entry, std: false, attr_alt: legend }),
arg = { draw_g: this.draw_g, align: textatt.align, x: pos_x, y: pos_y,
scale: (custom_textg && !entry.fTextSize) || !legend.fTextSize,
width: x0+column_width-pos_x-padding_x, height: step_y,
text: entry.fLabel, color: textatt.color };
if (custom_textg) {
lbl_g = this.draw_g.append('svg:g');
const entry_font_size = textatt.getSize(pp.getPadHeight());
this.startTextDrawing(textatt.font, entry_font_size, lbl_g, max_font_size);
arg.draw_g = this.draw_g.append('svg:g');
text_promises.push(this.startTextDrawingAsync(textatt.font, textatt.getSize(pp.getPadHeight()), arg.draw_g, max_font_size)
.then(() => this.drawText(arg))
.then(() => this.finishTextDrawing(arg.draw_g)));
} else {
this.drawText(arg);
}

this.drawText({ draw_g: lbl_g, align: textatt.align, x: pos_x, y: pos_y,
scale: (custom_textg && !entry.fTextSize) || !legend.fTextSize,
width: x0+column_width-pos_x-padding_x, height: step_y,
text: entry.fLabel, color: textatt.color });

if (custom_textg)
text_promises.push(this.finishTextDrawing(lbl_g));
}
}

Expand Down

0 comments on commit f76ad1d

Please sign in to comment.