Skip to content

Commit

Permalink
fix drawPoints parameter (#6975)
Browse files Browse the repository at this point in the history
  • Loading branch information
touletan authored and etimberg committed Jan 18, 2020
1 parent fac5078 commit 95345d0
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/plugins/plugin.legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,17 @@ class Legend extends Element {
if (labelOpts && labelOpts.usePointStyle) {
// Recalculate x and y for drawPoint() because its expecting
// x and y to be center of figure (instead of top left)
var radius = boxWidth * Math.SQRT2 / 2;
const drawOptions = {
radius: boxWidth * Math.SQRT2 / 2,
pointStyle: legendItem.pointStyle,
rotation: legendItem.rotation,
borderWidth: lineWidth
};
var centerX = rtlHelper.xPlus(x, boxWidth / 2);
var centerY = y + fontSize / 2;

// Draw pointStyle as legend symbol
helpers.canvas.drawPoint(ctx, legendItem.pointStyle, radius, centerX, centerY, legendItem.rotation);
helpers.canvas.drawPoint(ctx, drawOptions, centerX, centerY);
} else {
// Draw box as legend symbol
ctx.fillRect(rtlHelper.leftForLtr(x, boxWidth), y, boxWidth, fontSize);
Expand Down

0 comments on commit 95345d0

Please sign in to comment.