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

Function getAlignedHitBox

src/plugins/plugin.legend.ts:129–135  ·  view source on GitHub ↗
(x: number, textWidth: number, boxWidth: number, fontSize: number, textAlign: TextAlign, right: number)

Source from the content-addressed store, hash-verified

127const itemsEqual = (a: LegendItem | null, b: LegendItem | null) => a !== null && b !== null && a.datasetIndex === b.datasetIndex && a.index === b.index;
128
129function getAlignedHitBox(x: number, textWidth: number, boxWidth: number, fontSize: number, textAlign: TextAlign, right: number) {
130 const textX = _textX(textAlign, x + boxWidth + fontSize / 2, right, false);
131 const textLeft = textX - (textAlign === 'center' ? textWidth / 2 : textAlign === 'right' ? textWidth : 0);
132 const left = Math.min(x, textLeft);
133 // Cover both the symbol and the aligned text in LTR coordinates.
134 return {left, width: Math.max(x + boxWidth, textLeft + textWidth) - left};
135}
136
137/**
138 * The text alignment of an item: its own, or else the labels' one, which is

Callers 1

coverAlignedTextFunction · 0.85

Calls 1

_textXFunction · 0.85

Tested by

no test coverage detected