From 64f330824a1686425678905544b2910c5151de8c Mon Sep 17 00:00:00 2001 From: Jacco van den Berg Date: Thu, 5 May 2022 20:56:00 +0200 Subject: [PATCH 1/3] give correct range back for polarArea --- src/controllers/controller.polarArea.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/controllers/controller.polarArea.js b/src/controllers/controller.polarArea.js index 92642a32fef..30db45df416 100644 --- a/src/controllers/controller.polarArea.js +++ b/src/controllers/controller.polarArea.js @@ -33,6 +33,30 @@ export default class PolarAreaController extends DatasetController { this.updateElements(arcs, 0, arcs.length, mode); } + /** + * @protected + */ + getMinMax() { + const meta = this._cachedMeta; + const range = {min: Number.POSITIVE_INFINITY, max: Number.NEGATIVE_INFINITY}; + + meta.data.forEach((element, index) => { + const parsed = this.getParsed(index).r; + + if (!isNaN(parsed) && this.chart.getDataVisibility(index)) { + if (parsed < range.min) { + range.min = parsed; + } + + if (parsed > range.max) { + range.max = parsed; + } + } + }); + + return range; + } + /** * @private */ From e3b926a03f30ed725df9d397603e85ffd5e0476c Mon Sep 17 00:00:00 2001 From: Jacco van den Berg Date: Thu, 5 May 2022 21:09:52 +0200 Subject: [PATCH 2/3] added test --- test/specs/controller.polarArea.tests.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/specs/controller.polarArea.tests.js b/test/specs/controller.polarArea.tests.js index 340c58413cd..a5266e21521 100644 --- a/test/specs/controller.polarArea.tests.js +++ b/test/specs/controller.polarArea.tests.js @@ -1,6 +1,24 @@ describe('Chart.controllers.polarArea', function() { describe('auto', jasmine.fixture.specs('controller.polarArea')); + it('should update the scale correctly when data visibility is changed', function() { + var expectedScaleMax = 1; + var chart = window.acquireChart({ + type: 'polarArea', + data: { + datasets: [ + {data: [100]} + ], + labels: ['x'] + } + }); + + chart.toggleDataVisibility(0); + chart.update(); + + expect(chart.scales.r.max).toBe(expectedScaleMax); + }); + it('should be registered as dataset controller', function() { expect(typeof Chart.controllers.polarArea).toBe('function'); }); From 4f5b6f653bdd9f9ecd3ea96787c56d63d6d4b1ce Mon Sep 17 00:00:00 2001 From: Jacco van den Berg <39033624+LeeLenaleee@users.noreply.github.com> Date: Fri, 6 May 2022 13:02:48 +0200 Subject: [PATCH 3/3] tab to spaces --- src/controllers/controller.polarArea.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/controller.polarArea.js b/src/controllers/controller.polarArea.js index 30db45df416..b717eca7c25 100644 --- a/src/controllers/controller.polarArea.js +++ b/src/controllers/controller.polarArea.js @@ -34,8 +34,8 @@ export default class PolarAreaController extends DatasetController { } /** - * @protected - */ + * @protected + */ getMinMax() { const meta = this._cachedMeta; const range = {min: Number.POSITIVE_INFINITY, max: Number.NEGATIVE_INFINITY};