Skip to content

Commit

Permalink
Fix center coordinates calculation for point and polygon annotations (c…
Browse files Browse the repository at this point in the history
  • Loading branch information
stockiNail authored Feb 24, 2023
1 parent 7f41a7a commit cb5cb23
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/helpers/helpers.chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,15 @@ export function resolvePointProperties(chart, options) {
options.radius = radius;
}
const size = radius * 2;
const adjustCenterX = box.centerX + options.xAdjust;
const adjustCenterY = box.centerY + options.yAdjust;
return {
x: box.x + options.xAdjust,
y: box.y + options.yAdjust,
x2: box.x + size + options.xAdjust,
y2: box.y + size + options.yAdjust,
centerX: box.centerX + options.xAdjust,
centerY: box.centerY + options.yAdjust,
x: adjustCenterX - radius,
y: adjustCenterY - radius,
x2: adjustCenterX + radius,
y2: adjustCenterY + radius,
centerX: adjustCenterX,
centerY: adjustCenterY,
width: size,
height: size
};
Expand Down
Binary file modified test/fixtures/point/hooks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/fixtures/polygon/hooks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cb5cb23

Please sign in to comment.