ag-charts-community
Version:
Advanced Charting / Charts supporting Javascript / Typescript / React / Angular / Vue
114 lines • 3.44 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("../../scene/shape/path");
const bbox_1 = require("../../scene/bbox");
class RangeHandle extends path_1.Path {
constructor() {
super(...arguments);
this._fill = '#f2f2f2';
this._stroke = '#999999';
this._strokeWidth = 1;
this._lineCap = 'square';
this._centerX = 0;
this._centerY = 0;
// Use an even number for better looking results.
this._width = 8;
// Use an even number for better looking results.
this._gripLineGap = 2;
// Use an even number for better looking results.
this._gripLineLength = 8;
this._height = 16;
}
set centerX(value) {
if (this._centerX !== value) {
this._centerX = value;
this.dirtyPath = true;
}
}
get centerX() {
return this._centerX;
}
set centerY(value) {
if (this._centerY !== value) {
this._centerY = value;
this.dirtyPath = true;
}
}
get centerY() {
return this._centerY;
}
set width(value) {
if (this._width !== value) {
this._width = value;
this.dirtyPath = true;
}
}
get width() {
return this._width;
}
set gripLineGap(value) {
if (this._gripLineGap !== value) {
this._gripLineGap = value;
this.dirtyPath = true;
}
}
get gripLineGap() {
return this._gripLineGap;
}
set gripLineLength(value) {
if (this._gripLineLength !== value) {
this._gripLineLength = value;
this.dirtyPath = true;
}
}
get gripLineLength() {
return this._gripLineLength;
}
set height(value) {
if (this._height !== value) {
this._height = value;
this.dirtyPath = true;
}
}
get height() {
return this._height;
}
computeBBox() {
const { centerX, centerY, width, height } = this;
const x = centerX - width / 2;
const y = centerY - height / 2;
return new bbox_1.BBox(x, y, width, height);
}
isPointInPath(x, y) {
const point = this.transformPoint(x, y);
const bbox = this.computeBBox();
return bbox.containsPoint(point.x, point.y);
}
updatePath() {
const { path, centerX, centerY, width, height } = this;
const { alignment: a, align: al } = this;
path.clear();
const x = centerX - width / 2;
const y = centerY - height / 2;
const ax = al(a, x);
const ay = al(a, y);
const axw = ax + al(a, x, width);
const ayh = ay + al(a, y, height);
// Handle.
path.moveTo(ax, ay);
path.lineTo(axw, ay);
path.lineTo(axw, ayh);
path.lineTo(ax, ayh);
path.lineTo(ax, ay);
// Grip lines.
const dx = this.gripLineGap / 2;
const dy = this.gripLineLength / 2;
path.moveTo(al(a, centerX - dx), al(a, centerY - dy));
path.lineTo(al(a, centerX - dx), al(a, centerY + dy));
path.moveTo(al(a, centerX + dx), al(a, centerY - dy));
path.lineTo(al(a, centerX + dx), al(a, centerY + dy));
}
}
exports.RangeHandle = RangeHandle;
RangeHandle.className = 'RangeHandle';
//# sourceMappingURL=rangeHandle.js.map