]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Limit Math.asin inputs to the range [-1, 1] (#9410)
authorEvert Timberg <evert.timberg+github@gmail.com>
Wed, 14 Jul 2021 06:14:29 +0000 (02:14 -0400)
committerGitHub <noreply@github.com>
Wed, 14 Jul 2021 06:14:29 +0000 (09:14 +0300)
src/core/core.scale.js

index b6113f794b76d9b8361e496925a916e04ea69e07..25c4b0ebe2ce86ebe7af9dd17d3faf8341984a0a 100644 (file)
@@ -593,8 +593,8 @@ export default class Scale extends Element {
                                - tickOpts.padding - getTitleHeight(options.title, me.chart.options.font);
       maxLabelDiagonal = Math.sqrt(maxLabelWidth * maxLabelWidth + maxLabelHeight * maxLabelHeight);
       labelRotation = toDegrees(Math.min(
-        Math.asin(Math.min((labelSizes.highest.height + 6) / tickWidth, 1)),
-        Math.asin(Math.min(maxHeight / maxLabelDiagonal, 1)) - Math.asin(maxLabelHeight / maxLabelDiagonal)
+        Math.asin(_limitValue((labelSizes.highest.height + 6) / tickWidth, -1, 1)),
+        Math.asin(_limitValue(maxHeight / maxLabelDiagonal, -1, 1)) - Math.asin(_limitValue(maxLabelHeight / maxLabelDiagonal, -1, 1))
       ));
       labelRotation = Math.max(minRotation, Math.min(maxRotation, labelRotation));
     }