UNPKG

scichart

Version:

Fast WebGL JavaScript Charting Library and Framework

71 lines (70 loc) 3.81 kB
"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.DiscontinuousDateAxis = void 0; var AxisType_1 = require("../../../types/AxisType"); var BaseValueAxis_1 = require("./BaseValueAxis"); var IndexDeltaCalculator_1 = require("./DeltaCalculator/IndexDeltaCalculator"); var SmartDateLabelProvider_1 = require("./LabelProvider/SmartDateLabelProvider"); /** * @summary A 2D Chart Discontinuous Date Axis type * @description This axis is designed for use with discontinuous timeseries data, such as weekday only financial data. * This axis uses base values which are plotted by index (ie evenly spaced) and also used to convert from data values to indexes. * If dataGap is not provided it is calculated as the minimim gap between baseValues. * @remarks * --- * 📚 Docs: TODO */ var DiscontinuousDateAxis = /** @class */ (function (_super) { __extends(DiscontinuousDateAxis, _super); function DiscontinuousDateAxis(webAssemblyContext, options) { var _this = this; if (!(options === null || options === void 0 ? void 0 : options.labelProvider)) { options = options !== null && options !== void 0 ? options : {}; options.labelProvider = new SmartDateLabelProvider_1.SmartDateLabelProvider(options); } _this = _super.call(this, webAssemblyContext, options) || this; _this.type = AxisType_1.EAxisType.DiscontinuousDateAxis; _this.possibleDeltasOption = options === null || options === void 0 ? void 0 : options.possibleDeltas; _this.minTicksOption = options === null || options === void 0 ? void 0 : options.minTicks; _this.deltaCalculator = new IndexDeltaCalculator_1.IndexDeltaCalculator(webAssemblyContext, { possibleDeltas: options === null || options === void 0 ? void 0 : options.possibleDeltas, minTicks: options === null || options === void 0 ? void 0 : options.minTicks, datePrecision: options === null || options === void 0 ? void 0 : options.datePrecision }); return _this; } DiscontinuousDateAxis.prototype.setBaseXValues = function (baseXValuesDataSeries) { _super.prototype.setBaseValues.call(this, baseXValuesDataSeries); }; DiscontinuousDateAxis.prototype.toJSON = function () { var json = _super.prototype.toJSON.call(this); // labelProvider options are serialized in the labelProvider itself var options = { possibleDeltas: this.possibleDeltasOption, minTicks: this.minTicksOption }; Object.assign(json.options, options); return json; }; DiscontinuousDateAxis.prototype.updateIndexCalculatorBaseValuesInternal = function (vector) { // Force calculate dataGap if not set this.indexCalculator.UpdateVec(vector, this.dataGap === 0); }; return DiscontinuousDateAxis; }(BaseValueAxis_1.BaseValueAxis)); exports.DiscontinuousDateAxis = DiscontinuousDateAxis;