MCPcopy
hub / github.com/chartjs/Chart.js / drawPointLabelBox

Function drawPointLabelBox

src/scales/scale.radialLinear.js:231–259  ·  view source on GitHub ↗
(ctx, opts, item)

Source from the content-addressed store, hash-verified

229}
230
231function drawPointLabelBox(ctx, opts, item) {
232 const {left, top, right, bottom} = item;
233 const {backdropColor} = opts;
234
235 if (!isNullOrUndef(backdropColor)) {
236 const borderRadius = toTRBLCorners(opts.borderRadius);
237 const padding = toPadding(opts.backdropPadding);
238 ctx.fillStyle = backdropColor;
239
240 const backdropLeft = left - padding.left;
241 const backdropTop = top - padding.top;
242 const backdropWidth = right - left + padding.width;
243 const backdropHeight = bottom - top + padding.height;
244
245 if (Object.values(borderRadius).some(v => v !== 0)) {
246 ctx.beginPath();
247 addRoundedRectPath(ctx, {
248 x: backdropLeft,
249 y: backdropTop,
250 w: backdropWidth,
251 h: backdropHeight,
252 radius: borderRadius,
253 });
254 ctx.fill();
255 } else {
256 ctx.fillRect(backdropLeft, backdropTop, backdropWidth, backdropHeight);
257 }
258 }
259}
260
261function drawPointLabels(scale, labelCount) {
262 const {ctx, options: {pointLabels}} = scale;

Callers 1

drawPointLabelsFunction · 0.85

Calls 4

isNullOrUndefFunction · 0.85
toTRBLCornersFunction · 0.85
toPaddingFunction · 0.85
addRoundedRectPathFunction · 0.85

Tested by

no test coverage detected