scichart 3.0.301 → 3.1.329

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/Charting/Drawing/Pen2DCache.d.ts +1 -1
  2. package/Charting/Drawing/Pen2DCache.js +3 -2
  3. package/Charting/Services/ChartTitleRenderer.d.ts +37 -0
  4. package/Charting/Services/ChartTitleRenderer.js +176 -0
  5. package/Charting/Services/SciChartRenderer.d.ts +7 -1
  6. package/Charting/Services/SciChartRenderer.js +60 -9
  7. package/Charting/Services/TitleRenderer.d.ts +91 -0
  8. package/Charting/Services/TitleRenderer.js +190 -0
  9. package/Charting/Themes/IThemeProvider.d.ts +16 -0
  10. package/Charting/Themes/SciChartJSDarkTheme.d.ts +2 -0
  11. package/Charting/Themes/SciChartJSDarkTheme.js +2 -0
  12. package/Charting/Themes/SciChartJSLightTheme.d.ts +2 -0
  13. package/Charting/Themes/SciChartJSLightTheme.js +2 -0
  14. package/Charting/Visuals/Annotations/AnnotationBase.d.ts +12 -1
  15. package/Charting/Visuals/Annotations/AnnotationBase.js +25 -2
  16. package/Charting/Visuals/Annotations/BoxAnnotation.js +1 -1
  17. package/Charting/Visuals/Annotations/NativeTextAnnotation.js +1 -5
  18. package/Charting/Visuals/Annotations/SvgAnnotationBase.js +2 -1
  19. package/Charting/Visuals/Axis/AxisBase2D.js +2 -2
  20. package/Charting/Visuals/Axis/AxisCore.d.ts +9 -1
  21. package/Charting/Visuals/Axis/AxisRenderer.d.ts +0 -1
  22. package/Charting/Visuals/Axis/AxisRenderer.js +7 -7
  23. package/Charting/Visuals/Axis/AxisTitleRenderer.d.ts +7 -2
  24. package/Charting/Visuals/Axis/AxisTitleRenderer.js +28 -2
  25. package/Charting/Visuals/Axis/LabelProvider/LabelProviderBase2D.d.ts +5 -12
  26. package/Charting/Visuals/Axis/LabelProvider/LabelProviderBase2D.js +8 -55
  27. package/Charting/Visuals/Axis/LabelProvider/TextLabelProvider.d.ts +0 -1
  28. package/Charting/Visuals/Axis/LabelProvider/TextLabelProvider.js +0 -60
  29. package/Charting/Visuals/I2DSurfaceOptions.d.ts +9 -0
  30. package/Charting/Visuals/RenderableSeries/FastColumnRenderableSeries.d.ts +2 -2
  31. package/Charting/Visuals/RenderableSeries/FastColumnRenderableSeries.js +2 -2
  32. package/Charting/Visuals/SciChartDefaults.d.ts +2 -3
  33. package/Charting/Visuals/SciChartDefaults.js +2 -3
  34. package/Charting/Visuals/SciChartSurface.d.ts +29 -0
  35. package/Charting/Visuals/SciChartSurface.js +100 -7
  36. package/Charting/Visuals/TextureManager/DpiHelper.js +1 -1
  37. package/Charting/Visuals/TextureManager/TextureManager.js +32 -17
  38. package/Charting3D/Visuals/SciChart3DSurface.js +6 -2
  39. package/Core/BuildStamp.d.ts +1 -1
  40. package/Core/BuildStamp.js +2 -2
  41. package/_wasm/scichart.browser.js +1 -1
  42. package/_wasm/scichart2d.js +7 -7
  43. package/_wasm/scichart2d.wasm +0 -0
  44. package/_wasm/scichart3d.js +16 -16
  45. package/_wasm/scichart3d.wasm +0 -0
  46. package/index.d.ts +14 -1
  47. package/index.js +21 -12
  48. package/index.min.js +1 -1
  49. package/package.json +1 -1
  50. package/types/NumberArray.js +2 -1
  51. package/types/TextStyle.d.ts +97 -0
  52. package/types/TextStyle.js +86 -0
  53. package/utils/imageUtil.js +1 -0
  54. package/utils/text.d.ts +8 -1
  55. package/utils/text.js +23 -1
  56. package/Charting/Services/Workers/TextureWorker.d.ts +0 -16
  57. package/Charting/Services/Workers/TextureWorker.js +0 -142
  58. package/Charting/Services/Workers/TextureWorkerSource.d.ts +0 -1
  59. package/Charting/Services/Workers/TextureWorkerSource.js +0 -133
