]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Radial: min 1/2 of the max radius as chartArea (#8630)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Sat, 13 Mar 2021 18:47:21 +0000 (20:47 +0200)
committerGitHub <noreply@github.com>
Sat, 13 Mar 2021 18:47:21 +0000 (13:47 -0500)
* Radial: min 1/2 of the max radius as chartArea

* Keep fooling TS

src/scales/scale.radialLinear.js
test/fixtures/scale.radialLinear/pointLabels/no-more-than-half-radius.js [new file with mode: 0644]
test/fixtures/scale.radialLinear/pointLabels/no-more-than-half-radius.png [new file with mode: 0644]

index f6d9270b9798f0dd7495bb4f34e8dd46128658d0..298717aaf236fee2897abc8e3a8e22d813c47498 100644 (file)
@@ -348,9 +348,9 @@ export default class RadialLinearScale extends LinearScaleBase {
     radiusReductionTop = numberOrZero(radiusReductionTop);
     radiusReductionBottom = numberOrZero(radiusReductionBottom);
 
-    me.drawingArea = Math.min(
+    me.drawingArea = Math.max(largestPossibleRadius / 2, Math.min(
       Math.floor(largestPossibleRadius - (radiusReductionLeft + radiusReductionRight) / 2),
-      Math.floor(largestPossibleRadius - (radiusReductionTop + radiusReductionBottom) / 2));
+      Math.floor(largestPossibleRadius - (radiusReductionTop + radiusReductionBottom) / 2)));
     me.setCenterPoint(radiusReductionLeft, radiusReductionRight, radiusReductionTop, radiusReductionBottom);
   }
 
diff --git a/test/fixtures/scale.radialLinear/pointLabels/no-more-than-half-radius.js b/test/fixtures/scale.radialLinear/pointLabels/no-more-than-half-radius.js
new file mode 100644 (file)
index 0000000..cddd436
--- /dev/null
@@ -0,0 +1,34 @@
+module.exports = {
+  config: {
+    type: 'radar',
+    data: {
+      labels: ['Too long label 1', 'Too long label 2', 'Too long label 3', 'Too long label 4'],
+      datasets: [
+        {
+          backgroundColor: '#E43E51',
+          data: [1, 1, 1, 1]
+        }
+      ]
+    },
+    options: {
+      scales: {
+        r: {
+          max: 1,
+          ticks: {
+            display: false,
+          },
+          grid: {
+            display: false
+          }
+        }
+      },
+    }
+  },
+  options: {
+    spriteText: true,
+    canvas: {
+      width: 256,
+      height: 256
+    }
+  }
+};
diff --git a/test/fixtures/scale.radialLinear/pointLabels/no-more-than-half-radius.png b/test/fixtures/scale.radialLinear/pointLabels/no-more-than-half-radius.png
new file mode 100644 (file)
index 0000000..522292e
Binary files /dev/null and b/test/fixtures/scale.radialLinear/pointLabels/no-more-than-half-radius.png differ