scichart
Version:
Fast WebGL JavaScript Charting Library and Framework
69 lines (68 loc) • 4.02 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.PolarDataPointHitTestProvider = void 0;
var BaseHitTestProvider_1 = require("../../HitTest/BaseHitTestProvider");
var HitTestInfo_1 = require("../../HitTest/HitTestInfo");
var hitTestHelpers_1 = require("../../HitTest/hitTestHelpers");
var polarHitTestHelpers_1 = require("./polarHitTestHelpers");
var DEFAULT_RADIUS = 10;
/**
* Hit-test provider for {@link PolarLineRenderableSeries}. See base class {@link BaseHitTestProvider} for further info
*/
var PolarDataPointHitTestProvider = /** @class */ (function (_super) {
__extends(PolarDataPointHitTestProvider, _super);
function PolarDataPointHitTestProvider() {
return _super !== null && _super.apply(this, arguments) || this;
}
/** @inheritDoc */
PolarDataPointHitTestProvider.prototype.hitTest = function (x, y, hitTestRadius) {
if (hitTestRadius === void 0) { hitTestRadius = DEFAULT_RADIUS; }
return this.hitTestDataPointInternal(x, y, hitTestRadius);
};
/** @inheritDoc */
PolarDataPointHitTestProvider.prototype.hitTestDataPoint = function (x, y, hitTestRadius) {
var radius = hitTestRadius > 0 ? hitTestRadius : DEFAULT_RADIUS;
return this.hitTestDataPointInternal(x, y, radius);
};
PolarDataPointHitTestProvider.prototype.hitTestXSlice = function (x, y) {
return this.hitTest(x, y, DEFAULT_RADIUS);
};
PolarDataPointHitTestProvider.prototype.hitTestDataPointInternal = function (x, y, hitTestRadius) {
// convert to polar and add necessary offset
var hitTestPoint = this.getTranslatedHitTestPoint(x, y);
if (!hitTestPoint) {
return HitTestInfo_1.HitTestInfo.empty();
}
var hitTestPointPolar = this.parentSeries.xAxis.reverseTransform(hitTestPoint.x, hitTestPoint.y);
var _a = this.currentRenderPassData, xCoordinateCalculator = _a.xCoordinateCalculator, yCoordinateCalculator = _a.yCoordinateCalculator, isVerticalChart = _a.isVerticalChart;
var xHitCoord = isVerticalChart ? hitTestPointPolar.y : hitTestPointPolar.x;
var yHitCoord = isVerticalChart ? hitTestPointPolar.x : hitTestPointPolar.y;
var dataSeries = this.parentSeries.dataSeries;
if (!dataSeries) {
return HitTestInfo_1.HitTestInfo.empty();
}
var nearest = polarHitTestHelpers_1.polarHitTestHelpers.getNearestPolarPoint(this.webAssemblyContext, xCoordinateCalculator, yCoordinateCalculator, dataSeries, xHitCoord, yHitCoord);
var xNativeValues = dataSeries.getNativeXValues();
var yNativeValues = dataSeries.getNativeYValues();
var hitTestInfo = hitTestHelpers_1.hitTestHelpers.createHitTestInfo(this.parentSeries, xCoordinateCalculator, yCoordinateCalculator, isVerticalChart, dataSeries, xNativeValues, yNativeValues, xHitCoord, yHitCoord, nearest.nearestPointIndex, hitTestRadius);
hitTestInfo.isHit = nearest.distance < hitTestRadius;
return hitTestInfo;
};
return PolarDataPointHitTestProvider;
}(BaseHitTestProvider_1.BaseHitTestProvider));
exports.PolarDataPointHitTestProvider = PolarDataPointHitTestProvider;