scichart
Version:
Fast WebGL JavaScript Charting Library and Framework
665 lines (664 loc) • 32.2 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 __());
};
})();
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.PolarAxisBase = void 0;
var Deleter_1 = require("../../../../Core/Deleter");
var Point_1 = require("../../../../Core/Point");
var Rect_1 = require("../../../../Core/Rect");
var Pen2DCache_1 = require("../../../Drawing/Pen2DCache");
var WebGlRenderContext2D_1 = require("../../../Drawing/WebGlRenderContext2D");
var NativeObject_1 = require("../../Helpers/NativeObject");
var SciChartSurfaceBase_1 = require("../../SciChartSurfaceBase");
var DpiHelper_1 = require("../../TextureManager/DpiHelper");
var AxisBase2D_1 = require("../AxisBase2D");
var AxisLayoutState_1 = require("../AxisLayoutState");
var constants_1 = require("../constants");
var PolarAxisRenderer_1 = require("./PolarAxisRenderer");
var PolarAxisMode_1 = require("./types/PolarAxisMode");
var PolarGridlineMode_1 = require("./types/PolarGridlineMode");
var PolarLabelMode_1 = require("./types/PolarLabelMode");
/**
* @summary A 2D Chart Numeric / Value Axis type for use with Polar Charts.
* @description A Polar Numeric axis converts to angles around a circle.
* @remarks
* Set a {@link NumericAxis} on the {@link SciChartSurface.xAxes} or {@link SciChartSurface.yAxes} property.
*/
var PolarAxisBase = /** @class */ (function (_super) {
__extends(PolarAxisBase, _super);
/**
* Creates an instance of a {@link PolarAxisBase}
* @param webAssemblyContext The {@link TSciChart | SciChart 2D WebAssembly Context} containing native methods and
* access to our WebGL2 Engine and WebAssembly numerical methods
* @param options Optional parameters of type {@link IPolarAxisOptions} used to configure the axis at instantiation time
*/
function PolarAxisBase(webAssemblyContext, options) {
var _this = this;
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
Object.assign(options !== null && options !== void 0 ? options : {}, {
majorGridLineStyle: __assign({ strokeThickness: 1, color: (_a = SciChartSurfaceBase_1.SciChartSurfaceBase.DEFAULT_THEME.polarMajorGridLineBrush) !== null && _a !== void 0 ? _a : SciChartSurfaceBase_1.SciChartSurfaceBase.DEFAULT_THEME.majorGridLineBrush }, options === null || options === void 0 ? void 0 : options.majorGridLineStyle),
minorGridLineStyle: __assign({ strokeThickness: 1, color: (_b = SciChartSurfaceBase_1.SciChartSurfaceBase.DEFAULT_THEME.polarMinorGridLineBrush) !== null && _b !== void 0 ? _b : SciChartSurfaceBase_1.SciChartSurfaceBase.DEFAULT_THEME.minorGridLineBrush }, options === null || options === void 0 ? void 0 : options.minorGridLineStyle)
});
_this = _super.call(this, webAssemblyContext, options) || this;
_this.isPolarAxis = true;
_this.axisLayoutState = new AxisLayoutState_1.PolarAxisLayoutState();
_this.startAngleProperty = 0;
_this.totalAngleProperty = 2 * Math.PI;
_this.xCenterOffsetProperty = 0;
_this.yCenterOffsetProperty = 0;
_this.lengthScaleProperty = 1;
_this.gridlineModeProperty = PolarGridlineMode_1.EPolarGridlineMode.Circles;
_this.polarLabelModeProperty = PolarLabelMode_1.EPolarLabelMode.Horizontal;
_this.innerRadiusProperty = 0;
_this.polarAxisModeProperty = options === null || options === void 0 ? void 0 : options.polarAxisMode;
_this.gridlineMode = (_c = options === null || options === void 0 ? void 0 : options.gridlineMode) !== null && _c !== void 0 ? _c : _this.gridlineModeProperty;
_this.coordTransform = new webAssemblyContext.SCRTPolarCoordinateTransform(0, 0, 0);
_this.drawMajorBandsProperty = false;
_this.innerRadius = (_d = options === null || options === void 0 ? void 0 : options.innerRadius) !== null && _d !== void 0 ? _d : _this.innerRadiusProperty;
_this.xCenterOffset = (_e = options === null || options === void 0 ? void 0 : options.xCenterOffset) !== null && _e !== void 0 ? _e : _this.xCenterOffsetProperty;
_this.yCenterOffset = (_f = options === null || options === void 0 ? void 0 : options.yCenterOffset) !== null && _f !== void 0 ? _f : _this.yCenterOffsetProperty;
_this.lengthScaleProperty = (_g = options === null || options === void 0 ? void 0 : options.lengthScale) !== null && _g !== void 0 ? _g : _this.lengthScaleProperty;
_this.polarLabelMode = (_h = options === null || options === void 0 ? void 0 : options.polarLabelMode) !== null && _h !== void 0 ? _h : _this.polarLabelModeProperty;
_this.startAngleProperty =
(_j = options === null || options === void 0 ? void 0 : options.startAngle) !== null && _j !== void 0 ? _j : ((options === null || options === void 0 ? void 0 : options.startAngleDegrees) !== undefined
? _this.toRadians(options.startAngleDegrees)
: _this.startAngleProperty);
_this.totalAngleProperty =
(_k = options === null || options === void 0 ? void 0 : options.totalAngle) !== null && _k !== void 0 ? _k : ((options === null || options === void 0 ? void 0 : options.totalAngleDegrees) !== undefined
? _this.toRadians(options.totalAngleDegrees)
: _this.totalAngleProperty);
return _this;
}
PolarAxisBase.prototype.onAttach = function (parentSurface, isXAxis, isPrimaryAxis) {
_super.prototype.onAttach.call(this, parentSurface, isXAxis, isPrimaryAxis);
if (this.polarAxisMode === undefined) {
this.polarAxisModeProperty = isXAxis ? PolarAxisMode_1.EPolarAxisMode.Angular : PolarAxisMode_1.EPolarAxisMode.Radial;
}
};
Object.defineProperty(PolarAxisBase.prototype, "isAngular", {
/** @inheritDoc */
get: function () {
return this.polarAxisModeProperty === PolarAxisMode_1.EPolarAxisMode.Angular;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "polarAxisMode", {
/**
* Gets or sets whether this polar axis is angular or radial. The X and Y axes for a series must be different mode.
*/
get: function () {
return this.polarAxisModeProperty;
},
set: function (value) {
if (this.polarAxisMode !== value) {
this.polarAxisModeProperty = value;
this.notifyPropertyChanged("polarAxisMode");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "gridlineMode", {
/**
* Gets or sets whether the gridlines for the radial axis are drawn as Circles or Polygons (for radar chart).
*/
get: function () {
return this.gridlineModeProperty;
},
set: function (value) {
if (this.gridlineMode !== value) {
if (this.isAngular) {
console.warn("PolarAxisBase.gridlineMode property is ignored for the angular axis");
return;
}
this.gridlineModeProperty = value;
this.notifyPropertyChanged("gridlineMode");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "startAngle", {
/** @inheritDoc */
get: function () {
return this.startAngleProperty;
},
/** @inheritDoc */
set: function (value) {
if (this.startAngleProperty !== value) {
this.startAngleProperty = value;
this.notifyPropertyChanged("startAngle");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "totalAngle", {
/**
* Gets or sets the angular length for an Angular axis. Default 2 pi radians (ie 360 degrees)
*/
get: function () {
return this.totalAngleProperty;
},
set: function (value) {
if (this.totalAngleProperty !== value) {
if (!this.isAngular) {
console.warn("PolarAxisBase.totalAngle property is ignored for the radial axis");
return;
}
if (value === 0) {
console.warn("PolarAxisBase.totalAngle can not be zero");
}
this.totalAngleProperty = value;
this.notifyPropertyChanged("totalAngle");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "startAngleDegrees", {
/**
* Gets or sets the start angle in degrees.
*/
get: function () {
return Math.round(((this.startAngleProperty * 180) / Math.PI) * 10) / 10; // 1 decimal
},
set: function (value) {
if (value !== undefined) {
this.startAngleProperty = this.toRadians(value);
this.notifyPropertyChanged("startAngle");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "totalAngleDegrees", {
/**
* Gets or sets the total angle in degrees.
*/
get: function () {
return Math.round(((this.totalAngleProperty * 180) / Math.PI) * 10) / 10;
},
set: function (value) {
if (value !== undefined) {
if (!this.isAngular) {
console.warn("PolarAxisBase.totalAngleDegrees property is ignored for the radial axis");
return;
}
if (value === 0) {
console.warn("PolarAxisBase.totalAngleDegrees can not be zero");
}
this.totalAngleProperty = this.toRadians(value);
this.notifyPropertyChanged("totalAngle");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "xCenterOffset", {
/** @inheritDoc */
get: function () {
return this.xCenterOffsetProperty;
},
/** @inheritDoc */
set: function (value) {
if (this.xCenterOffsetProperty !== value) {
if (!this.isAngular) {
console.warn("PolarAxisBase.xCenterOffset property is ignored for the radial axis");
return;
}
this.xCenterOffsetProperty = value;
this.notifyPropertyChanged("xCenterOffset");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "yCenterOffset", {
/** @inheritDoc */
get: function () {
return this.yCenterOffsetProperty;
},
/** @inheritDoc */
set: function (value) {
if (this.yCenterOffsetProperty !== value) {
if (!this.isAngular) {
console.warn("PolarAxisBase.yCenterOffset property is ignored for the radial axis");
return;
}
this.yCenterOffsetProperty = value;
this.notifyPropertyChanged("yCenterOffset");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "lengthScale", {
/**
* Gets or sets the scale of the axis used for zooming. Default 1 (one to one scale).
*/
get: function () {
return this.lengthScaleProperty;
},
set: function (value) {
if (this.lengthScaleProperty !== value) {
this.lengthScaleProperty = value;
this.notifyPropertyChanged("lengthScale");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "axisLength", {
/** @inheritDoc */
get: function () {
var _a;
// offset is premultiplied by lengthscale for polar
return ((_a = this.axisLengthProperty) !== null && _a !== void 0 ? _a : 1) * this.lengthScale - this.offset;
},
/** @inheritDoc */
set: function (value) {
if (this.axisLengthProperty !== value) {
this.axisLengthProperty = value;
this.notifyPropertyChanged(constants_1.PROPERTY.AXIS_LENGTH);
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "maxRadius", {
/** The maximum radius as set by layout */
get: function () {
var _a;
return (_a = this.axisLengthProperty) !== null && _a !== void 0 ? _a : 1;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "polarLabelMode", {
/**
* Gets or sets the label mode for angular axis. For radial axis is ignored.
*/
get: function () {
return this.polarLabelModeProperty;
},
set: function (value) {
if (this.polarLabelMode !== value) {
if (!this.isAngular) {
console.warn("PolarAxisBase.polarLabelMode property is ignored for the radial axis");
return;
}
this.polarLabelModeProperty = value;
this.notifyPropertyChanged("polarLabelMode");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "offset", {
/**
* Gets or sets the offset of the axis position.
* Defines a position of the axis along the layout flow.
*/
get: function () {
var _a;
var offset = this.offsetProperty;
if (this.offsetOverrideProperty) {
offset = this.offsetOverrideProperty;
}
else if (this.innerRadius !== undefined) {
offset = this.innerRadius * ((_a = this.axisLengthProperty) !== null && _a !== void 0 ? _a : 1);
}
return offset * this.lengthScale;
},
/**
* Called internally by layout strategies when switching between stacked and non-stacked axes.
* If you want to set a manual offset, call {@link overrideOffset}
*/
set: function (value) {
if (this.offsetProperty !== value) {
this.offsetProperty = value;
if (this.innerRadius === undefined) {
this.clearCoordCalcCache();
this.notifyPropertyChanged(constants_1.PROPERTY.OFFSET);
}
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "innerRadius", {
/**
* Gets or Sets the inner radius for a radial axis as a decimal between 0 and 1 which is treated as a fraction of the maximum radius.
* If you want to set an absolute innerRadius, use overrideOffset
*/
get: function () {
return this.innerRadiusProperty;
},
set: function (value) {
if (this.innerRadius !== value) {
if (this.isAngular) {
console.warn("PolarAxisBase.innerRadius property is ignored for the angular axis");
return;
}
if (value < 0 || value > 1) {
throw Error("innerRadius must be between 0 and 1");
}
this.innerRadiusProperty = value;
this.clearCoordCalcCache();
this.notifyPropertyChanged("innerRadius");
}
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "otherAxis", {
/**
* Gets the other polar axis. Is set in the layout step in {@link PolarAxisBase.measure} method
*/
get: function () {
return this.otherAxisProperty;
},
enumerable: false,
configurable: true
});
/** @inheritDoc */
PolarAxisBase.prototype.measure = function () {
var _this = this;
// Validate axes
// TODO pair up axes - first with first, second with second
if (this.isXAxis) {
var yAxis = this.parentSurface.yAxes
.asArray()
.find(function (a) { return a.isPolarAxis && a.isAngular !== _this.isAngular; });
if (!yAxis) {
throw new Error("Could not find a polar y axis with isAngluar: ".concat(!this.isAngular));
}
this.otherAxisProperty = yAxis;
if (!this.isAngular) {
this.xCenterOffsetProperty = yAxis.xCenterOffset;
this.yCenterOffsetProperty = yAxis.yCenterOffset;
}
}
else {
var xAxis = this.parentSurface.xAxes
.asArray()
.find(function (a) { return a.isPolarAxis && a.isAngular !== _this.isAngular; });
if (!xAxis) {
throw new Error("Could not find a polar x axis with isAngluar: ".concat(!this.isAngular));
}
this.otherAxisProperty = xAxis;
if (!this.isAngular) {
this.xCenterOffsetProperty = xAxis.xCenterOffset;
this.yCenterOffsetProperty = xAxis.yCenterOffset;
}
}
_super.prototype.measure.call(this);
};
/** @inheritDoc */
PolarAxisBase.prototype.zoomBy = function (minFraction, maxFraction) {
if (this.isAngular) {
return _super.prototype.zoomBy.call(this, minFraction, maxFraction);
}
else {
return _super.prototype.zoomBy.call(this, 0, maxFraction / 10);
}
};
/** @inheritDoc */
PolarAxisBase.prototype.scroll = function (pixelsToScroll, clipMode) {
if (this.isAngular) {
return _super.prototype.scroll.call(this, (pixelsToScroll / this.otherAxis.axisLength) * this.axisLength, clipMode);
}
else {
return _super.prototype.scroll.call(this, pixelsToScroll, AxisBase2D_1.EClipMode.ClipAtMin);
}
};
/**
* Return the transform function is used to transform from polar to cartesian coordinates
* @param usePixelRatio is needed for correct transform for SVG annotations
* @returns
*/
PolarAxisBase.prototype.getTransform = function (usePixelRatio) {
if (usePixelRatio === void 0) { usePixelRatio = false; }
var _a = this.viewRect, x = _a.x, y = _a.y;
this.coordTransform.yIsPolar = this.isAngular && !this.isXAxisProperty;
// CenterOffsets are already applied to the viewrect during layout
var divider = usePixelRatio ? DpiHelper_1.DpiHelper.PIXEL_RATIO : 1;
this.coordTransform.XCenter = (x - this.parentSurface.seriesViewRect.left) / divider;
this.coordTransform.YCenter = (y - this.parentSurface.seriesViewRect.top) / divider;
this.coordTransform.StartAngle = this.startAngle;
return this.coordTransform;
};
Object.defineProperty(PolarAxisBase.prototype, "isHorizontalAxis", {
/**
* Gets whether the axis is currently horizontal or not
*/
get: function () {
// Angular axes are considered horizontal for the purposes of measuring
return this.isAngular;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PolarAxisBase.prototype, "isVerticalChart", {
/** @inheritDoc */
get: function () {
return this.isXAxis && !this.isAngular;
},
enumerable: false,
configurable: true
});
/** @inheritDoc */ // todo
PolarAxisBase.prototype.applyTheme = function (themeProvider) {
var _a, _b, _c, _d;
var previousThemeProvider = this.parentSurface.previousThemeProvider;
if (this.axisBandsFill === previousThemeProvider.axisBandsFill) {
this.axisBandsFill = themeProvider.axisBandsFill;
}
if (this.labelStyle.color === previousThemeProvider.tickTextBrush) {
this.labelStyle = { color: themeProvider.tickTextBrush };
}
var prevminorGridlineStroke = (_a = previousThemeProvider.polarMinorGridLineBrush) !== null && _a !== void 0 ? _a : previousThemeProvider.minorGridLineBrush;
var minorGridlineStroke = (_b = themeProvider.polarMinorGridLineBrush) !== null && _b !== void 0 ? _b : themeProvider.minorGridLineBrush;
if (this.minorGridLineStyle.color === prevminorGridlineStroke) {
this.minorGridLineStyle = { color: minorGridlineStroke };
}
var prevmajorGridlineStroke = (_c = previousThemeProvider.polarMajorGridLineBrush) !== null && _c !== void 0 ? _c : previousThemeProvider.majorGridLineBrush;
var majorGridlineStroke = (_d = themeProvider.polarMajorGridLineBrush) !== null && _d !== void 0 ? _d : themeProvider.majorGridLineBrush;
if (this.majorGridLineStyle.color === prevmajorGridlineStroke) {
this.majorGridLineStyle = { color: majorGridlineStroke };
}
if (this.minorTickLineStyle.color === previousThemeProvider.minorGridLineBrush) {
this.minorTickLineStyle = { color: themeProvider.minorGridLineBrush };
}
if (this.majorTickLineStyle.color === previousThemeProvider.majorGridLineBrush) {
this.majorTickLineStyle = { color: themeProvider.majorGridLineBrush };
}
if (this.axisTitleStyle.color === previousThemeProvider.axisTitleColor) {
this.axisTitleStyle = { color: themeProvider.axisTitleColor };
}
};
PolarAxisBase.prototype.toJSON = function () {
var json = _super.prototype.toJSON.call(this);
var options = {
gridlineMode: this.gridlineMode,
innerRadius: this.innerRadius,
lengthScale: this.lengthScale,
polarAxisMode: this.polarAxisMode,
polarLabelMode: this.polarLabelMode,
startAngle: this.startAngle,
totalAngle: this.totalAngle,
xCenterOffset: this.xCenterOffset,
yCenterOffset: this.yCenterOffset
};
var res = __assign(__assign({}, json), { options: __assign(__assign({}, json.options), options) });
return res;
};
/** @inheritDoc */
PolarAxisBase.prototype.delete = function () {
this.coordTransform = (0, Deleter_1.deleteSafe)(this.coordTransform);
_super.prototype.delete.call(this);
};
/** @inheritDoc */
PolarAxisBase.prototype.drawAxisBands = function (renderContext, ticks, tickCoords, brush) { };
/** @inheritDoc */
PolarAxisBase.prototype.getPenForLines = function (penCache, stroke, strokeThickness, strokeDashArray) {
if (penCache === this.penCacheForMajorGridLines || penCache === this.penCacheForMinorGridLines) {
if (!this.isAngular && this.gridlineMode === PolarGridlineMode_1.EPolarGridlineMode.Circles) {
return (0, Pen2DCache_1.createPenInCache)(penCache, stroke, strokeThickness, 1, strokeDashArray, false);
}
}
var strokeThickness2 = strokeThickness > 0 ? strokeThickness + 1 : 0;
return (0, Pen2DCache_1.createPenInCache)(penCache, stroke, strokeThickness2, 1, strokeDashArray, true);
};
/** @inheritDoc */
PolarAxisBase.prototype.drawGridLines = function (renderContext, tickCoords, linesPen, isMajor) {
var _this = this;
var _a, _b, _c, _d;
if (!tickCoords || tickCoords.length === 0)
return;
var leftPad = ((_b = (_a = this.parentSurface.padding) === null || _a === void 0 ? void 0 : _a.left) !== null && _b !== void 0 ? _b : 0) * DpiHelper_1.DpiHelper.PIXEL_RATIO;
var topPad = ((_d = (_c = this.parentSurface.padding) === null || _c === void 0 ? void 0 : _c.top) !== null && _d !== void 0 ? _d : 0) * DpiHelper_1.DpiHelper.PIXEL_RATIO;
var _e = this.viewRect, x = _e.x, y = _e.y, maxRadius = _e.width;
var transform = this.getTransform();
maxRadius = maxRadius * this.otherAxis.lengthScale;
var clipRect = Rect_1.Rect.intersect(this.parentSurface.clipRect, this.parentSurface.seriesViewRect);
if (this.isAngular) {
var vertices_1 = (0, NativeObject_1.getVectorColorVertex)(this.webAssemblyContext2D);
var vec_1 = (0, NativeObject_1.getVector2)(this.webAssemblyContext2D);
var vertex_1 = (0, NativeObject_1.getVertex)(this.webAssemblyContext2D, 0, 0);
var minorInnerRadius_1 = 15;
tickCoords.forEach(function (tc, index) {
transform.TransformPoint(maxRadius, tc, vec_1);
vertex_1.SetPosition(vec_1.x, vec_1.y);
vertices_1.push_back(vertex_1);
if (_this.otherAxis.offset > 0) {
transform.TransformPoint(_this.otherAxis.offset, tc, vec_1);
vertex_1.SetPosition(vec_1.x, vec_1.y);
vertices_1.push_back(vertex_1);
}
else {
if (isMajor) {
// draw to center
vertex_1.SetPosition(transform.XCenter, transform.YCenter);
vertices_1.push_back(vertex_1);
}
else {
// stop close to center to avoid center mess
transform.TransformPoint(minorInnerRadius_1, tc, vec_1);
vertex_1.SetPosition(vec_1.x, vec_1.y);
vertices_1.push_back(vertex_1);
}
}
});
renderContext.drawLinesNative(vertices_1, linesPen, WebGlRenderContext2D_1.ELineDrawMode.DiscontinuousLine, clipRect, leftPad, topPad);
}
else {
if (this.gridlineMode === PolarGridlineMode_1.EPolarGridlineMode.Polygons) {
var angles_1 = this.otherAxis.getTicksWithCoords().majorTickCoords;
var vertices_2 = (0, NativeObject_1.getVectorColorVertex)(this.webAssemblyContext2D);
var vec_2 = (0, NativeObject_1.getVector2)(this.webAssemblyContext2D);
var vertex_2 = (0, NativeObject_1.getVertex)(this.webAssemblyContext2D, 0, 0);
tickCoords.forEach(function (tc) {
angles_1.forEach(function (angle, i) {
transform.TransformPoint(tc, angle, vec_2);
vertex_2.SetPosition(vec_2.x, vec_2.y);
vertices_2.push_back(vertex_2);
if (i > 0 && i < angles_1.length - 1) {
vertices_2.push_back(vertex_2);
}
});
});
renderContext.drawLinesNative(vertices_2, linesPen, WebGlRenderContext2D_1.ELineDrawMode.DiscontinuousLine, clipRect, leftPad, topPad);
}
else {
// Circle gridlines
var vecArcs_1 = (0, NativeObject_1.getVectorArcVertex)(this.webAssemblyContext2D);
var arc_1 = (0, NativeObject_1.getArcVertex)(this.webAssemblyContext2D);
//const solidBrush = this.solidBrushCacheAxisBands.newBrush(this.axisBandsFill, true);
var vpHeight_1 = 0;
if (this.parentSurface.isCopyCanvasSurface)
vpHeight_1 = SciChartSurfaceBase_1.SciChartSurfaceBase.domMasterCanvas.height;
else
vpHeight_1 = this.parentSurface.renderSurface.viewportSize.height;
var startAngle = this.otherAxis.startAngle;
var endAngle_1 = this.otherAxis.axisLength;
tickCoords.forEach(function (tc) {
var arcParms = (0, NativeObject_1.getArcParams)(_this.webAssemblyContext2D, transform.XCenter, vpHeight_1 - transform.YCenter, 0, endAngle_1, tc, 0, 1, 1, linesPen.m_fThickness);
arc_1.MakeCircularArc(arcParms);
vecArcs_1.push_back(arc_1);
});
renderContext.drawArcs(vecArcs_1, transform.XCenter, vpHeight_1 - transform.YCenter, startAngle, clipRect, linesPen, undefined, leftPad, topPad);
}
}
};
/** Converts angle from degrees to radians */
PolarAxisBase.prototype.toRadians = function (angleInDegrees) {
return (angleInDegrees * Math.PI) / 180;
};
/**
* Converts from cartesian to polar coordinates
* @param x - X cartesian coordinate
* @param y - Y cartesian coordinate
* @returns {@link Point} where Point.x is angle and Point.y is radius
*/
PolarAxisBase.prototype.reverseTransform = function (x, y, flipXYForVertical) {
if (flipXYForVertical === void 0) { flipXYForVertical = true; }
var transform = this.getTransform();
var vec = new this.webAssemblyContext2D.TSRVector2();
transform.ReverseTransformPoint(x, y, vec);
var ppoint;
if (flipXYForVertical) {
// if true Polar chart is NOT vertical
if (this.isXAxis && this.isAngular) {
ppoint = new Point_1.Point(-vec.y, vec.x);
}
else {
ppoint = new Point_1.Point(vec.x, -vec.y);
}
}
else {
if (this.isXAxis) {
ppoint = new Point_1.Point(-vec.y, vec.x);
}
else {
ppoint = new Point_1.Point(vec.x, -vec.y);
}
}
vec.delete();
return ppoint;
};
PolarAxisBase.prototype.switchAxisRenderer = function (useNativeText) {
// no need to switch. The same PolarAxisRenderer renderer supports both modes
};
PolarAxisBase.prototype.createAxisRender = function () {
return new PolarAxisRenderer_1.PolarAxisRenderer(this.webAssemblyContext2D);
};
return PolarAxisBase;
}(AxisBase2D_1.AxisBase2D));
exports.PolarAxisBase = PolarAxisBase;