Skip to content

Commit cb5cb23

Browse files
authored
Fix center coordinates calculation for point and polygon annotations (#851)
1 parent 7f41a7a commit cb5cb23

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

src/helpers/helpers.chart.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,15 @@ export function resolvePointProperties(chart, options) {
137137
options.radius = radius;
138138
}
139139
const size = radius * 2;
140+
const adjustCenterX = box.centerX + options.xAdjust;
141+
const adjustCenterY = box.centerY + options.yAdjust;
140142
return {
141-
x: box.x + options.xAdjust,
142-
y: box.y + options.yAdjust,
143-
x2: box.x + size + options.xAdjust,
144-
y2: box.y + size + options.yAdjust,
145-
centerX: box.centerX + options.xAdjust,
146-
centerY: box.centerY + options.yAdjust,
143+
x: adjustCenterX - radius,
144+
y: adjustCenterY - radius,
145+
x2: adjustCenterX + radius,
146+
y2: adjustCenterY + radius,
147+
centerX: adjustCenterX,
148+
centerY: adjustCenterY,
147149
width: size,
148150
height: size
149151
};

test/fixtures/point/hooks.png

363 Bytes
Loading

test/fixtures/polygon/hooks.png

-75 Bytes
Loading

0 commit comments

Comments
 (0)