@@ -0,0 +1,190 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TitleRendererBase = void 0;
4
+ var Deleter_1 = require("../../Core/Deleter");
5
+ var Rect_1 = require("../../Core/Rect");
6
+ var TextPosition_1 = require("../../types/TextPosition");
7
+ var TextStyle_1 = require("../../types/TextStyle");
8
+ var parseColor_1 = require("../../utils/parseColor");
9
+ var createNativeRect_1 = require("../Visuals/Helpers/createNativeRect");
10
+ var NativeObject_1 = require("../Visuals/Helpers/NativeObject");
11
+ var DpiHelper_1 = require("../Visuals/TextureManager/DpiHelper");
12
+ var TextureManager_1 = require("../Visuals/TextureManager/TextureManager");
13
+ var TitleRendererBase = /** @class */ (function () {
14
+ function TitleRendererBase(webAssemblyContext) {
15
+ this.drawDebug = false;
16
+ this.useCache = true;
17
+ this.viewRectProperty = Rect_1.Rect.createZero();
18
+ /**
19
+ * The height taken by the text with normal(horizontal) orientation including padding
20
+ */
21
+ this.textHeight = 0;
22
+ /**
23
+ * The width taken by the text with normal(horizontal) orientation including padding
24
+ */
25
+ this.textWidth = 0;
26
+ /**
27
+ * The height taken by the text considering current orientation orientation including padding
28
+ */
29
+ this.desiredHeightProperty = 0;
30
+ /**
31
+ * The width taken by the text considering current orientation orientation including padding
32
+ */
33
+ this.desiredWidthProperty = 0;
34
+ this.webAssemblyContext = webAssemblyContext;
35
+ this.textureManager = new TextureManager_1.TextureManager(webAssemblyContext);
36
+ this.onDpiChanged = this.onDpiChanged.bind(this);
37
+ DpiHelper_1.DpiHelper.dpiChanged.subscribe(this.onDpiChanged);
38
+ }
39
+ Object.defineProperty(TitleRendererBase.prototype, "viewRect", {
40
+ /**
41
+ * Defines a bounding {@link Rect} containing the title text
42
+ */
43
+ get: function () {
44
+ return this.viewRectProperty;
45
+ },
46
+ enumerable: false,
47
+ configurable: true
48
+ });
49
+ // TODO consider if this class should be abstract
50
+ TitleRendererBase.prototype.measure = function () {
51
+ var params = [];
52
+ for (var _i = 0; _i < arguments.length; _i++) {
53
+ params[_i] = arguments[_i];
54
+ }
55
+ };
56
+ TitleRendererBase.prototype.layout = function (originRect) { };
57
+ TitleRendererBase.prototype.draw = function () {
58
+ var params = [];
59
+ for (var _i = 0; _i < arguments.length; _i++) {
60
+ params[_i] = arguments[_i];
61
+ }
62
+ };
63
+ TitleRendererBase.prototype.delete = function () {
64
+ this.resetCache();
65
+ DpiHelper_1.DpiHelper.dpiChanged.unsubscribe(this.onDpiChanged);
66
+ };
67
+ TitleRendererBase.prototype.resetCache = function () {
68
+ this.invalidateCache();
69
+ };
70
+ TitleRendererBase.prototype.invalidateCache = function () {
71
+ var _a;
72
+ this.text = undefined;
73
+ this.textStyle = undefined;
74
+ this.originalTextStyle = undefined;
75
+ (0, Deleter_1.deleteSafe)((_a = this.texture) === null || _a === void 0 ? void 0 : _a.bitmapTexture);
76
+ this.texture = undefined;
77
+ };
78
+ TitleRendererBase.prototype.onDpiChanged = function (args) {
79
+ this.resetCache();
80
+ };
81
+ /**
82
+ * Performs rendering of the title
83
+ */
84
+ TitleRendererBase.prototype.drawInternal = function (renderContext, useNativeText, titlePosition, lineSpacing) {
85
+ if (!this.text) {
86
+ return;
87
+ }
88
+ if (useNativeText) {
89
+ this.drawWithNativeText(renderContext, titlePosition);
90
+ }
91
+ else {
92
+ this.drawWithTexture(renderContext, titlePosition);
93
+ }
94
+ // if (this.drawDebug) {
95
+ // this.drawTitleDebugViewRect(renderContext);
96
+ // }
97
+ };
98
+ TitleRendererBase.prototype.drawWithNativeText = function (renderContext, position) {
99
+ var titleText = Array.isArray(this.text) ? this.text.join("\n") : this.text;
100
+ // @ts-ignore mismatch with TTextStyle
101
+ var nativeFont = renderContext.getFont(this.textStyle, true);
102
+ // calculate start coordinates for native text drawing;
103
+ // the start point is the beginning of alphabetic text baseline
104
+ var tx = this.viewRect.left + this.textStyle.padding.left;
105
+ var ty = this.viewRect.top + this.textStyle.padding.top + this.firstLineAscent;
106
+ var adjRotation = 0;
107
+ // let adjRotation = this.textStyle.rotation;
108
+ if (position === TextStyle_1.ETitlePosition.Left) {
109
+ adjRotation += -90;
110
+ tx = this.viewRect.left + this.textStyle.padding.top + this.firstLineAscent;
111
+ ty = this.viewRect.bottom - this.textStyle.padding.left;
112
+ }
113
+ else if (position === TextStyle_1.ETitlePosition.Right) {
114
+ adjRotation += 90;
115
+ tx = this.viewRect.right - this.textStyle.padding.top - this.firstLineAscent;
116
+ ty = this.viewRect.top + this.textStyle.padding.left;
117
+ }
118
+ var rotationRad = -(adjRotation * Math.PI) / 180;
119
+ var nativeMultilineAlignment = (0, TextPosition_1.convertMultiLineAlignment)(this.textStyle.multilineAlignment, this.webAssemblyContext);
120
+ var textColor = (0, parseColor_1.parseColorToUIntArgb)(this.textStyle.color);
121
+ nativeFont.DrawStringAdvanced(titleText, textColor, Math.round(tx), Math.round(ty), (0, NativeObject_1.getVector4)(this.webAssemblyContext, tx, ty, rotationRad, 0), nativeMultilineAlignment, this.nativeLineSpacing);
122
+ };
123
+ TitleRendererBase.prototype.drawWithTexture = function (renderContext, titlePosition) {
124
+ var _a = this.texture, bitmapTexture = _a.bitmapTexture, textureHeight = _a.textureHeight, textureWidth = _a.textureWidth;
125
+ if (bitmapTexture) {
126
+ try {
127
+ var nativeContext = renderContext.getNativeContext();
128
+ nativeContext.DrawTexture(bitmapTexture, Math.round(this.viewRect.left), Math.round(this.viewRect.top), textureWidth, textureHeight);
129
+ if (!this.useCache) {
130
+ bitmapTexture.delete();
131
+ this.texture = undefined;
132
+ }
133
+ }
134
+ catch (err) {
135
+ console.error("Error while drawing title: ", err);
136
+ // webgl context probably lost. Clear the cache
137
+ this.resetCache();
138
+ }
139
+ }
140
+ };
141
+ /**
142
+ * Calculates the {@link TitleRenderer.viewRect}
143
+ */
144
+ TitleRendererBase.prototype.getViewRect = function (title, originRect, titlePosition, alignment) {
145
+ if (title === void 0) { title = ""; }
146
+ if (!title) {
147
+ return Rect_1.Rect.createZero();
148
+ }
149
+ var hasHorizontalPlacement = (0, TextStyle_1.getIsHorizontalPlacement)(titlePosition);
150
+ var alignmentDelta = this.getAlignmentAdjustmentDelta(hasHorizontalPlacement ? originRect.width : originRect.height, titlePosition, alignment);
151
+ switch (titlePosition) {
152
+ case TextStyle_1.ETitlePosition.Top:
153
+ return new Rect_1.Rect(originRect.x + alignmentDelta, originRect.y, this.textWidth, this.textHeight);
154
+ case TextStyle_1.ETitlePosition.Bottom:
155
+ return new Rect_1.Rect(originRect.x + alignmentDelta, originRect.bottom - this.textHeight, this.textWidth, this.textHeight);
156
+ case TextStyle_1.ETitlePosition.Left:
157
+ return new Rect_1.Rect(originRect.x, originRect.y + alignmentDelta, this.textHeight, this.textWidth);
158
+ case TextStyle_1.ETitlePosition.Right:
159
+ return new Rect_1.Rect(originRect.right - this.textHeight, originRect.y + alignmentDelta, this.textHeight, this.textWidth);
160
+ default:
161
+ return (0, TextStyle_1.handleInvalidChartTitlePosition)(titlePosition);
162
+ }
163
+ };
164
+ TitleRendererBase.prototype.drawTitleDebugViewRect = function (renderContext) {
165
+ var viewRect = this.viewRect;
166
+ var vecRects = (0, NativeObject_1.getVectorRectVertex)(this.webAssemblyContext);
167
+ var brush = new this.webAssemblyContext.SCRTSolidBrush((0, parseColor_1.parseColorToUIntArgb)("rgba(0,255,0,0.7)"), false);
168
+ var nativeRect = (0, createNativeRect_1.createNativeRect)(this.webAssemblyContext, 0, 0, viewRect.width, viewRect.height);
169
+ vecRects.push_back(nativeRect);
170
+ renderContext.drawRects(vecRects, brush, viewRect.left, viewRect.top);
171
+ brush.delete();
172
+ };
173
+ /**
174
+ * Calculates the offset of title text alignment defined by {@link TChartTitleStyle.alignment} or {@link TTextStyle.alignment}
175
+ */
176
+ TitleRendererBase.prototype.getAlignmentAdjustmentDelta = function (availableSpace, position, alignment) {
177
+ switch (alignment) {
178
+ case TextStyle_1.ETextAlignment.Center:
179
+ return availableSpace / 2 - this.textWidth / 2;
180
+ case TextStyle_1.ETextAlignment.Left:
181
+ return position === TextStyle_1.ETitlePosition.Left ? availableSpace - this.textWidth : 0;
182
+ case TextStyle_1.ETextAlignment.Right:
183
+ return position === TextStyle_1.ETitlePosition.Left ? 0 : availableSpace - this.textWidth;
184
+ default:
185
+ return (0, TextStyle_1.handleInvalidTextAlignment)(alignment);
186
+ }
187
+ };
188
+ return TitleRendererBase;
189
+ }());
190
+ exports.TitleRendererBase = TitleRendererBase;
@@ -234,6 +234,11 @@ export interface IThemeProvider {
234
234
  * @remarks Acceptable values include RGB format e.g. ```#FF0000```, RGBA format e.g. ```#FF000077`` and RGBA format e.g. ```rgba(255,0,0,0.5)```
235
235
  */
236
236
  axisTitleColor: string;
237
+ /**
238
+ * The default Chart Title color applied as an HTML color code
239
+ * @remarks Acceptable values include RGB format e.g. ```#FF0000```, RGBA format e.g. ```#FF000077`` and RGBA format e.g. ```rgba(255,0,0,0.5)```
240
+ */
241
+ chartTitleColor: string;
237
242
  /**
238
243
  * The default shadow effect color applied to drop-shadows
239
244
  * @remarks Acceptable values include RGB format e.g. ```#FF0000```, RGBA format e.g. ```#FF000077`` and RGBA format e.g. ```rgba(255,0,0,0.5)```
@@ -468,6 +473,11 @@ export interface IThemePartial {
468
473
  * @remarks Acceptable values include RGB format e.g. ```#FF0000```, RGBA format e.g. ```#FF000077`` and RGBA format e.g. ```rgba(255,0,0,0.5)```
469
474
  */
470
475
  axisTitleColor?: string;
476
+ /**
477
+ * The default Chart Title color applied as an HTML color code
478
+ * @remarks Acceptable values include RGB format e.g. ```#FF0000```, RGBA format e.g. ```#FF000077`` and RGBA format e.g. ```rgba(255,0,0,0.5)```
479
+ */
480
+ chartTitleColor?: string;
471
481
  /**
472
482
  * The default shadow effect color applied to drop-shadows
473
483
  * @remarks Acceptable values include RGB format e.g. ```#FF0000```, RGBA format e.g. ```#FF000077`` and RGBA format e.g. ```rgba(255,0,0,0.5)```
@@ -536,6 +546,7 @@ export declare abstract class ThemeProvider implements IThemeProvider {
536
546
  abstract impulseFillBrush: string;
537
547
  abstract defaultColorMapBrush: TGradientStop[];
538
548
  abstract axisTitleColor: string;
549
+ abstract chartTitleColor: string;
539
550
  abstract shadowEffectColor: string;
540
551
  abstract planeBorderColor: string;
541
552
  abstract axisPlaneBackgroundFill: string;
@@ -745,6 +756,11 @@ export declare abstract class ThemeProvider implements IThemeProvider {
745
756
  * @remarks Acceptable values include RGB format e.g. ```#FF0000```, RGBA format e.g. ```#FF000077`` and RGBA format e.g. ```rgba(255,0,0,0.5)```
746
757
  */
747
758
  axisTitleColor?: string;
759
+ /**
760
+ * The default Chart Title color applied as an HTML color code
761
+ * @remarks Acceptable values include RGB format e.g. ```#FF0000```, RGBA format e.g. ```#FF000077`` and RGBA format e.g. ```rgba(255,0,0,0.5)```
762
+ */
763
+ chartTitleColor?: string;
748
764
  /**
749
765
  * The default shadow effect color applied to drop-shadows
750
766
  * @remarks Acceptable values include RGB format e.g. ```#FF0000```, RGBA format e.g. ```#FF000077`` and RGBA format e.g. ```rgba(255,0,0,0.5)```
@@ -122,6 +122,8 @@ export declare class SciChartJSDarkTheme extends ThemeProvider {
122
122
  /** @inheritDoc */
123
123
  axisTitleColor: string;
124
124
  /** @inheritDoc */
125
+ chartTitleColor: string;
126
+ /** @inheritDoc */
125
127
  shadowEffectColor: string;
126
128
  /** @inheritDoc */
127
129
  planeBorderColor: string;
@@ -144,6 +144,8 @@ var SciChartJSDarkTheme = /** @class */ (function (_super) {
144
144
  /** @inheritDoc */
145
145
  _this.axisTitleColor = "#C8C7C3FF";
146
146
  /** @inheritDoc */
147
+ _this.chartTitleColor = "#C8C7C3FF";
148
+ /** @inheritDoc */
147
149
  _this.shadowEffectColor = "#000000FF";
148
150
  /** @inheritDoc */
149
151
  _this.planeBorderColor = "#333333FF";
@@ -126,6 +126,8 @@ export declare class SciChartJSLightTheme extends ThemeProvider {
126
126
  /** @inheritDoc */
127
127
  axisTitleColor: string;
128
128
  /** @inheritDoc */
129
+ chartTitleColor: string;
130
+ /** @inheritDoc */
129
131
  shadowEffectColor: string;
130
132
  /** @inheritDoc */
131
133
  planeBorderColor: string;
@@ -148,6 +148,8 @@ var SciChartJSLightTheme = /** @class */ (function (_super) {
148
148
  /** @inheritDoc */
149
149
  _this.axisTitleColor = "#777777FF";
150
150
  /** @inheritDoc */
151
+ _this.chartTitleColor = "#777777FF";
152
+ /** @inheritDoc */
151
153
  _this.shadowEffectColor = "#A0AABAFA";
152
154
  /** @inheritDoc */
153
155
  _this.planeBorderColor = "#EEEEEEFF";
@@ -10,6 +10,9 @@ import { AnnotationClickEventArgs } from "./AnnotationClickEventArgs";
10
10
  import { AnnotationDragDeltaEventArgs } from "./AnnotationDragDeltaEventArgs";
11
11
  import { IAdornerProvider } from "./IAdornerProvider";
12
12
  import { EAnnotationLayer, EAnnotationType, IAnnotation } from "./IAnnotation";
13
+ /**
14
+ * Defines possible parts of an annotation which could be interacted with a cursor to do dragging or resizing
15
+ */
13
16
  export declare enum EDraggingGripPoint {
14
17
  /** x1,y1 */
15
18
  x1y1 = "x1y1",
@@ -232,9 +235,9 @@ export declare abstract class AnnotationBase implements IAnnotation, IAdornerPro
232
235
  readonly isSvgAnnotation: boolean;
233
236
  /** @inheritDoc */
234
237
  invalidateParentCallback: () => void;
235
- adornerDraggingPoint: EDraggingGripPoint;
236
238
  selectedChanged: EventHandler<boolean>;
237
239
  clicked: EventHandler<AnnotationClickEventArgs>;
240
+ protected adornerDraggingPointProperty: EDraggingGripPoint;
238
241
  protected svgAdorner: SVGElement;
239
242
  protected prevIsSelected: boolean;
240
243
  /** the annotation absolute coordinates */
@@ -277,6 +280,14 @@ export declare abstract class AnnotationBase implements IAnnotation, IAdornerPro
277
280
  get annotationLayer(): EAnnotationLayer;
278
281
  /** @inheritDoc */
279
282
  set annotationLayer(annotationCanvas: EAnnotationLayer);
283
+ /**
284
+ * Gets or sets current {@link EDraggingGripPoint}
285
+ */
286
+ get adornerDraggingPoint(): EDraggingGripPoint;
287
+ /**
288
+ * Gets or sets current {@link EDraggingGripPoint}
289
+ */
290
+ protected set adornerDraggingPoint(value: EDraggingGripPoint);
280
291
  /** @inheritDoc */
281
292
  get parentSurface(): SciChartSurface;
282
293
  /** @inheritDoc */
@@ -16,6 +16,9 @@ var AnnotationClickEventArgs_1 = require("./AnnotationClickEventArgs");
16
16
  var AnnotationDragDeltaEventArgs_1 = require("./AnnotationDragDeltaEventArgs");
17
17
  var constants_1 = require("./constants");
18
18
  var IAnnotation_1 = require("./IAnnotation");
19
+ /**
20
+ * Defines possible parts of an annotation which could be interacted with a cursor to do dragging or resizing
21
+ */
19
22
  var EDraggingGripPoint;
20
23
  (function (EDraggingGripPoint) {
21
24
  /** x1,y1 */
@@ -177,6 +180,28 @@ var AnnotationBase = /** @class */ (function () {
177
180
  enumerable: false,
178
181
  configurable: true
179
182
  });
183
+ Object.defineProperty(AnnotationBase.prototype, "adornerDraggingPoint", {
184
+ /**
185
+ * Gets or sets current {@link EDraggingGripPoint}
186
+ */
187
+ get: function () {
188
+ return this.adornerDraggingPointProperty;
189
+ },
190
+ /**
191
+ * Gets or sets current {@link EDraggingGripPoint}
192
+ */
193
+ set: function (value) {
194
+ var _a;
195
+ if (this.adornerDraggingPointProperty !== value) {
196
+ this.adornerDraggingPointProperty = value;
197
+ if (value) {
198
+ (_a = this.dragStarted) === null || _a === void 0 ? void 0 : _a.raiseEvent();
199
+ }
200
+ }
201
+ },
202
+ enumerable: false,
203
+ configurable: true
204
+ });
180
205
  Object.defineProperty(AnnotationBase.prototype, "parentSurface", {
181
206
  /** @inheritDoc */
182
207
  get: function () {
@@ -563,8 +588,6 @@ var AnnotationBase = /** @class */ (function () {
563
588
  };
564
589
  AnnotationBase.prototype.calcDragDistance = function (xyPoint) { };
565
590
  AnnotationBase.prototype.onDragStarted = function (args) {
566
- var _a;
567
- (_a = this.dragStarted) === null || _a === void 0 ? void 0 : _a.raiseEvent();
568
591
  return false;
569
592
  };
570
593
  AnnotationBase.prototype.checkIsClickedOnAnnotation = function (x, y) {
@@ -166,7 +166,7 @@ var BoxAnnotation = /** @class */ (function (_super) {
166
166
  _super.prototype.onDragStarted.call(this, args);
167
167
  var _a = this.getAnnotationBorders(false, true), x1 = _a.x1, x2 = _a.x2, y1 = _a.y1, y2 = _a.y2;
168
168
  var _b = annotationHelpers_1.annotationHelpers.calcNewApex(x1, y1, x2, y2, this.isVerticalChart), x1y1 = _b.x1y1, x2y1 = _b.x2y1, x1y2 = _b.x1y2, x2y2 = _b.x2y2;
169
- var xyMousePoint = (0, translate_1.translateFromCanvasToSeriesViewRect)(new Point_1.Point(args.mousePoint.x, args.mousePoint.y), this.parentSurface.seriesViewRect);
169
+ var xyMousePoint = (0, translate_1.translateFromCanvasToSeriesViewRect)(new Point_1.Point(args.mousePoint.x, args.mousePoint.y), this.parentSurface.seriesViewRect, true);
170
170
  if (x1y1 && this.canDragPoint(AnnotationBase_1.EDraggingGripPoint.x1y1)) {
171
171
  var dist = (0, pointUtil_1.calcDistance)(x1y1.x, x1y1.y, xyMousePoint.x, xyMousePoint.y);
172
172
  if (dist < this.annotationsGripsRadius * DpiHelper_1.DpiHelper.PIXEL_RATIO) {
@@ -360,11 +360,7 @@ var NativeTextAnnotation = /** @class */ (function (_super) {
360
360
  x1 -= textBounds.m_fWidth;
361
361
  }
362
362
  if (this.verticalAnchorPointProperty === AnchorPoint_1.EVerticalAnchorPoint.Center) {
363
- y1 += textBounds.GetLineBounds(0).m_fHeight / 2;
364
- y1 -=
365
- ((textBounds.GetLineBounds(0).m_fHeight - textBounds.GetLineBounds(0).m_fOffsetY) *
366
- (textBounds.GetLinesCount() - 1)) /
367
- 2;
363
+ y1 -= textBounds.m_fHeight / 2 - textBounds.GetLineBounds(0).m_fHeight;
368
364
  }
369
365
  else if (this.verticalAnchorPointProperty === AnchorPoint_1.EVerticalAnchorPoint.Top) {
370
366
  y1 += textBounds.GetLineBounds(0).m_fHeight;
@@ -297,7 +297,8 @@ var SvgAnnotationBase = /** @class */ (function (_super) {
297
297
  return;
298
298
  var borderX1 = this.getX1Coordinate(xCalc, yCalc) + this.xCoordShift;
299
299
  var borderY1 = this.getY1Coordinate(xCalc, yCalc) + this.yCoordShift;
300
- this.svgDOMRect = this.svg.getBoundingClientRect();
300
+ // @ts-ignore
301
+ this.svgDOMRect = this.svg.getBBox();
301
302
  var borderX2 = borderX1 + this.svgDOMRect.width;
302
303
  var borderY2 = borderY1 + this.svgDOMRect.height;
303
304
  if (this.verticalAnchorPoint === AnchorPoint_1.EVerticalAnchorPoint.Bottom) {
@@ -114,7 +114,7 @@ var AxisBase2D = /** @class */ (function (_super) {
114
114
  color: SciChartSurfaceBase_1.SciChartSurfaceBase.DEFAULT_THEME.tickTextBrush,
115
115
  fontWeight: "normal",
116
116
  fontStyle: "normal",
117
- padding: Thickness_1.Thickness.fromString("2 4 0 4"),
117
+ padding: Thickness_1.Thickness.fromString("2 4 2 4"),
118
118
  alignment: LabelAlignment_1.ELabelAlignment.Auto
119
119
  };
120
120
  _this.isInnerAxisProperty = false;
@@ -1226,5 +1226,5 @@ var AxisBase2D = /** @class */ (function (_super) {
1226
1226
  exports.AxisBase2D = AxisBase2D;
1227
1227
  /** @ignore */
1228
1228
  var getPenForLines = function (penCache, stroke, strokeThickness, strokeDashArray) {
1229
- return (0, Pen2DCache_1.createPenInCache)(penCache, stroke, strokeThickness, 1, strokeDashArray);
1229
+ return (0, Pen2DCache_1.createPenInCache)(penCache, stroke, strokeThickness, 1, strokeDashArray, false);
1230
1230
  };
@@ -7,6 +7,7 @@ import { Thickness } from "../../../Core/Thickness";
7
7
  import { EAutoRange } from "../../../types/AutoRange";
8
8
  import { EAxisType } from "../../../types/AxisType";
9
9
  import { ELabelAlignment } from "../../../types/LabelAlignment";
10
+ import { EMultiLineAlignment } from "../../../types/TextPosition";
10
11
  import { CoordinateCalculatorBase } from "../../Numerics/CoordinateCalculators/CoordinateCalculatorBase";
11
12
  import { TickCoordinatesProvider } from "../../Numerics/TickCoordinateProviders/TickCoordinatesProvider";
12
13
  import { TickProvider } from "../../Numerics/TickProviders/TickProvider";
@@ -58,8 +59,15 @@ export declare type TTextStyle = {
58
59
  * If you are using text labels rather than just numbers, or when using native text, you may want to increase the bottom padding.
59
60
  */
60
61
  padding?: Thickness;
61
- /** Horizontal label alignment for vertical axes. Default Auto */
62
+ /**
63
+ * Horizontal label alignment for vertical axes. Default Auto.
64
+ * @privateRemarks This property should only be used for axis labels.
65
+ * So the current type definition should be changed in future versions, specifically this property may be renamed or removed.
66
+ * In other cases, e.g. for multiline text alignment use TTextStyle.multilineAlignment
67
+ */
62
68
  alignment?: ELabelAlignment;
69
+ /** Horizontal text alignment for multiline text. */
70
+ multilineAlignment?: EMultiLineAlignment;
63
71
  };
64
72
  /**
65
73
  * Interface to minimal set of parameters which define an {@link AxisCore | Axis} in SciChart
@@ -25,7 +25,6 @@ export declare class AxisRenderer implements IDeletable {
25
25
  private measureTextCanvas;
26
26
  private keepLabelsWithinAxisProperty;
27
27
  private hideOverlappingLabelsProperty;
28
- private vertices;
29
28
  /**
30
29
  * Creates an instance of a {@link AxisRenderer}
31
30
  * @param webAssemblyContext The {@link TSciChart | SciChart 2D WebAssembly Context} containing native methods and
@@ -46,7 +46,6 @@ var AxisRenderer = /** @class */ (function () {
46
46
  this.hideOverlappingLabelsProperty = true;
47
47
  this.webAssemblyContext = webAssemblyContext;
48
48
  this.textureManager = new TextureManager_1.TextureManager(webAssemblyContext);
49
- this.vertices = (0, NativeObject_1.getVectorColorVertex)(webAssemblyContext);
50
49
  if (!app_1.IS_TEST_ENV) {
51
50
  this.measureTextCanvas = document.createElement("canvas");
52
51
  this.measureTextCanvas.width = 1;
@@ -263,7 +262,7 @@ var AxisRenderer = /** @class */ (function () {
263
262
  try {
264
263
  if (nativeFont) {
265
264
  var tx = xCoord + viewRect.left + padding.left;
266
- var ty = yCoord + viewRect.top + lineHeight - padding.bottom;
265
+ var ty = yCoord + viewRect.top + lineHeight + padding.top;
267
266
  var rx = tx;
268
267
  var ry = ty - lineHeight;
269
268
  if (rotationRad !== 0) {
@@ -324,7 +323,7 @@ var AxisRenderer = /** @class */ (function () {
324
323
  try {
325
324
  if (nativeFont) {
326
325
  var tx = xCoord + viewRect.left + padding.left;
327
- var ty = yCoord + viewRect.top + lineHeight - padding.bottom;
326
+ var ty = yCoord + viewRect.top + lineHeight + padding.top;
328
327
  nativeFont.DrawStringAdvanced(labelText !== null && labelText !== void 0 ? labelText : "", textColor, Math.round(tx), Math.round(ty), (0, NativeObject_1.getVector4)(this.webAssemblyContext, tx, ty, rotationRad, 0), multiLineAlignment, nativeLineSpacing);
329
328
  }
330
329
  else {
@@ -389,7 +388,8 @@ var AxisRenderer = /** @class */ (function () {
389
388
  return;
390
389
  var viewRect = this.viewRect;
391
390
  var tickSize = tickStyle.tickSize;
392
- this.vertices.clear();
391
+ var vertices = (0, NativeObject_1.getVectorColorVertex)(this.webAssemblyContext);
392
+ vertices.clear();
393
393
  var isHorizontal = (0, AxisAlignment_1.getIsHorizontal)(axisAlignment);
394
394
  if (isHorizontal === undefined) {
395
395
  return;
@@ -425,13 +425,13 @@ var AxisRenderer = /** @class */ (function () {
425
425
  }
426
426
  }
427
427
  var vertex = (0, NativeObject_1.getVertex)(_this.webAssemblyContext, x1, y1);
428
- _this.vertices.push_back(vertex);
428
+ vertices.push_back(vertex);
429
429
  var vertex2 = (0, NativeObject_1.getVertex)(_this.webAssemblyContext, x2, y2);
430
- _this.vertices.push_back(vertex2);
430
+ vertices.push_back(vertex2);
431
431
  });
432
432
  var leftOffset = viewRect.left - (isHorizontal ? axisOffset : 0);
433
433
  var topOffset = viewRect.top - (isHorizontal ? 0 : axisOffset);
434
- renderContext.drawLinesNative(this.vertices, pen, WebGlRenderContext2D_1.ELineDrawMode.DiscontinuousLine, leftOffset, topOffset);
434
+ renderContext.drawLinesNative(vertices, pen, WebGlRenderContext2D_1.ELineDrawMode.DiscontinuousLine, leftOffset, topOffset);
435
435
  };
436
436
  /**
437
437
  * Called internally - draws axis labels when needed, for example for line annotations
@@ -2,15 +2,20 @@ import { Rect } from "../../../Core/Rect";
2
2
  import { EAxisAlignment } from "../../../types/AxisAlignment";
3
3
  import { TSciChart } from "../../../types/TSciChart";
4
4
  import { WebGlRenderContext2D } from "../../Drawing/WebGlRenderContext2D";
5
- import { TextureManager } from "../TextureManager/TextureManager";
5
+ import { TextureManager, TTextureObject } from "../TextureManager/TextureManager";
6
6
  import { TTextStyle } from "./AxisCore";
7
7
  /**
8
8
  * Draws an axis title using our WebGL Rendering engine
9
9
  */
10
10
  export declare class AxisTitleRenderer {
11
+ useCache: boolean;
11
12
  viewRect: Rect;
12
13
  text: string | string[];
13
14
  lineSpacing: number;
15
+ private previousText;
16
+ private textStyle;
17
+ private previousLineSpacing;
18
+ private texture;
14
19
  private webAssemblyContext;
15
20
  private desiredHeightProperty;
16
21
  private desiredWidthProperty;
@@ -22,6 +27,6 @@ export declare class AxisTitleRenderer {
22
27
  get desiredWidth(): number;
23
28
  set desiredWidth(value: number);
24
29
  layout(rect: Rect): void;
25
- getTitleTexture(text: string | string[], textStyle: TTextStyle, textureManager: TextureManager): import("../TextureManager/TextureManager").TTextureObject;
30
+ getTitleTexture(text: string | string[], textStyle: TTextStyle, textureManager: TextureManager): TTextureObject;
26
31
  draw(renderContext: WebGlRenderContext2D, textStyle: TTextStyle, axisAlignment: EAxisAlignment, debugRendering: boolean): void;
27
32
  }
@@ -12,6 +12,7 @@ var __assign = (this && this.__assign) || function () {
12
12
  };
13
13
  Object.defineProperty(exports, "__esModule", { value: true });
14
14
  exports.AxisTitleRenderer = void 0;
15
+ var Deleter_1 = require("../../../Core/Deleter");
15
16
  var Rect_1 = require("../../../Core/Rect");
16
17
  var Thickness_1 = require("../../../Core/Thickness");
17
18
  var AxisAlignment_1 = require("../../../types/AxisAlignment");
@@ -29,6 +30,7 @@ var PADDING = {
29
30
  */
30
31
  var AxisTitleRenderer = /** @class */ (function () {
31
32
  function AxisTitleRenderer(webAssemblyContext) {
33
+ this.useCache = true;
32
34
  this.viewRect = Rect_1.Rect.createZero();
33
35
  this.text = "";
34
36
  this.lineSpacing = 1.1;
@@ -80,8 +82,20 @@ var AxisTitleRenderer = /** @class */ (function () {
80
82
  this.viewRect = rect;
81
83
  };
82
84
  AxisTitleRenderer.prototype.getTitleTexture = function (text, textStyle, textureManager) {
85
+ if (this.useCache &&
86
+ this.texture &&
87
+ text === this.previousText &&
88
+ this.lineSpacing === this.previousLineSpacing &&
89
+ checkAreEqualTextStyles(textStyle, this.textStyle)) {
90
+ return this.texture;
91
+ }
92
+ this.previousLineSpacing = this.lineSpacing;
93
+ this.previousText = text;
94
+ this.textStyle = textStyle;
83
95
  var lines = Array.isArray(text) ? text : [text];
84
- return textureManager.createTextTexture(lines, __assign(__assign({}, textStyle), { padding: new Thickness_1.Thickness(0, 0, 0, 0) }), 0, this.lineSpacing);
96
+ var texture = textureManager.createTextTexture(lines, __assign(__assign({}, textStyle), { padding: new Thickness_1.Thickness(0, 0, 0, 0) }), 0, this.lineSpacing);
97
+ this.texture = texture;
98
+ return texture;
85
99
  };
86
100
  AxisTitleRenderer.prototype.draw = function (renderContext, textStyle, axisAlignment, debugRendering) {
87
101
  if (!this.text)
@@ -121,8 +135,20 @@ var AxisTitleRenderer = /** @class */ (function () {
121
135
  nativeContext.DrawTexture(bitmapTexture, 0, 0, textureWidth, textureHeight);
122
136
  nativeContext.PopMatrix();
123
137
  }
124
- bitmapTexture.delete();
138
+ if (!this.useCache) {
139
+ (0, Deleter_1.deleteSafe)(bitmapTexture);
140
+ this.texture = undefined;
141
+ }
125
142
  };
126
143
  return AxisTitleRenderer;
127
144
  }());
128
145
  exports.AxisTitleRenderer = AxisTitleRenderer;
146
+ var checkAreEqualTextStyles = function (style1, style2) {
147
+ return (style1.color === style2.color &&
148
+ style1.fontFamily === style2.fontFamily &&
149
+ style1.fontSize === style2.fontSize &&
150
+ style1.fontStyle === style2.fontStyle &&
151
+ style1.fontWeight === style2.fontWeight &&
152
+ style1.multilineAlignment === style2.multilineAlignment &&
153
+ ((style1.padding === undefined && style2.padding === undefined) || style1.padding.equals(style2.padding)));
154
+ };
@@ -13,17 +13,12 @@ export declare class LabelInfo {
13
13
  textureHeight: number;
14
14
  textureWidth: number;
15
15
  lastUsed: number;
16
- private subs;
17
16
  constructor(tick: number, text: string, bitmapTexture: TSRTexture, textureHeight: number, textureWidth: number);
18
- registerNotifier(callback: () => void): void;
19
- textureUpdated(): void;
20
17
  }
21
18
  export interface ILabel2DOptions extends ILabelOptions {
22
19
  rotation?: number;
23
20
  /**
24
- * Experimental - set true to enable async label texture creation
25
- * Can be set globally using SciChartDefaults.asyncLabels = true;
26
- * When false getLabelTexture is used. When true, getLabelTextureAsync is used.
21
+ * @deprecated This functionality has been removed. useNativeText: true provides much greater performance benefit.
27
22
  */
28
23
  asyncLabels?: boolean;
29
24
  /**
@@ -53,8 +48,7 @@ export declare abstract class LabelProviderBase2D extends LabelProvider implemen
53
48
  */
54
49
  useSharedCache: boolean;
55
50
  /**
56
- * Experimental - set true to enable async label texture creation
57
- * Can be set globally using SciChartDefaults. Currently default false.
51
+ * @deprecated This functionality has been removed. useNativeText: true provides much greater performance benefit.
58
52
  */
59
53
  asyncLabels: boolean;
60
54
  /**
@@ -132,13 +126,12 @@ export declare abstract class LabelProviderBase2D extends LabelProvider implemen
132
126
  */
133
127
  getCachedLabelTexture(labelText: string, textureManager: TextureManager, labelStyle: TTextStyle): TTextureObject;
134
128
  /**
135
- * Create a texture for the given label text asynchronously. This method is called if asyncLabels is true, otherwise getLabelTexture is used.
136
- * If overriding this method with useSharedCache = true, consider setting it false for this LabelProvider,
137
- * otherwise other axes using the same style and text may see your custom texture. Alternatively you can override getCachedStyle or set styleId directly
129
+ * @deprecated AsyncLabels have been removed. useNativeText: true provides much greater performance benefit.
130
+ * If using texture labels override getLabelTexture instead
138
131
  */
139
132
  getLabelTextureAsync(labelText: string, textureManager: TextureManager, labelStyle: TTextStyle): Promise<TTextureObject>;
140
133
  /**
141
- * Create a texture for the given label text. This method is called if asyncLabels is false, otherwise getLabelTextureAsync is used.
134
+ * Create a texture for the given label text. This method is called if useNativeText is false.
142
135
  * If overriding this method with useSharedCache = true, consider setting it false for this LabelProvider,
143
136
  * otherwise other axes using the same style and text may see your custom texture. Alternatively you can override getCachedStyle or set styleId directly
144
137
  */