Skip to content

Commit

Permalink
add drawPointLegend to keep drawPoint signature
Browse files Browse the repository at this point in the history
  • Loading branch information
touletan committed Jul 10, 2022
1 parent f469966 commit 6572b8e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/helpers/helpers.canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ export function clearCanvas(canvas, ctx) {
ctx.restore();
}

export function drawPoint(ctx, options, x, y, w) {
export function drawPoint(ctx, options, x, y) {
drawPointLegend(ctx, options, x, y, null);
}

export function drawPointLegend(ctx, options, x, y, w) {
let type, xOffset, yOffset, size, cornerRadius, width;
const style = options.pointStyle;
const rotation = options.rotation;
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/plugin.legend.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import defaults from '../core/core.defaults';
import Element from '../core/core.element';
import layouts from '../core/core.layouts';
import {addRoundedRectPath, drawPoint, renderText} from '../helpers/helpers.canvas';
import {addRoundedRectPath, drawPointLegend, renderText} from '../helpers/helpers.canvas';
import {
callback as call, valueOrDefault, toFont,
toPadding, getRtlAdapter, overrideTextDirection, restoreTextDirection,
Expand Down Expand Up @@ -325,7 +325,7 @@ export class Legend extends Element {
const centerY = y + halfFontSize;

// Draw pointStyle as legend symbol
drawPoint(ctx, drawOptions, centerX, centerY, boxWidth);
drawPointLegend(ctx, drawOptions, centerX, centerY, boxWidth);
} else {
// Draw box as legend symbol
// Adjust position when boxHeight < fontSize (want it centered)
Expand Down
2 changes: 2 additions & 0 deletions types/helpers/helpers.canvas.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ export interface DrawPointOptions {

export function drawPoint(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number): void;

export function drawPointLegend(ctx: CanvasRenderingContext2D, options: DrawPointOptions, x: number, y: number, w: number): void;

/**
* Converts the given font object into a CSS font string.
* @param font a font object
Expand Down

0 comments on commit 6572b8e

Please sign in to comment.