scichart
Version:
Fast WebGL JavaScript Charting Library and Framework
133 lines (132 loc) • 6 kB
JavaScript
"use strict";
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.RectangleDataLabelState = void 0;
var ColumnMode_1 = require("../../../../types/ColumnMode");
var ValueName_1 = require("../../../../types/ValueName");
var DataLabelState_1 = require("./DataLabelState");
var RectangleDataLabelState = /** @class */ (function (_super) {
__extends(RectangleDataLabelState, _super);
function RectangleDataLabelState(renderContext, renderPassData, style, color, yValues, parentSeries) {
var _this = _super.call(this, renderContext, renderPassData, style, color, yValues, parentSeries) || this;
_this.x1CoordCache = undefined;
_this.y1CoordCache = undefined;
var pointSeries = renderPassData.pointSeries;
_this.x1Values = pointSeries.getYValuesByName(ValueName_1.EValueName.X1);
_this.defaultY1 = parentSeries.defaultY1;
_this.y1Values = pointSeries.getYValuesByName(ValueName_1.EValueName.Y1);
_this.columnXMode = parentSeries.columnXMode;
_this.columnYMode = parentSeries.columnYMode;
_this.columnWidth = _this.parentSeries.getDataPointWidth(renderPassData.xCoordinateCalculator, parentSeries.dataPointWidth, parentSeries.dataPointWidthMode);
return _this;
}
RectangleDataLabelState.prototype.x1Val = function (index) {
return this.parentSeries.dataSeries.getNativeValue(this.x1Values, this.getIndexInternal(index));
};
RectangleDataLabelState.prototype.y1Val = function (index) {
if (this.y1Values) {
return this.parentSeries.dataSeries.getNativeValue(this.y1Values, this.getIndexInternal(index));
}
else {
return this.defaultY1;
}
};
// TODO: do we need it for Y1?
// public yValAfterAnimation(index?: number): number {
// if (!this.yFinalValues) return this.yVal(index);
// return this.yFinalValues.get(this.getIndexInternal(index));
// }
RectangleDataLabelState.prototype.x1Coord = function (index) {
if (this.renderPassData.isVerticalChart) {
return this.y1CoordInternal(index);
}
else {
var x1Coord = this.x1CoordInternal(index);
return x1Coord;
}
};
Object.defineProperty(RectangleDataLabelState.prototype, "index", {
get: function () {
return this.indexProperty;
},
set: function (value) {
this.xCoordCache = undefined;
this.yCoordCache = undefined;
this.x1CoordCache = undefined;
this.y1CoordCache = undefined;
this.indexProperty = value;
},
enumerable: false,
configurable: true
});
RectangleDataLabelState.prototype.y1Coord = function (index) {
if (this.renderPassData.isVerticalChart)
return this.x1CoordInternal(index);
else
return this.y1CoordInternal(index);
};
RectangleDataLabelState.prototype.x1CoordForXColumnModes = function (index) {
if (this.columnXMode === ColumnMode_1.EColumnMode.MidWidth || this.columnXMode === ColumnMode_1.EColumnMode.StartWidth) {
return this.renderPassData.xCoordinateCalculator.getCoordWidth(this.x1Val(index));
}
else if (this.columnXMode === ColumnMode_1.EColumnMode.Start || this.columnXMode === ColumnMode_1.EColumnMode.Mid) {
return this.columnWidth;
}
else {
return this.renderPassData.xCoordinateCalculator.getCoordinate(this.x1Val(index));
}
};
RectangleDataLabelState.prototype.x1CoordInternal = function (index) {
if (index !== undefined) {
return this.x1CoordForXColumnModes(index);
}
else {
if (this.x1CoordCache !== undefined) {
return this.x1CoordCache;
}
else {
this.x1CoordCache = this.x1CoordForXColumnModes();
}
return this.x1CoordCache;
}
};
RectangleDataLabelState.prototype.y1CoordForYColumnModes = function (index) {
if (this.columnYMode === ColumnMode_1.EColumnYMode.CenterHeight || this.columnYMode === ColumnMode_1.EColumnYMode.TopHeight) {
// here y1 is rectangle height in pixels
return this.renderPassData.yCoordinateCalculator.getCoordWidth(this.y1Val(index));
}
else {
return this.renderPassData.yCoordinateCalculator.getCoordinate(this.y1Val(index));
}
};
RectangleDataLabelState.prototype.y1CoordInternal = function (index) {
if (index !== undefined) {
return this.y1CoordForYColumnModes(index);
}
else {
if (this.y1CoordCache !== undefined) {
return this.y1CoordCache;
}
else {
this.y1CoordCache = this.y1CoordForYColumnModes();
}
return this.y1CoordCache;
}
};
return RectangleDataLabelState;
}(DataLabelState_1.DataLabelState));
exports.RectangleDataLabelState = RectangleDataLabelState;