Invalid center coordinates when a point/polygon annotation is configured using x/yMin and y/xMax
stockiNail opened this issue · 0 comments
stockiNail commented
When a point/polygon annotation is configured using x/yMin and y/xMax, the calculated centerX and centerY are wrong because the center point of result box is used. This is correct only if the box is a square.
chartjs-plugin-annotation/src/helpers/helpers.chart.js
Lines 140 to 149 in 76ba0e9
To use the center point of the box, it should be:
const adjustCenterX = box.centerX + options.xAdjust;
const adjustCenterY = box.centerY + options.yAdjust;
return {
x: adjustCenterX - radius,
y: adjustCenterY - radius,
x2: adjustCenterX + radius,
y2: adjustCenterY + radius,
centerX: adjustCenterX,
centerY: adjustCenterY,
width: size,
height: size
};