* `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
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;
};
},
- 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);
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,
};
},
- getArea: function() {
- return Math.PI * Math.pow(this._view.radius, 2);
- },
-
tooltipPosition: function() {
var vm = this._view;
return {
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);
},
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: 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,
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,
// 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 = {
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() {
});
});
- 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,
// 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 = {
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,
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,
});
});
- 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,