Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change labelColors to labelColor in tooltip drawColorBox method. #11135

Merged
merged 1 commit into from
Feb 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/plugins/plugin.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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,
Expand All @@ -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);
}
}
Expand Down