scichart
Version:
Fast WebGL JavaScript Charting Library and Framework
168 lines (167 loc) • 8.03 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 __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.XDataSeries = void 0;
var NumberRange_1 = require("../../Core/NumberRange");
var vectorToArray_1 = require("../../utils/vectorToArray");
var BaseDataSeries_1 = require("./BaseDataSeries");
var IDataSeries_1 = require("./IDataSeries");
/**
* @summary XDataSeries is a DataSeries for holding X values only in SciChart's 2D
* {@link https://www.scichart.com/javascript-chart-features | JavaScript Charts}
* @description
* The XDataSeries is primarily used to create Pie or Donut charts with our {@link PolarColumnRenderableSeries | JavaScript Polar Column Chart} in Width mode,
* or to create a linear gauge using {@link FastBoxRenderableSeries | JavaScript Box Chart} in Width mode.
*
* @remarks
* A DataSeries stores the data to render. This is independent from the {@link IRenderableSeries | RenderableSeries}
* which defines how that data should be rendered.
*
* See derived types of {@link BaseDataSeries} to find out what data-series are available.
* See derived types of {@link IRenderableSeries} to find out what 2D JavaScript Chart types are available.
*
* ---
* 📚 Docs: {@link https://www.scichart.com/documentation/js/v4/2d-charts/chart-types/data-series-api/data-series-api-overview/}
*/
var XDataSeries = /** @class */ (function (_super) {
__extends(XDataSeries, _super);
/**
* Creates an instance of {@link XDataSeries}
* @param webAssemblyContext the {@link TSciChart | SciChart WebAssembly Context} containing native methods
* and access to our underlying WebGL2 WebAssembly rendering engine
* @param options the {@link IXDataSeriesOptions} which can be passed to configure the DataSeries at construct time
*
* ---
* 📚 Docs: {@link https://www.scichart.com/documentation/js/v4/2d-charts/chart-types/data-series-api/data-series-api-overview/}
*/
function XDataSeries(webAssemblyContext, options) {
var _this = this;
var baseOptions = __assign(__assign({}, options), { arrayCount: 0 });
_this = _super.call(this, webAssemblyContext, baseOptions) || this;
/**
* @inheritDoc
*/
_this.type = IDataSeries_1.EDataSeriesType.X;
if (baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.xValues) {
_this.appendRange(baseOptions.xValues, baseOptions.metadata);
if ((baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.fifoCapacity) && (baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.fifoStartIndex)) {
_this.xValues.notifyAppend(baseOptions === null || baseOptions === void 0 ? void 0 : baseOptions.fifoStartIndex);
}
}
return _this;
}
/**
* Appends a single X point to the DataSeries
* @remarks
* For best performance on drawing large datasets, use the {@link appendRange} method
*
* Any changes of the DataSeries will trigger a redraw on the parent {@link SciChartSurface}
* @param x The X-value
* @param metadata The point metadata
*/
XDataSeries.prototype.append = function (x, metadata) {
_super.prototype.appendN.call(this, x, [], metadata, undefined);
};
/**
* Appends a range of X points to the DataSeries
* @remarks
* This method is considerably higher performance than {@link append} which appends a single point
*
* Any changes of the DataSeries will trigger a redraw on the parent {@link SciChartSurface}
* @param xValues The X-values
* @param metadata The array of point metadata
*/
XDataSeries.prototype.appendRange = function (xValues, metadata) {
_super.prototype.appendRangeN.call(this, xValues, [], metadata);
};
/**
* Updates a single X value by X-index. Might also need to set isSorted = false
* @remarks Any changes of the DataSeries will trigger a redraw on the parent {@link SciChartSurface}
* @param index The index to update
* @param x The new X value
* @param metadata The point metadata
*/
XDataSeries.prototype.updateX = function (index, x, metadata) {
_super.prototype.updateXyN.call(this, index, x, [], metadata);
};
/**
* @summary Inserts a single X value at the start index
* @remarks
* For best performance on drawing large datasets, use the {@link insertRange} method
*
* Any changes of the DataSeries will trigger a redraw on the parent {@link SciChartSurface}
* @param startIndex the index to insert at
* @param x the X value
* @param metadata The point metadata
*/
XDataSeries.prototype.insert = function (startIndex, x, metadata) {
_super.prototype.insertN.call(this, startIndex, x, [], metadata);
};
/**
* @summary Inserts a range of X values at the startIndex
* @remarks
* Any changes of the DataSeries will trigger a redraw on the parent {@link SciChartSurface}
* @param startIndex the index to insert at
* @param xValues the XValues
* @param metadata The array of point metadata
*/
XDataSeries.prototype.insertRange = function (startIndex, xValues, metadata) {
_super.prototype.insertRangeN.call(this, startIndex, xValues, [], metadata);
};
/** For XDataSeries this always returns (0, 1) */
XDataSeries.prototype.getWindowedYRange = function (xRange, getPositiveRange, isXCategoryAxis, dataSeriesValueType, yRangeMode) {
return new NumberRange_1.NumberRange(0, 1);
};
XDataSeries.prototype.getOptions = function (excludeData) {
if (excludeData === void 0) { excludeData = false; }
var json = _super.prototype.getOptions.call(this, excludeData);
if (!excludeData) {
// const dataSize = this.count();
// const xValues: number[] = new Array(dataSize);
// if (this.fifoCapacity && this.fifoSweeping) {
// for (let i = 0; i < dataSize; i++) {
// xValues[i] = (this.xValues as SCRTFifoVector).getRaw(i);
// }
// } else {
// for (let i = 0; i < dataSize; i++) {
// xValues[i] = this.xValues.get(i);
// }
// }
// Vroom Vroom!
var xValues = (0, vectorToArray_1.vectorToArray)(this.xValues, this.webAssemblyContext);
var options = {
xValues: xValues,
yValues: undefined
};
Object.assign(json, options);
}
return json;
};
return XDataSeries;
}(BaseDataSeries_1.BaseDataSeries));
exports.XDataSeries = XDataSeries;