export function _isPointInArea(point, area, margin) {
margin = margin || 0.5; // margin - default is to match rounded decimals
- return point && area && point.x > area.left - margin && point.x < area.right + margin &&
- point.y > area.top - margin && point.y < area.bottom + margin;
+ return !area || (point && point.x > area.left - margin && point.x < area.right + margin &&
+ point.y > area.top - margin && point.y < area.bottom + margin);
}
export function clipArea(ctx, area) {
});
describe('isPointInArea', function() {
+ it('should return true when no area is provided', function() {
+ expect(helpers._isPointInArea({x: 1, y: 1})).toBe(true);
+ });
it('should determine if a point is in the area', function() {
var isPointInArea = helpers._isPointInArea;
var area = {left: 0, top: 0, right: 512, bottom: 256};
export type TextAlign = 'left' | 'center' | 'right';
export interface VisualElement {
- draw(ctx: CanvasRenderingContext2D): void;
+ draw(ctx: CanvasRenderingContext2D, area?: ChartArea): void;
inRange(mouseX: number, mouseY: number, useFinalPosition?: boolean): boolean;
inXRange(mouseX: number, useFinalPosition?: boolean): boolean;
inYRange(mouseY: number, useFinalPosition?: boolean): boolean;