MCPcopy Create free account
hub / github.com/chartjs/Chart.js / coverAlignedText

Function coverAlignedText

src/plugins/plugin.legend.ts:197–201  ·  view source on GitHub ↗

* Widen and move the hit box of a vertical legend item so that it covers the * symbol and the aligned text, then mirror it for right-to-left. * @param placement - what every item shares * @param hitbox - the item's hit box * @param textAlign - the alignment of the item's text * @param x - the l

({layout: {font, boxWidth}, rtlHelper}: ItemPlacement, hitbox: LegendHitBox, textAlign: TextAlign, x: number, right: number)

Source from the content-addressed store, hash-verified

195 * @param right - the right end of the item's text area, before mirroring
196 */
197function coverAlignedText({layout: {font, boxWidth}, rtlHelper}: ItemPlacement, hitbox: LegendHitBox, textAlign: TextAlign, x: number, right: number) {
198 const aligned = getAlignedHitBox(x, hitbox._text.width, boxWidth, font.size, textAlign, right);
199 hitbox.width = aligned.width;
200 hitbox.left = rtlHelper.leftForLtr(rtlHelper.x(aligned.left), hitbox.width);
201}
202export class Legend extends Element<AnyObject, LegendOpts> implements LayoutItem {
203
204 _added: boolean;

Callers 1

adjustHitBoxesMethod · 0.85

Calls 3

getAlignedHitBoxFunction · 0.85
leftForLtrMethod · 0.80
xMethod · 0.80

Tested by

no test coverage detected