scichart
Version:
Fast WebGL JavaScript Charting Library and Framework
154 lines (153 loc) • 7.97 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.PolarLineRenderableSeries = void 0;
var NumberRange_1 = require("../../../../Core/NumberRange");
var SeriesType_1 = require("../../../../types/SeriesType");
var BaseLineRenderableSeries_1 = require("../BaseLineRenderableSeries");
var PolarDataLabelProvider_1 = require("./DataLabels/PolarDataLabelProvider");
var PolarInterpolateLineRenderDataTransform_1 = require("../RenderDataTransforms/PolarInterpolateLineRenderDataTransform");
var PolarLineSeriesDrawingProvider_1 = require("./DrawingProviders/PolarLineSeriesDrawingProvider");
var PolarPointMarkerDrawingProvider_1 = require("./DrawingProviders/PolarPointMarkerDrawingProvider");
var PolarDataPointHitTestProvider_1 = require("./HitTest/PolarDataPointHitTestProvider");
/**
* Defines a polar line-series or polar line chart type in the SciChart's High Performance Real-time
* {@link https://www.scichart.com/javascript-chart-features | JavaScript Charts}
* @remarks
* To add a polar line series to a {@link SciChartPolarSurface} you need to declare both the {@link PolarLineRenderableSeries | RenderableSeries}
* and a {@link XyDataSeries | DataSeries}. Simplified code sample below:
*
* ```ts
* const { sciChartSurface, wasmContext } = SciChartPolarSurface.create(rootId);
*
* // Create the renderableSeries
* const polarLineSeries = new PolarLineRenderableSeries(wasmContext, {
* dataSeries: new XyDataSeries(wasmContext, {
* xValues: [1, 2, 3, 4],
* yValues: [3, 2, 4, 1],
* }),
* stroke: "#FFF"
* });
* // append to the SciChartSurface
* sciChartPolarSurface.renderableSeries.add(polarLineSeries);
* ```
*
* ---
* 📚 Docs: {@link https://www.scichart.com/documentation/js/v4/2d-charts/chart-types/polar-line-renderable-series/}
*/
var PolarLineRenderableSeries = /** @class */ (function (_super) {
__extends(PolarLineRenderableSeries, _super);
/**
* Creates an instance of the {@link PolarLineRenderableSeries}
* @param webAssemblyContext The {@link TSciChart | SciChart WebAssembly Context} containing
* native methods and access to our WebGL2 WebAssembly Drawing Engine
* @param options optional parameters of type {@link IPolarLineRenderableSeriesOptions} applied when constructing the series type
*
* ---
* 📚 Docs: {@link https://www.scichart.com/documentation/js/v4/2d-charts/chart-types/polar-line-renderable-series/}
*/
function PolarLineRenderableSeries(webAssemblyContext, options) {
var _this = this;
var _a, _b, _c, _d;
_this = _super.call(this, webAssemblyContext, options) || this;
_this.isPolar = true;
_this.type = SeriesType_1.ESeriesType.PolarLineSeries;
_this.clipToTotalAngleProperty = false;
_this.interpolateLineProperty = false;
if (!_this.dataLabelProviderProperty) {
_this.dataLabelProviderProperty = new PolarDataLabelProvider_1.PolarDataLabelProvider(options === null || options === void 0 ? void 0 : options.dataLabels);
_this.dataLabelProviderProperty.onAttach(_this.webAssemblyContext, _this);
}
// Must be called here for the series type to be available
if ((_a = _this.paletteProvider) === null || _a === void 0 ? void 0 : _a.onAttached) {
(_b = _this.paletteProvider) === null || _b === void 0 ? void 0 : _b.onAttached(_this);
}
_this.renderDataTransformProperty = new PolarInterpolateLineRenderDataTransform_1.PolarInterpolateLineRenderDataTransform(_this, _this.webAssemblyContext, []);
_this.clipToTotalAngleProperty = (_c = options === null || options === void 0 ? void 0 : options.clipToTotalAngle) !== null && _c !== void 0 ? _c : _this.clipToTotalAngleProperty;
_this.interpolateLine = (_d = options === null || options === void 0 ? void 0 : options.interpolateLine) !== null && _d !== void 0 ? _d : _this.interpolateLineProperty;
return _this;
}
Object.defineProperty(PolarLineRenderableSeries.prototype, "interpolateLine", {
/**
* Gets or sets how to draw lines. If true draws lines as interpolated arc, otherwise draws normal lines
*/
get: function () {
return this.interpolateLineProperty;
},
set: function (value) {
if (this.interpolateLineProperty !== value) {
this.interpolateLineProperty = value;
if (this.interpolateLineProperty) {
this.renderDataTransform.drawingProviders = [this.drawingProviders[0]];
}
else {
this.renderDataTransform.drawingProviders = [];
}
this.notifyPropertyChanged("interpolateLine");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarLineRenderableSeries.prototype, "clipToTotalAngle", {
/**
* Gets or sets if to clip or draw data outside of the total angle. Default to draw
*/
get: function () {
return this.clipToTotalAngleProperty;
},
set: function (value) {
if (this.clipToTotalAngleProperty !== value) {
this.clipToTotalAngleProperty = value;
this.notifyPropertyChanged("clipToTotalAngle");
}
},
enumerable: false,
configurable: true
});
/** @inheritDoc */
PolarLineRenderableSeries.prototype.getIndicesRange = function (xRange, isCategoryData) {
if (this.clipToTotalAngle) {
return _super.prototype.getIndicesRange.call(this, xRange, isCategoryData);
}
else {
return new NumberRange_1.NumberRange(0, this.dataSeries.count() - 1);
}
};
/** @inheritDoc */
PolarLineRenderableSeries.prototype.toJSON = function (excludeData) {
if (excludeData === void 0) { excludeData = false; }
var json = _super.prototype.toJSON.call(this, excludeData);
var options = {
clipToTotalAngle: this.clipToTotalAngle,
interpolateLine: this.interpolateLine
};
Object.assign(json.options, options);
return json;
};
/** @inheritDoc */
PolarLineRenderableSeries.prototype.addDrawingProviders = function (webAssemblyContext, options) {
this.drawingProviders.push(new PolarLineSeriesDrawingProvider_1.PolarLineSeriesDrawingProvider(webAssemblyContext, this));
this.drawingProviders.push(new PolarPointMarkerDrawingProvider_1.PolarPointMarkerDrawingProvider(webAssemblyContext, this));
};
/** @inheritDoc */
PolarLineRenderableSeries.prototype.newHitTestProvider = function () {
return new PolarDataPointHitTestProvider_1.PolarDataPointHitTestProvider(this, this.webAssemblyContext);
};
return PolarLineRenderableSeries;
}(BaseLineRenderableSeries_1.BaseLineRenderableSeries));
exports.PolarLineRenderableSeries = PolarLineRenderableSeries;