UNPKG

scichart

Version:

Fast WebGL JavaScript Charting Library and Framework

120 lines (119 loc) 7.14 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.SciChartPolarSurface = void 0; var app_1 = require("../../constants/app"); var SciChartSurfaceType_1 = require("../../types/SciChartSurfaceType"); var SurfaceType_1 = require("../../types/SurfaceType"); var PolarLayoutManager_1 = require("../LayoutManager/Polar/PolarLayoutManager"); var createMaster_1 = require("./createMaster"); var createSingle_1 = require("./createSingle"); var sciChartInitCommon_1 = require("./sciChartInitCommon"); var SciChartSurface_1 = require("./SciChartSurface"); /** * @summary The {@link SciChartPolarSurface} is the root 2D Polar Chart control in SciChart's High Performance Real-time * {@link https://www.scichart.com/javascript-chart-features | JavaScript Chart Library} * @description * To create a polar chart using SciChart, declare a {@link SciChartPolarSurface} using {@link SciChartPolarSurface.create}, * add X and Y axes to the {@link SciChartPolarSurface.xAxes} {@link SciChartPolarSurface.yAxes} collection. * * Next, add a polar series to the {@link SciChartPolarSurface.renderableSeries} collection. * * You can add annotations and markers using the {@link SciChartPolarSurface.annotations} property, and you can add zoom and pan behaviours, * tooltips and more by using the {@link SciChartPolarSurface.chartModifiers} property. * * To redraw a {@link SciChartPolarSurface} at any time, call {@link SciChartPolarSurface.invalidateElement}, however all properties are reactive and the * chart will automatically redraw if data or properties change. * @remarks * It is possible to have more than one {@link SciChartPolarSurface} on screen at the same time. * {@link SciChartPolarSurface | SciChartPolarSurfaces} scale to fit the parent DIV where they are hosted. Use CSS to position the DIV. */ var SciChartPolarSurface = /** @class */ (function (_super) { __extends(SciChartPolarSurface, _super); function SciChartPolarSurface(webAssemblyContext, options) { var _this = _super.call(this, webAssemblyContext, options) || this; _this.layoutManager = new PolarLayoutManager_1.PolarLayoutManager(); return _this; } /** * Creates a {@link SciChartPolarSurface} and {@link TSciChart | WebAssembly Context} to occupy the div by element ID in your DOM. * @remarks This method is async and must be awaited * @param divElement The Div Element ID or reference where the {@link SciChartSurface} will reside * @param options Optional - Optional parameters for chart creation. See {@link I2DSurfaceOptions} for more details */ SciChartPolarSurface.create = function (divElement, options) { options = SciChartSurface_1.SciChartSurface.resolveOptions(options); if (app_1.IS_TEST_ENV) { return this.createPolarTest(divElement, options); } else { var surfaceConstructor = function (wasmContext, options) { return new SciChartPolarSurface(wasmContext, options); }; return (0, createMaster_1.createMultichart)(divElement, surfaceConstructor, options).then(function (result) { result.sciChartSurface.applyOptions(options); return result; }); } }; /** * Performs a similar operation to {@link SciChartPolarSurface.create} but uses a dedicated WebAssembly context for this chart, and draws directly to the target canvas * This provides better performance for a single chart, but there is a limit (16) to how many you can have on one page. * If you need large numbers of charts all updating at the same time, use this, together with {@link addSubChart} to create many charts on one surface. * @param divElement The Div Element ID or reference where the {@link SciChartSurface} will reside * @param options - optional parameters for chart creation. See {@link I2DSurfaceOptions} for more details */ SciChartPolarSurface.createSingle = function (divElement, options) { options = SciChartSurface_1.SciChartSurface.resolveOptions(options); if (app_1.IS_TEST_ENV) { return this.createPolarTest(divElement, options); } else { var surfaceConstructor = function (wasmContext, options) { return new SciChartPolarSurface(wasmContext, options); }; return (0, createSingle_1.createSingleInternal)(divElement, surfaceConstructor, options).then(function (result) { result.sciChartSurface.applyOptions(options); return result; }); } }; Object.defineProperty(SciChartPolarSurface.prototype, "surfaceType", { /** @inheritDoc */ get: function () { return SurfaceType_1.ESurfaceType.SciChartPolarSurfaceType; }, enumerable: false, configurable: true }); SciChartPolarSurface.createPolarTest = function (divElement, options) { var _a, _b; var canvases = sciChartInitCommon_1.default.initCanvas(divElement, (_a = options === null || options === void 0 ? void 0 : options.widthAspect) !== null && _a !== void 0 ? _a : 0, (_b = options === null || options === void 0 ? void 0 : options.heightAspect) !== null && _b !== void 0 ? _b : 0, sciChartInitCommon_1.default.ECanvasType.canvas2D); var sciChartSurface = new SciChartPolarSurface(SciChartSurface_1.sciChartConfig.testWasm, { canvases: canvases }); sciChartSurface.applyTheme(options === null || options === void 0 ? void 0 : options.theme); sciChartSurface.applyOptions(options); return new Promise(function (resolve) { return resolve({ wasmContext: sciChartSurface.webAssemblyContext2D, sciChartSurface: sciChartSurface }); }); }; SciChartPolarSurface.prototype.toJSON = function (excludeData) { if (excludeData === void 0) { excludeData = false; } var definition = _super.prototype.toJSON.call(this, excludeData); definition.type = SciChartSurfaceType_1.ESciChartSurfaceType.Polar2D; return definition; }; return SciChartPolarSurface; }(SciChartSurface_1.SciChartSurface)); exports.SciChartPolarSurface = SciChartPolarSurface;