Skip to content

Commit ab70b68

Browse files
committed
use Math.hypot
1 parent e7b0ca3 commit ab70b68

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/types/doughnutLabel.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,9 @@ function getControllerMeta({chartArea}, options, meta) {
154154
};
155155
}
156156

157-
function getFitRatio({width, height}, radius) {
158-
const hypo = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
159-
return (radius * 2) / hypo;
160-
}
157+
function getFitRatio({width, height}, radius) {
158+
return (radius * 2) / Math.hypot(width, height);
159+
}
161160

162161
function getAngles(y, centerX, centerY, radius) {
163162
const yk2 = Math.pow(centerY - y, 2);

0 commit comments

Comments
 (0)