scichart
Version:
Fast WebGL JavaScript Charting Library and Framework
117 lines (116 loc) • 6.76 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.RectangleSeriesHitTestProvider = void 0;
var Point_1 = require("../../../../Core/Point");
var ValueName_1 = require("../../../../types/ValueName");
var translate_1 = require("../../../../utils/translate");
var BaseHitTestProvider_1 = require("./BaseHitTestProvider");
var hitTestHelpers_1 = require("./hitTestHelpers");
var hitTestHelpersRectangleSeries_1 = require("./hitTestHelpersRectangleSeries");
var HitTestInfo_1 = require("./HitTestInfo");
/**
* Hit-test provider for {@link PolarColumnRenderableSeries}. See base class {@link BaseHitTestProvider} for further info
*/
var RectangleSeriesHitTestProvider = /** @class */ (function (_super) {
__extends(RectangleSeriesHitTestProvider, _super);
function RectangleSeriesHitTestProvider() {
return _super !== null && _super.apply(this, arguments) || this;
}
RectangleSeriesHitTestProvider.prototype.getTranslatedHitTestPoint = function (x, y) {
if (!this.currentRenderPassData || x === undefined || y === undefined) {
return undefined;
}
var p = (0, translate_1.translateFromCanvasToSeriesViewRect)(new Point_1.Point(x, y), this.parentSeries.parentSurface.seriesViewRect);
if (!p)
return undefined;
if (this.isPolar()) {
return this.parentSeries.xAxis.reverseTransform(p.x, p.y, false);
}
else {
return p;
}
};
/** @inheritDoc */
RectangleSeriesHitTestProvider.prototype.hitTest = function (x, y) {
// x, y screen cartesian coords with (0, 0) in left top corner
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 xValues = dataSeries.getNativeXValues();
var x1Values = dataSeries.getYValuesByName(ValueName_1.EValueName.X1);
var yValues = dataSeries.getYValuesByName(ValueName_1.EValueName.Y);
var y1Values = dataSeries.getYValuesByName(ValueName_1.EValueName.Y1);
var _b = this.parentSeries, getDataPointWidth = _b.getDataPointWidth, dataPointWidth = _b.dataPointWidth, defaultY1 = _b.defaultY1, columnXMode = _b.columnXMode, columnYMode = _b.columnYMode, dataPointWidthMode = _b.dataPointWidthMode;
var columnWidth = getDataPointWidth(xCoordinateCalculator, dataPointWidth, dataPointWidthMode);
var _c = this.hitTestForBox(this.webAssemblyContext, xCoordinateCalculator, yCoordinateCalculator, xValues, x1Values, yValues, y1Values, xHitCoord, yHitCoord, defaultY1, columnWidth, columnXMode, columnYMode, isVerticalChart, this.isPolar()), nearestPointIndex = _c.nearestPointIndex, isHit = _c.isHit, isWithinDataBounds = _c.isWithinDataBounds, xValue = _c.xValue, yValue = _c.yValue, x1Value = _c.x1Value, y1Value = _c.y1Value;
var hitTestInfo = hitTestHelpers_1.hitTestHelpers.createHitTestInfo(this.parentSeries, xCoordinateCalculator, yCoordinateCalculator, isVerticalChart, dataSeries, xValues, yValues, xHitCoord, yHitCoord, nearestPointIndex, 0);
hitTestInfo.isHit = isHit;
hitTestInfo.isWithinDataBounds = isWithinDataBounds;
hitTestInfo.xValue = xValue;
hitTestInfo.yValue = yValue;
hitTestInfo.x1Value = x1Value;
hitTestInfo.y1Value = y1Value;
return hitTestInfo;
};
/** @inheritDoc */
RectangleSeriesHitTestProvider.prototype.hitTestForDataPointSelectionModifier = function (x, y, hitTestRadius) {
if (hitTestRadius === void 0) { hitTestRadius = BaseHitTestProvider_1.BaseHitTestProvider.DEFAULT_HIT_TEST_RADIUS; }
return this.hitTest(x, y);
};
/** @inheritDoc */
RectangleSeriesHitTestProvider.prototype.hitTestXSlice = function (x, y) {
return this.hitTest(x, y);
};
/** @inheritDoc */
RectangleSeriesHitTestProvider.prototype.hitTestDataPoint = function (x, y, hitTestRadius) {
return this.hitTest(x, y);
};
/**
* Override this method if a different hit-test function is needed
*/
RectangleSeriesHitTestProvider.prototype.hitTestForBox = function (wasmContext, xCoordinateCalculator, yCoordinateCalculator, xValues, x1Values, yValues, y1Values, xHitCoord, yHitCoord, defaultY1, columnCoordWidth, columnXMode, columnYMode, isVertical, isPolar) {
return hitTestHelpersRectangleSeries_1.hitTestHelpersRectangleSeries.hitTestForBoxUnsorted(wasmContext, xCoordinateCalculator, yCoordinateCalculator, xValues, x1Values, yValues, y1Values, xHitCoord, yHitCoord, defaultY1, columnCoordWidth, columnXMode, columnYMode, isVertical, isPolar);
// return hitTestHelpersBoxSeries.hitTestForBoxSorted(
// wasmContext,
// xCoordinateCalculator,
// yCoordinateCalculator,
// xValues,
// yValues,
// y1Values,
// xHitCoord,
// yHitCoord,
// defaultY1,
// columnCoordWidth,
// columnXMode,
// columnYMode,
// isPolar
// );
};
RectangleSeriesHitTestProvider.prototype.isPolar = function () {
return this.parentSeries.parentSurface.isPolar;
};
return RectangleSeriesHitTestProvider;
}(BaseHitTestProvider_1.BaseHitTestProvider));
exports.RectangleSeriesHitTestProvider = RectangleSeriesHitTestProvider;