Skip to content

Commit 6cf9de9

Browse files
leo2436leoChen1996
andauthored
Change labelColors to labelColor in tooltip drawColorBox method. (#11135)
Co-authored-by: Leo Chen <[email protected]>
1 parent e417c60 commit 6cf9de9

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/plugins/plugin.tooltip.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ export class Tooltip extends Element {
780780
* @private
781781
*/
782782
_drawColorBox(ctx, pt, i, rtlHelper, options) {
783-
const labelColors = this.labelColors[i];
783+
const labelColor = this.labelColors[i];
784784
const labelPointStyle = this.labelPointStyles[i];
785785
const {boxHeight, boxWidth} = options;
786786
const bodyFont = toFont(options.bodyFont);
@@ -807,20 +807,20 @@ export class Tooltip extends Element {
807807
drawPoint(ctx, drawOptions, centerX, centerY);
808808

809809
// Draw the point
810-
ctx.strokeStyle = labelColors.borderColor;
811-
ctx.fillStyle = labelColors.backgroundColor;
810+
ctx.strokeStyle = labelColor.borderColor;
811+
ctx.fillStyle = labelColor.backgroundColor;
812812
drawPoint(ctx, drawOptions, centerX, centerY);
813813
} else {
814814
// Border
815-
ctx.lineWidth = isObject(labelColors.borderWidth) ? Math.max(...Object.values(labelColors.borderWidth)) : (labelColors.borderWidth || 1); // TODO, v4 remove fallback
816-
ctx.strokeStyle = labelColors.borderColor;
817-
ctx.setLineDash(labelColors.borderDash || []);
818-
ctx.lineDashOffset = labelColors.borderDashOffset || 0;
815+
ctx.lineWidth = isObject(labelColor.borderWidth) ? Math.max(...Object.values(labelColor.borderWidth)) : (labelColor.borderWidth || 1); // TODO, v4 remove fallback
816+
ctx.strokeStyle = labelColor.borderColor;
817+
ctx.setLineDash(labelColor.borderDash || []);
818+
ctx.lineDashOffset = labelColor.borderDashOffset || 0;
819819

820820
// Fill a white rect so that colours merge nicely if the opacity is < 1
821821
const outerX = rtlHelper.leftForLtr(rtlColorX, boxWidth);
822822
const innerX = rtlHelper.leftForLtr(rtlHelper.xPlus(rtlColorX, 1), boxWidth - 2);
823-
const borderRadius = toTRBLCorners(labelColors.borderRadius);
823+
const borderRadius = toTRBLCorners(labelColor.borderRadius);
824824

825825
if (Object.values(borderRadius).some(v => v !== 0)) {
826826
ctx.beginPath();
@@ -836,7 +836,7 @@ export class Tooltip extends Element {
836836
ctx.stroke();
837837

838838
// Inner square
839-
ctx.fillStyle = labelColors.backgroundColor;
839+
ctx.fillStyle = labelColor.backgroundColor;
840840
ctx.beginPath();
841841
addRoundedRectPath(ctx, {
842842
x: innerX,
@@ -852,7 +852,7 @@ export class Tooltip extends Element {
852852
ctx.fillRect(outerX, colorY, boxWidth, boxHeight);
853853
ctx.strokeRect(outerX, colorY, boxWidth, boxHeight);
854854
// Inner square
855-
ctx.fillStyle = labelColors.backgroundColor;
855+
ctx.fillStyle = labelColor.backgroundColor;
856856
ctx.fillRect(innerX, colorY + 1, boxWidth - 2, boxHeight - 2);
857857
}
858858
}

0 commit comments

Comments
 (0)