]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Remove unused Element methods (#6694)
authorBen McCann <322311+benmccann@users.noreply.github.com>
Tue, 5 Nov 2019 23:09:44 +0000 (15:09 -0800)
committerEvert Timberg <evert.timberg+github@gmail.com>
Tue, 5 Nov 2019 23:09:44 +0000 (18:09 -0500)
docs/getting-started/v3-migration.md
src/elements/element.arc.js
src/elements/element.point.js
src/elements/element.rectangle.js
test/specs/element.arc.tests.js
test/specs/element.point.tests.js
test/specs/element.rectangle.tests.js

index 04dfa426eee51b78c64eeb5b00898e1aa0e8b2d1..41d1bfd2092e9fa1cacf1d17ff842f380af37c8d 100644 (file)
@@ -53,13 +53,16 @@ Chart.js is no longer providing the `Chart.bundle.js` and `Chart.bundle.min.js`.
 * `helpers.numberOfLabelLines`
 * `helpers.removeEvent`
 * `helpers.scaleMerge`
-* `scale.getRightValue`
-* `scale.mergeTicksOptions`
-* `scale.ticksAsNumbers`
+* `Scale.getRightValue`
+* `Scale.mergeTicksOptions`
+* `Scale.ticksAsNumbers`
 * `Chart.Controller`
 * `Chart.chart.chart`
 * `Chart.types`
 * `Line.calculatePointY`
+* `Element.getArea`
+* `Element.height`
+* `Element.inLabelRange`
 * Made `scale.handleDirectionalChanges` private
 * Made `scale.tickValues` private
 
index 84b5e633541beb0bdf590b8c9fb2bd2f5f727148..d5d9fbf158ca42c20e4af4285907d4ef7473c84f 100644 (file)
@@ -94,15 +94,6 @@ function drawBorder(ctx, vm, arc) {
 module.exports = Element.extend({
        _type: 'arc',
 
-       inLabelRange: function(mouseX) {
-               var vm = this._view;
-
-               if (vm) {
-                       return (Math.pow(mouseX - vm.x, 2) < Math.pow(vm.radius + vm.hoverRadius, 2));
-               }
-               return false;
-       },
-
        inRange: function(chartX, chartY) {
                var vm = this._view;
 
@@ -143,11 +134,6 @@ module.exports = Element.extend({
                };
        },
 
-       getArea: function() {
-               var vm = this._view;
-               return Math.PI * ((vm.endAngle - vm.startAngle) / (2 * Math.PI)) * (Math.pow(vm.outerRadius, 2) - Math.pow(vm.innerRadius, 2));
-       },
-
        tooltipPosition: function() {
                var vm = this._view;
                var centreAngle = vm.startAngle + ((vm.endAngle - vm.startAngle) / 2);
index dc020c86a064451e40ac23b277ce0b62194ac35c..226ed06c04df30686fa7aa795cb3986f2d857953 100644 (file)
@@ -42,7 +42,6 @@ module.exports = Element.extend({
                return vm ? ((Math.pow(mouseX - vm.x, 2) + Math.pow(mouseY - vm.y, 2)) < Math.pow(vm.hitRadius + vm.radius, 2)) : false;
        },
 
-       inLabelRange: xRange,
        inXRange: xRange,
        inYRange: yRange,
 
@@ -54,10 +53,6 @@ module.exports = Element.extend({
                };
        },
 
-       getArea: function() {
-               return Math.PI * Math.pow(this._view.radius, 2);
-       },
-
        tooltipPosition: function() {
                var vm = this._view;
                return {
index 254d77514cb59e5e355a878727f81681638c4534..1e08df12c13df859c142d72b7f6ab8b2716bc51a 100644 (file)
@@ -157,22 +157,10 @@ module.exports = Element.extend({
                ctx.restore();
        },
 
-       height: function() {
-               var vm = this._view;
-               return vm.base - vm.y;
-       },
-
        inRange: function(mouseX, mouseY) {
                return inRange(this._view, mouseX, mouseY);
        },
 
-       inLabelRange: function(mouseX, mouseY) {
-               var vm = this._view;
-               return isVertical(vm)
-                       ? inRange(vm, mouseX, null)
-                       : inRange(vm, null, mouseY);
-       },
-
        inXRange: function(mouseX) {
                return inRange(this._view, mouseX, null);
        },
@@ -195,14 +183,6 @@ module.exports = Element.extend({
                return {x: x, y: y};
        },
 
-       getArea: function() {
-               var vm = this._view;
-
-               return isVertical(vm)
-                       ? vm.width * Math.abs(vm.y - vm.base)
-                       : vm.height * Math.abs(vm.x - vm.base);
-       },
-
        tooltipPosition: function() {
                var vm = this._view;
                return {
index 40d52533d5ec050ead3bcf3a4b0908bc65fac518..41c720d9b876b4cc13500dbf14b64be872246e9f 100644 (file)
@@ -18,10 +18,6 @@ describe('Arc element tests', function() {
                        _index: 1
                });
 
-               // Make sure we can run these before the view is added
-               expect(arc.inRange(2, 2)).toBe(false);
-               expect(arc.inLabelRange(2)).toBe(false);
-
                // Mock out the view as if the controller put it there
                arc._view = {
                        startAngle: 0,
@@ -60,25 +56,6 @@ describe('Arc element tests', function() {
                expect(pos.y).toBeCloseTo(0.5);
        });
 
-       it ('should get the area', function() {
-               var arc = new Chart.elements.Arc({
-                       _datasetIndex: 2,
-                       _index: 1
-               });
-
-               // Mock out the view as if the controller put it there
-               arc._view = {
-                       startAngle: 0,
-                       endAngle: Math.PI / 2,
-                       x: 0,
-                       y: 0,
-                       innerRadius: 0,
-                       outerRadius: Math.sqrt(2),
-               };
-
-               expect(arc.getArea()).toBeCloseTo(0.5 * Math.PI, 6);
-       });
-
        it ('should get the center', function() {
                var arc = new Chart.elements.Arc({
                        _datasetIndex: 2,
index f6700e34713338e16308ae8625433964771dd2d4..bc51bedefaf64b5a47cf987aca5129809b65106a 100644 (file)
@@ -20,7 +20,6 @@ describe('Chart.elements.Point', function() {
 
                // Safely handles if these are called before the viewmodel is instantiated
                expect(point.inRange(5)).toBe(false);
-               expect(point.inLabelRange(5)).toBe(false);
 
                // Attach a view object as if we were the controller
                point._view = {
@@ -34,13 +33,6 @@ describe('Chart.elements.Point', function() {
                expect(point.inRange(10, 10)).toBe(false);
                expect(point.inRange(10, 5)).toBe(false);
                expect(point.inRange(5, 5)).toBe(false);
-
-               expect(point.inLabelRange(5)).toBe(false);
-               expect(point.inLabelRange(7)).toBe(true);
-               expect(point.inLabelRange(10)).toBe(true);
-               expect(point.inLabelRange(12)).toBe(true);
-               expect(point.inLabelRange(15)).toBe(false);
-               expect(point.inLabelRange(20)).toBe(false);
        });
 
        it ('should get the correct tooltip position', function() {
@@ -64,20 +56,6 @@ describe('Chart.elements.Point', function() {
                });
        });
 
-       it('should get the correct area', function() {
-               var point = new Chart.elements.Point({
-                       _datasetIndex: 2,
-                       _index: 1
-               });
-
-               // Attach a view object as if we were the controller
-               point._view = {
-                       radius: 2,
-               };
-
-               expect(point.getArea()).toEqual(Math.PI * 4);
-       });
-
        it('should get the correct center point', function() {
                var point = new Chart.elements.Point({
                        _datasetIndex: 2,
index d6932359ed9e4d1dd814d984f413d53f1724b486..686eea9324bdff977daf4e15d461702b30a75015 100644 (file)
@@ -20,7 +20,6 @@ describe('Rectangle element tests', function() {
 
                // Safely handles if these are called before the viewmodel is instantiated
                expect(rectangle.inRange(5)).toBe(false);
-               expect(rectangle.inLabelRange(5)).toBe(false);
 
                // Attach a view object as if we were the controller
                rectangle._view = {
@@ -35,13 +34,6 @@ describe('Rectangle element tests', function() {
                expect(rectangle.inRange(10, 16)).toBe(false);
                expect(rectangle.inRange(5, 5)).toBe(false);
 
-               expect(rectangle.inLabelRange(5)).toBe(false);
-               expect(rectangle.inLabelRange(7)).toBe(false);
-               expect(rectangle.inLabelRange(10)).toBe(true);
-               expect(rectangle.inLabelRange(12)).toBe(true);
-               expect(rectangle.inLabelRange(15)).toBe(false);
-               expect(rectangle.inLabelRange(20)).toBe(false);
-
                // Test when the y is below the base (negative bar)
                var negativeRectangle = new Chart.elements.Rectangle({
                        _datasetIndex: 2,
@@ -61,38 +53,6 @@ describe('Rectangle element tests', function() {
                expect(negativeRectangle.inRange(10, -5)).toBe(true);
        });
 
-       it('should get the correct height', function() {
-               var rectangle = new Chart.elements.Rectangle({
-                       _datasetIndex: 2,
-                       _index: 1
-               });
-
-               // Attach a view object as if we were the controller
-               rectangle._view = {
-                       base: 0,
-                       width: 4,
-                       x: 10,
-                       y: 15
-               };
-
-               expect(rectangle.height()).toBe(-15);
-
-               // Test when the y is below the base (negative bar)
-               var negativeRectangle = new Chart.elements.Rectangle({
-                       _datasetIndex: 2,
-                       _index: 1
-               });
-
-               // Attach a view object as if we were the controller
-               negativeRectangle._view = {
-                       base: -10,
-                       width: 4,
-                       x: 10,
-                       y: -15
-               };
-               expect(negativeRectangle.height()).toBe(5);
-       });
-
        it('should get the correct tooltip position', function() {
                var rectangle = new Chart.elements.Rectangle({
                        _datasetIndex: 2,
@@ -132,40 +92,6 @@ describe('Rectangle element tests', function() {
                });
        });
 
-       it('should get the correct vertical area', function() {
-               var rectangle = new Chart.elements.Rectangle({
-                       _datasetIndex: 2,
-                       _index: 1
-               });
-
-               // Attach a view object as if we were the controller
-               rectangle._view = {
-                       base: 0,
-                       width: 4,
-                       x: 10,
-                       y: 15
-               };
-
-               expect(rectangle.getArea()).toEqual(60);
-       });
-
-       it('should get the correct horizontal area', function() {
-               var rectangle = new Chart.elements.Rectangle({
-                       _datasetIndex: 2,
-                       _index: 1
-               });
-
-               // Attach a view object as if we were the controller
-               rectangle._view = {
-                       base: 0,
-                       height: 4,
-                       x: 10,
-                       y: 15
-               };
-
-               expect(rectangle.getArea()).toEqual(40);
-       });
-
        it('should get the center', function() {
                var rectangle = new Chart.elements.Rectangle({
                        _datasetIndex: 2,