From 3fea7c113fad98b92b257fdd0b98c43fd7f03bd2 Mon Sep 17 00:00:00 2001 From: Corentin Pillet Date: Thu, 15 Sep 2022 11:14:09 +0200 Subject: [PATCH] fix: Fixing issue with calculation --- src/custom-defaults.js | 2 +- src/plugin.js | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/custom-defaults.js b/src/custom-defaults.js index 66afced..807b6b3 100644 --- a/src/custom-defaults.js +++ b/src/custom-defaults.js @@ -149,7 +149,7 @@ export default { * @member {Number} * @default 50 (%) */ - maxZoomOutPercentage: 50, + maxZoomOutPercentage: 60, /** * The count of numbers after the point separator for float values of percent property diff --git a/src/plugin.js b/src/plugin.js index b78a64c..7ef3e5a 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -48,8 +48,8 @@ export default { } outlabelPlugin.update(el, elements, index); - const x = outlabelPlugin.labelRect.x + (!outlabelPlugin.labelRect.isLeft ? 0 : outlabelPlugin.labelRect.width); - const y = outlabelPlugin.labelRect.y + (outlabelPlugin.labelRect.isTop ? 0 : outlabelPlugin.labelRect.height); + const x = outlabelPlugin.labelRect.x - (!outlabelPlugin.labelRect.isLeft ? 0 : outlabelPlugin.labelRect.width); + const y = outlabelPlugin.labelRect.y - (outlabelPlugin.labelRect.isTop ? 0 : outlabelPlugin.labelRect.height); if (x < rect.x1) { rect.x1 = x; } @@ -71,7 +71,8 @@ export default { rect.x2 - chart.chartArea.right, rect.y2 - chart.chartArea.bottom ]; - const diff = Math.max(...maxDeltas.filter(x => x > 0), 0); + let diff = Math.max(...maxDeltas.filter(x => x > 0)); + diff = Math.abs(diff) === Infinity ? 0 : diff; const percent = diff * 100 / ctrl.outerRadius; ctrl.outerRadius -= percent < max ? diff : max * 100 / ctrl.outerRadius; ctrl.innerRadius = ctrl.outerRadius / 2;