From 6cf9de968194259922328c99acfa84a8c2508276 Mon Sep 17 00:00:00 2001 From: leo2436 <58366762+leo2436@users.noreply.github.com> Date: Mon, 13 Feb 2023 03:15:07 +0800 Subject: [PATCH] Change labelColors to labelColor in tooltip drawColorBox method. (#11135) Co-authored-by: Leo Chen --- src/plugins/plugin.tooltip.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/plugins/plugin.tooltip.js b/src/plugins/plugin.tooltip.js index c11c11b54fb..2e881417f78 100644 --- a/src/plugins/plugin.tooltip.js +++ b/src/plugins/plugin.tooltip.js @@ -780,7 +780,7 @@ export class Tooltip extends Element { * @private */ _drawColorBox(ctx, pt, i, rtlHelper, options) { - const labelColors = this.labelColors[i]; + const labelColor = this.labelColors[i]; const labelPointStyle = this.labelPointStyles[i]; const {boxHeight, boxWidth} = options; const bodyFont = toFont(options.bodyFont); @@ -807,20 +807,20 @@ export class Tooltip extends Element { drawPoint(ctx, drawOptions, centerX, centerY); // Draw the point - ctx.strokeStyle = labelColors.borderColor; - ctx.fillStyle = labelColors.backgroundColor; + ctx.strokeStyle = labelColor.borderColor; + ctx.fillStyle = labelColor.backgroundColor; drawPoint(ctx, drawOptions, centerX, centerY); } else { // Border - ctx.lineWidth = isObject(labelColors.borderWidth) ? Math.max(...Object.values(labelColors.borderWidth)) : (labelColors.borderWidth || 1); // TODO, v4 remove fallback - ctx.strokeStyle = labelColors.borderColor; - ctx.setLineDash(labelColors.borderDash || []); - ctx.lineDashOffset = labelColors.borderDashOffset || 0; + ctx.lineWidth = isObject(labelColor.borderWidth) ? Math.max(...Object.values(labelColor.borderWidth)) : (labelColor.borderWidth || 1); // TODO, v4 remove fallback + ctx.strokeStyle = labelColor.borderColor; + ctx.setLineDash(labelColor.borderDash || []); + ctx.lineDashOffset = labelColor.borderDashOffset || 0; // Fill a white rect so that colours merge nicely if the opacity is < 1 const outerX = rtlHelper.leftForLtr(rtlColorX, boxWidth); const innerX = rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - 2); - const borderRadius = toTRBLCorners(labelColors.borderRadius); + const borderRadius = toTRBLCorners(labelColor.borderRadius); if (Object.values(borderRadius).some(v => v !== 0)) { ctx.beginPath(); @@ -836,7 +836,7 @@ export class Tooltip extends Element { ctx.stroke(); // Inner square - ctx.fillStyle = labelColors.backgroundColor; + ctx.fillStyle = labelColor.backgroundColor; ctx.beginPath(); addRoundedRectPath(ctx, { x: innerX, @@ -852,7 +852,7 @@ export class Tooltip extends Element { ctx.fillRect(outerX, colorY, boxWidth, boxHeight); ctx.strokeRect(outerX, colorY, boxWidth, boxHeight); // Inner square - ctx.fillStyle = labelColors.backgroundColor; + ctx.fillStyle = labelColor.backgroundColor; ctx.fillRect(innerX, colorY + 1, boxWidth - 2, boxHeight - 2); } }