scichart
Version:
Fast WebGL JavaScript Charting Library and Framework
79 lines (78 loc) • 4.87 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.BoxPlotSeriesHitTestProvider = void 0;
var BaseHitTestProvider_1 = require("./BaseHitTestProvider");
var hitTestHelpers_1 = require("./hitTestHelpers");
var HitTestInfo_1 = require("./HitTestInfo");
/**
* Hit-test provider for {@link BoxPlotSeriesHitTestProvider}. See base class {@link BaseHitTestProvider} for further info
*/
var BoxPlotSeriesHitTestProvider = /** @class */ (function (_super) {
__extends(BoxPlotSeriesHitTestProvider, _super);
function BoxPlotSeriesHitTestProvider() {
return _super !== null && _super.apply(this, arguments) || this;
}
/** @inheritDoc */
BoxPlotSeriesHitTestProvider.prototype.hitTest = function (x, y) {
var hitTestPoint = this.getTranslatedHitTestPoint(x, y);
if (!hitTestPoint) {
return HitTestInfo_1.HitTestInfo.empty();
}
var _a = this.currentRenderPassData, xCoordinateCalculator = _a.xCoordinateCalculator, yCoordinateCalculator = _a.yCoordinateCalculator, isVerticalChart = _a.isVerticalChart;
var xHitCoord = isVerticalChart ? hitTestPoint.y : hitTestPoint.x;
var yHitCoord = isVerticalChart ? hitTestPoint.x : hitTestPoint.y;
var dataSeries = this.parentSeries.dataSeries;
if (!dataSeries) {
return HitTestInfo_1.HitTestInfo.empty();
}
var nearestPointIndex = hitTestHelpers_1.hitTestHelpers.getNearestXPoint(this.webAssemblyContext, xCoordinateCalculator, dataSeries, xHitCoord, dataSeries.dataDistributionCalculator.isSortedAscending);
var xValues = dataSeries.getNativeXValues();
var yMedianValues = dataSeries.getNativeMedianValues();
var _b = this.parentSeries, getDataPointWidth = _b.getDataPointWidth, dataPointWidth = _b.dataPointWidth, dataPointWidthMode = _b.dataPointWidthMode, capDataPointWidth = _b.cap.dataPointWidth;
var boxCoordWidth = getDataPointWidth(xCoordinateCalculator, Math.max(dataPointWidth, capDataPointWidth), dataPointWidthMode);
var hitTestInfo = hitTestHelpers_1.hitTestHelpers.createHitTestInfo(this.parentSeries, xCoordinateCalculator, yCoordinateCalculator, isVerticalChart, dataSeries, xValues, yMedianValues, xHitCoord, yHitCoord, nearestPointIndex, 0, undefined, boxCoordWidth);
var yMinValues = dataSeries.getNativeMinimumValues();
var yMaxValues = dataSeries.getNativeMaximumValues();
if (nearestPointIndex >= 0) {
hitTestInfo.isHit = hitTestHelpers_1.hitTestHelpers.testIsHitForBoxPlot(xCoordinateCalculator, yCoordinateCalculator, boxCoordWidth, dataSeries, xValues, yMinValues, yMaxValues, nearestPointIndex, xHitCoord, yHitCoord);
var boxPlotMax = yMaxValues.get(nearestPointIndex);
var boxPlotUpper = dataSeries.getNativeUpperQuartileValues().get(nearestPointIndex);
var boxPlotMedian = yMedianValues.get(nearestPointIndex);
var boxPlotLower = dataSeries.getNativeLowerQuartileValues().get(nearestPointIndex);
var boxPlotMinimum = yMinValues.get(nearestPointIndex);
hitTestInfo.yValues = [boxPlotMax, boxPlotUpper, boxPlotMedian, boxPlotLower, boxPlotMinimum];
}
else {
hitTestInfo.isHit = false;
}
return hitTestInfo;
};
/** @inheritDoc */
BoxPlotSeriesHitTestProvider.prototype.hitTestForDataPointSelectionModifier = function (x, y, hitTestRadius) {
if (hitTestRadius === void 0) { hitTestRadius = BaseHitTestProvider_1.BaseHitTestProvider.DEFAULT_HIT_TEST_RADIUS; }
return this.hitTest(x, y);
};
/** @inheritDoc */
BoxPlotSeriesHitTestProvider.prototype.hitTestXSlice = function (x, y) {
var hitTestInfo = this.hitTest(x, y);
hitTestInfo.isHit = hitTestInfo.isWithinDataBounds;
return hitTestInfo;
};
return BoxPlotSeriesHitTestProvider;
}(BaseHitTestProvider_1.BaseHitTestProvider));
exports.BoxPlotSeriesHitTestProvider = BoxPlotSeriesHitTestProvider;