scichart 3.0.317 → 3.1.333

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 (56) 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 +33 -0
  4. package/Charting/Services/ChartTitleRenderer.js +149 -0
  5. package/Charting/Services/SciChartRenderer.d.ts +7 -1
  6. package/Charting/Services/SciChartRenderer.js +54 -8
  7. package/Charting/Services/TitleRenderer.d.ts +98 -0
  8. package/Charting/Services/TitleRenderer.js +249 -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/NativeTextAnnotation.js +1 -5
  15. package/Charting/Visuals/Annotations/SvgAnnotationBase.js +2 -1
  16. package/Charting/Visuals/Axis/AxisBase2D.js +7 -16
  17. package/Charting/Visuals/Axis/AxisCore.d.ts +9 -1
  18. package/Charting/Visuals/Axis/AxisRenderer.js +2 -2
  19. package/Charting/Visuals/Axis/AxisTitleRenderer.d.ts +14 -13
  20. package/Charting/Visuals/Axis/AxisTitleRenderer.js +102 -90
  21. package/Charting/Visuals/Axis/LabelProvider/LabelCache.js +1 -0
  22. package/Charting/Visuals/Axis/LabelProvider/LabelProviderBase2D.d.ts +5 -12
  23. package/Charting/Visuals/Axis/LabelProvider/LabelProviderBase2D.js +8 -55
  24. package/Charting/Visuals/Axis/LabelProvider/TextLabelProvider.d.ts +0 -1
  25. package/Charting/Visuals/Axis/LabelProvider/TextLabelProvider.js +0 -60
  26. package/Charting/Visuals/I2DSurfaceOptions.d.ts +9 -0
  27. package/Charting/Visuals/RenderableSeries/FastColumnRenderableSeries.d.ts +2 -2
  28. package/Charting/Visuals/RenderableSeries/FastColumnRenderableSeries.js +2 -2
  29. package/Charting/Visuals/SciChartDefaults.d.ts +2 -3
  30. package/Charting/Visuals/SciChartDefaults.js +2 -3
  31. package/Charting/Visuals/SciChartSurface.d.ts +31 -0
  32. package/Charting/Visuals/SciChartSurface.js +108 -6
  33. package/Charting/Visuals/TextureManager/DpiHelper.js +1 -1
  34. package/Charting/Visuals/TextureManager/TextureManager.js +34 -19
  35. package/Charting3D/Visuals/SciChart3DSurface.js +6 -2
  36. package/Core/BuildStamp.d.ts +1 -1
  37. package/Core/BuildStamp.js +2 -2
  38. package/_wasm/scichart.browser.js +1 -1
  39. package/_wasm/scichart2d.js +1 -1
  40. package/_wasm/scichart2d.wasm +0 -0
  41. package/_wasm/scichart3d.js +7 -7
  42. package/_wasm/scichart3d.wasm +0 -0
  43. package/constants/app.js +2 -1
  44. package/index.d.ts +14 -1
  45. package/index.js +21 -12
  46. package/index.min.js +1 -1
  47. package/package.json +1 -1
  48. package/types/NumberArray.js +2 -1
  49. package/types/TextStyle.d.ts +97 -0
  50. package/types/TextStyle.js +86 -0
  51. package/utils/text.d.ts +8 -1
  52. package/utils/text.js +23 -1
  53. package/Charting/Services/Workers/TextureWorker.d.ts +0 -16
  54. package/Charting/Services/Workers/TextureWorker.js +0 -142
  55. package/Charting/Services/Workers/TextureWorkerSource.d.ts +0 -1
  56. package/Charting/Services/Workers/TextureWorkerSource.js +0 -133
@@ -29,6 +29,8 @@ import { ESurfaceType, SciChartSurfaceBase, TSciChartConfig } from "./SciChartSu
29
29
  import { TDpiChangedEventArgs } from "./TextureManager/DpiHelper";
30
30
  import { Point } from "../../Core/Point";
31
31
  import { EWatermarkPosition } from "../../types/WatermarkPosition";
32
+ import { TChartTitleStyle } from "../../types/TextStyle";
33
+ import { IChartTitleRenderer } from "../Services/TitleRenderer";
32
34
  export declare type TSciChart = TWasmContext;
33
35
  export declare type TWebAssemblyChart = {
34
36
  wasmContext: TSciChart;
@@ -97,6 +99,7 @@ export declare class SciChartSurface extends SciChartSurfaceBase {
97
99
  * Tell SciChart to load the Wasm and Data files from the local server, rather than from CDN.
98
100
  */
99
101
  static useWasmLocal(): void;
102
+ static isSubSurface(surface: SciChartSurface): surface is SciChartSubSurface;
100
103
  private static createTest;
101
104
  readonly renderSurface: RenderSurface;
102
105
  /**
@@ -218,7 +221,11 @@ export declare class SciChartSurface extends SciChartSurfaceBase {
218
221
  /** Set true to position the watermark relative to the overall canvas, rather than the series area. */
219
222
  watermarkRelativeToCanvas: boolean;
220
223
  protected animationList: IGenericAnimation[];
224
+ protected titleProperty: string | string[];
225
+ protected titleStyleProperty: Readonly<Required<TChartTitleStyle>>;
226
+ protected chartTitleRendererProperty: IChartTitleRenderer;
221
227
  protected paddingProperty: Thickness;
228
+ protected currentWebGlRenderContextProperty: WebGlRenderContext2D;
222
229
  private readonly sciChartRenderer;
223
230
  private layoutManagerProperty;
224
231
  private dataLabelLayoutManagerProperty;
@@ -272,6 +279,11 @@ export declare class SciChartSurface extends SciChartSurfaceBase {
272
279
  * Used internally - gets or sets the {@link LayoutManager}
273
280
  */
274
281
  set layoutManager(value: LayoutManager);
282
+ /**
283
+ * Controls the rendering of {@link SiCharSurface.title}
284
+ */
285
+ get chartTitleRenderer(): IChartTitleRenderer;
286
+ set chartTitleRenderer(value: IChartTitleRenderer);
275
287
  /**
276
288
  * Gets or sets the {@link ISeriesTextLayoutManager} for performing text layout across multiple series
277
289
  */
@@ -280,6 +292,24 @@ export declare class SciChartSurface extends SciChartSurfaceBase {
280
292
  * Used internally - gets or sets the {@link ISeriesTextLayoutManager} for performing text layout across multiple series
281
293
  */
282
294
  set dataLabelLayoutManager(value: IDataLabelLayoutManager);
295
+ /**
296
+ * Gets or sets the title for the SciChartSurface
297
+ */
298
+ get title(): string | string[];
299
+ /**
300
+ * Gets or sets the title for the SciChartSurface
301
+ */
302
+ set title(value: string | string[]);
303
+ /**
304
+ * Gets or sets the title text style and placement for the SciChartSurface as {@link TChartTitleStyle}
305
+ */
306
+ get titleStyle(): Readonly<Required<TChartTitleStyle>>;
307
+ /**
308
+ * Gets or sets the title text style and placement for the SciChartSurface as {@link TChartTitleStyle}
309
+ * @remarks if updating, should be set as an object (or partial object) of type {@link TChartTitleStyle},
310
+ * instead of directly setting individual properties
311
+ */
312
+ set titleStyle(value: TChartTitleStyle);
283
313
  /**
284
314
  * Gets or sets the Padding between the SciChartSurface and it's inner elements, in order top, right, bottom, left
285
315
  * @remarks
@@ -439,6 +469,7 @@ export declare class SciChartSurface extends SciChartSurfaceBase {
439
469
  * Gets the SciChartSurface Canvas Bottom Border
440
470
  */
441
471
  get bottomCanvasBorder(): number;
472
+ get currentWebGlRenderContext(): WebGlRenderContext2D;
442
473
  /**
443
474
  * Is being called on each render, to run animations
444
475
  * @param timeElapsed
@@ -91,7 +91,6 @@ var RenderSurface_1 = require("../Drawing/RenderSurface");
91
91
  var SolidBrushCache_1 = require("../Drawing/SolidBrushCache");
92
92
  var LayoutManager_1 = require("../LayoutManager/LayoutManager");
93
93
  var SciChartRenderer_1 = require("../Services/SciChartRenderer");
94
- var TextureWorker_1 = require("../Services/Workers/TextureWorker");
95
94
  var AdornerLayer_1 = require("./Annotations/AdornerLayer");
96
95
  var AnnotationBase_1 = require("./Annotations/AnnotationBase");
97
96
  var AxisBase2D_1 = require("./Axis/AxisBase2D");
@@ -109,9 +108,10 @@ var DpiHelper_1 = require("./TextureManager/DpiHelper");
109
108
  var UpdateSuspender_1 = require("./UpdateSuspender");
110
109
  var Point_1 = require("../../Core/Point");
111
110
  var SciChartDefaults_1 = require("./SciChartDefaults");
111
+ var ChartTitleRenderer_1 = require("../Services/ChartTitleRenderer");
112
+ var TextStyle_1 = require("../../types/TextStyle");
113
+ var TextPosition_1 = require("../../types/TextPosition");
112
114
  exports.sciChartConfig = {};
113
- // To force the worker to be created before it is needed, so we know if it alive or not
114
- var t = TextureWorker_1.textureWorker;
115
115
  /**
116
116
  * @summary The {@link SciChartSurface} is the root 2D Chart control in SciChart's High Performance Real-time
117
117
  * {@link https://www.scichart.com/javascript-chart-features | JavaScript Chart Library}
@@ -170,6 +170,21 @@ var SciChartSurface = /** @class */ (function (_super) {
170
170
  /** Set true to position the watermark relative to the overall canvas, rather than the series area. */
171
171
  _this.watermarkRelativeToCanvas = false;
172
172
  _this.animationList = [];
173
+ _this.titleStyleProperty = {
174
+ fontSize: 60,
175
+ fontFamily: "Arial",
176
+ color: SciChartSurfaceBase_1.SciChartSurfaceBase.DEFAULT_THEME.chartTitleColor,
177
+ fontWeight: "normal",
178
+ fontStyle: "normal",
179
+ lineSpacing: 1.1,
180
+ padding: Thickness_1.Thickness.fromString("10 4 10 4"),
181
+ multilineAlignment: TextPosition_1.EMultiLineAlignment.Center,
182
+ // rotation: 0,
183
+ alignment: TextStyle_1.ETextAlignment.Center,
184
+ position: TextStyle_1.ETitlePosition.Top,
185
+ placeWithinChart: false,
186
+ useNativeText: SciChartDefaults_1.SciChartDefaults.useNativeText
187
+ };
173
188
  _this.paddingProperty = Thickness_1.Thickness.fromNumber(10);
174
189
  _this.zoomStateProperty = ZoomState_1.EZoomState.AtExtents;
175
190
  _this.viewportBorderProperty = {
@@ -216,6 +231,7 @@ var SciChartSurface = /** @class */ (function (_super) {
216
231
  _this.renderSurface = new RenderSurface_1.RenderSurface(webAssemblyContext, viewportSize, (_e = _this.domCanvas2D) === null || _e === void 0 ? void 0 : _e.id);
217
232
  _this.renderSurface.handleDraw = _this.onRenderSurfaceDraw;
218
233
  _this.sciChartRenderer = new SciChartRenderer_1.SciChartRenderer(_this);
234
+ _this.chartTitleRendererProperty = new ChartTitleRenderer_1.ChartTitleRenderer(_this.webAssemblyContext2D);
219
235
  _this.layoutManager = new LayoutManager_1.LayoutManager();
220
236
  // TODO: remove this
221
237
  if (_this.domCanvas2D) {
@@ -345,6 +361,9 @@ var SciChartSurface = /** @class */ (function (_super) {
345
361
  SciChartSurface.useWasmLocal = function () {
346
362
  SciChartSurface.configure(undefined);
347
363
  };
364
+ SciChartSurface.isSubSurface = function (surface) {
365
+ return surface.isSubSurface;
366
+ };
348
367
  SciChartSurface.createTest = function (divElement, options) {
349
368
  var _a, _b;
350
369
  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);
@@ -453,6 +472,22 @@ var SciChartSurface = /** @class */ (function (_super) {
453
472
  enumerable: false,
454
473
  configurable: true
455
474
  });
475
+ Object.defineProperty(SciChartSurface.prototype, "chartTitleRenderer", {
476
+ /**
477
+ * Controls the rendering of {@link SiCharSurface.title}
478
+ */
479
+ get: function () {
480
+ return this.chartTitleRendererProperty;
481
+ },
482
+ set: function (value) {
483
+ var _a;
484
+ (_a = this.chartTitleRendererProperty) === null || _a === void 0 ? void 0 : _a.delete();
485
+ this.chartTitleRendererProperty = value;
486
+ this.invalidateElement();
487
+ },
488
+ enumerable: false,
489
+ configurable: true
490
+ });
456
491
  Object.defineProperty(SciChartSurface.prototype, "dataLabelLayoutManager", {
457
492
  /**
458
493
  * Gets or sets the {@link ISeriesTextLayoutManager} for performing text layout across multiple series
@@ -470,6 +505,46 @@ var SciChartSurface = /** @class */ (function (_super) {
470
505
  enumerable: false,
471
506
  configurable: true
472
507
  });
508
+ Object.defineProperty(SciChartSurface.prototype, "title", {
509
+ /**
510
+ * Gets or sets the title for the SciChartSurface
511
+ */
512
+ get: function () {
513
+ return this.titleProperty;
514
+ },
515
+ /**
516
+ * Gets or sets the title for the SciChartSurface
517
+ */
518
+ set: function (value) {
519
+ if (this.titleProperty !== value) {
520
+ this.titleProperty = value;
521
+ this.invalidateElement();
522
+ }
523
+ },
524
+ enumerable: false,
525
+ configurable: true
526
+ });
527
+ Object.defineProperty(SciChartSurface.prototype, "titleStyle", {
528
+ /**
529
+ * Gets or sets the title text style and placement for the SciChartSurface as {@link TChartTitleStyle}
530
+ */
531
+ get: function () {
532
+ return this.titleStyleProperty;
533
+ },
534
+ /**
535
+ * Gets or sets the title text style and placement for the SciChartSurface as {@link TChartTitleStyle}
536
+ * @remarks if updating, should be set as an object (or partial object) of type {@link TChartTitleStyle},
537
+ * instead of directly setting individual properties
538
+ */
539
+ set: function (value) {
540
+ if (this.titleStyleProperty !== value) {
541
+ this.titleStyleProperty = Object.assign({}, this.titleStyleProperty, value);
542
+ this.invalidateElement();
543
+ }
544
+ },
545
+ enumerable: false,
546
+ configurable: true
547
+ });
473
548
  Object.defineProperty(SciChartSurface.prototype, "padding", {
474
549
  /**
475
550
  * Gets or sets the Padding between the SciChartSurface and it's inner elements, in order top, right, bottom, left
@@ -552,6 +627,11 @@ var SciChartSurface = /** @class */ (function (_super) {
552
627
  * @inheritDoc
553
628
  */
554
629
  SciChartSurface.prototype.applyTheme = function (themeProvider) {
630
+ // TODO move to base when title is implemented on 3d charts
631
+ var previousThemeProvider = this.previousThemeProvider;
632
+ if (this.titleStyle.color === previousThemeProvider.chartTitleColor) {
633
+ this.titleStyle = { color: themeProvider.chartTitleColor };
634
+ }
555
635
  _super.prototype.applyTheme.call(this, themeProvider);
556
636
  this.renderableSeries.asArray().forEach(function (rs) { return rs.applyTheme(themeProvider); });
557
637
  this.xAxes.asArray().forEach(function (axis) { return axis.applyTheme(themeProvider); });
@@ -586,7 +666,9 @@ var SciChartSurface = /** @class */ (function (_super) {
586
666
  var chart = _a[_i];
587
667
  chart.updateSubLayout();
588
668
  }
589
- this.invalidateElement();
669
+ // Bypass the isSuspended check, otherwise the chart will go blank if it is resized while suspended
670
+ var canvasId = this.domCanvas2D ? this.domCanvas2D.id : "undefinedCanvasId";
671
+ this.renderSurface.invalidateElement(canvasId);
590
672
  };
591
673
  /**
592
674
  * @inheritDoc
@@ -604,6 +686,7 @@ var SciChartSurface = /** @class */ (function (_super) {
604
686
  // Step_5: Get context and pass drawing to SciChartRenderer
605
687
  SciChartSurface.prototype.doDrawingLoop = function (context) {
606
688
  context = context !== null && context !== void 0 ? context : this.renderSurface.getRenderContext();
689
+ this.currentWebGlRenderContextProperty = context;
607
690
  try {
608
691
  var sus = new UpdateSuspender_1.UpdateSuspender(this, false); // Don't want to invalidate on resume
609
692
  try {
@@ -640,6 +723,7 @@ var SciChartSurface = /** @class */ (function (_super) {
640
723
  throw err;
641
724
  }
642
725
  }
726
+ this.currentWebGlRenderContextProperty = undefined;
643
727
  };
644
728
  /**
645
729
  * @inheritDoc
@@ -663,6 +747,7 @@ var SciChartSurface = /** @class */ (function (_super) {
663
747
  this.watermarkProperties = (0, Deleter_1.deleteSafe)(this.watermarkProperties);
664
748
  this.watermarkPropertyPosition = (0, Deleter_1.deleteSafe)(this.watermarkPropertyPosition);
665
749
  this.chartModifiers.asArray().forEach(function (chm) { return chm.delete(); });
750
+ this.chartTitleRendererProperty = (0, Deleter_1.deleteSafe)(this.chartTitleRenderer);
666
751
  if (clearHtml && this.domChartRoot) {
667
752
  var style = this.domChartRoot.style;
668
753
  if (style) {
@@ -930,6 +1015,13 @@ var SciChartSurface = /** @class */ (function (_super) {
930
1015
  enumerable: false,
931
1016
  configurable: true
932
1017
  });
1018
+ Object.defineProperty(SciChartSurface.prototype, "currentWebGlRenderContext", {
1019
+ get: function () {
1020
+ return this.currentWebGlRenderContextProperty;
1021
+ },
1022
+ enumerable: false,
1023
+ configurable: true
1024
+ });
933
1025
  /**
934
1026
  * Is being called on each render, to run animations
935
1027
  * @param timeElapsed
@@ -1092,6 +1184,8 @@ var SciChartSurface = /** @class */ (function (_super) {
1092
1184
  }
1093
1185
  var options = {
1094
1186
  id: this.id,
1187
+ title: this.title,
1188
+ titleStyle: this.titleStyle,
1095
1189
  canvasBorder: this.canvasBorder,
1096
1190
  heightAspect: this.heightAspect,
1097
1191
  widthAspect: this.widthAspect,
@@ -1144,6 +1238,12 @@ var SciChartSurface = /** @class */ (function (_super) {
1144
1238
  if (options === null || options === void 0 ? void 0 : options.autoColorMode) {
1145
1239
  this.autoColorMode = options.autoColorMode;
1146
1240
  }
1241
+ if (options === null || options === void 0 ? void 0 : options.title) {
1242
+ this.title = options.title;
1243
+ }
1244
+ if (options === null || options === void 0 ? void 0 : options.titleStyle) {
1245
+ this.titleStyle = options.titleStyle;
1246
+ }
1147
1247
  };
1148
1248
  /**
1149
1249
  * @inheritDoc
@@ -1610,7 +1710,9 @@ var SciChartSubSurface = /** @class */ (function (_super) {
1610
1710
  /**
1611
1711
  * @inheritDoc
1612
1712
  */
1613
- SciChartSubSurface.prototype.changeViewportSize = function (pixelWidth, pixelHeight) { };
1713
+ SciChartSubSurface.prototype.changeViewportSize = function (pixelWidth, pixelHeight) {
1714
+ this.renderSurface.viewportSize = this.parentSurface.renderSurface.viewportSize;
1715
+ };
1614
1716
  /**
1615
1717
  * Gets the sub-chart container
1616
1718
  */
@@ -1619,7 +1721,7 @@ var SciChartSubSurface = /** @class */ (function (_super) {
1619
1721
  };
1620
1722
  SciChartSubSurface.prototype.getSubChartRect = function () {
1621
1723
  var _a = this.renderSurface.viewportSize, width = _a.width, height = _a.height;
1622
- var _b = this.padding, top = _b.top, left = _b.left, bottom = _b.bottom, right = _b.right;
1724
+ var _b = this.adjustedPadding, top = _b.top, left = _b.left, bottom = _b.bottom, right = _b.right;
1623
1725
  return new Rect_1.Rect(left, top, width - left - right, height - top - bottom);
1624
1726
  };
1625
1727
  /**
@@ -122,7 +122,7 @@ var DpiHelper = /** @class */ (function () {
122
122
  if (dpiScale === void 0) { dpiScale = DpiHelper.PIXEL_RATIO; }
123
123
  var dpiAdjusted = __assign({}, gridLineStyle);
124
124
  var roundedStrokeThickness = Math.round(gridLineStyle.strokeThickness * dpiScale);
125
- dpiAdjusted.strokeDashArray = (_a = gridLineStyle.strokeDashArray) === null || _a === void 0 ? void 0 : _a.map(function (sd) { return sd * dpiScale; });
125
+ dpiAdjusted.strokeDashArray = (_a = gridLineStyle.strokeDashArray) === null || _a === void 0 ? void 0 : _a.map(function (sd) { return Math.round(sd * dpiScale); });
126
126
  dpiAdjusted.strokeThickness =
127
127
  roundedStrokeThickness > 0 || gridLineStyle.strokeThickness === 0 ? roundedStrokeThickness : 1;
128
128
  return dpiAdjusted;
@@ -75,12 +75,17 @@ var TextureManager = /** @class */ (function () {
75
75
  * @returns
76
76
  */
77
77
  TextureManager.prototype.createTextTexture = function (text, textStyle, rotation, lineSpacing, backgroundColor, opacity) {
78
+ var _a;
78
79
  if (app_1.IS_TEST_ENV) {
79
80
  return { bitmapTexture: undefined, textureWidth: 1, textureHeight: 1 };
80
81
  }
81
82
  var fontStyle = textStyle.fontStyle, fontWeight = textStyle.fontWeight, fontFamily = textStyle.fontFamily, fontSizePx = textStyle.fontSize, padding = textStyle.padding, alignment = textStyle.alignment, color = textStyle.color;
83
+ // Save state
84
+ this.ctx.save();
82
85
  this.ctx.globalAlpha = opacity !== null && opacity !== void 0 ? opacity : 1;
83
- this.ctx.textBaseline = "top";
86
+ this.ctx.textBaseline = "alphabetic";
87
+ // Switched this back to alphabetic because...reasons
88
+ // https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-textbaseline-alphabetic
84
89
  this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
85
90
  if (backgroundColor) {
86
91
  this.ctx.fillStyle = backgroundColor;
@@ -90,51 +95,61 @@ var TextureManager = /** @class */ (function () {
90
95
  this.ctx.font = (0, font_1.getFontString)(fontStyle, fontWeight, fontSizePx, fontFamily);
91
96
  var textureWidth = 0;
92
97
  // const fontSizePt = Math.ceil(fontSizePx * PX_TO_PT);
93
- var lineHeight = (0, exports.measureTextHeight)(fontSizePx);
94
- var extraLineHeight = lineHeight * (lineSpacing !== null && lineSpacing !== void 0 ? lineSpacing : 1.1);
95
- var textureHeight = lineHeight + padding.top + padding.bottom;
98
+ var textureHeight = padding.top + padding.bottom;
99
+ var maxLineHeight = 0;
100
+ var firstLineOffset = 0;
101
+ var lineHeights = [];
96
102
  for (var index = 0; index < text.length; index++) {
97
103
  var line = text[index];
98
- var lineWidth = (0, exports.measureTextWidth)(this.ctx, line) + padding.left + padding.right;
104
+ var textMeasure = this.ctx.measureText(line);
105
+ var lineHeight = Math.round(textMeasure.actualBoundingBoxAscent + textMeasure.actualBoundingBoxDescent);
106
+ lineHeights.push(lineHeight);
107
+ if (lineHeight > maxLineHeight) {
108
+ maxLineHeight = lineHeight;
109
+ }
110
+ if (index === 0) {
111
+ firstLineOffset = textMeasure.actualBoundingBoxAscent;
112
+ }
113
+ var lineWidth = Math.round(textMeasure.width + padding.left + padding.right);
99
114
  if (lineWidth > textureWidth) {
100
115
  textureWidth = lineWidth;
101
116
  }
102
- if (index > 0) {
103
- textureHeight += extraLineHeight;
104
- }
117
+ textureHeight += lineHeight;
105
118
  }
106
- var y = padding.top;
119
+ var lineSpacingPixels = Math.round(maxLineHeight * ((lineSpacing !== null && lineSpacing !== void 0 ? lineSpacing : 1.1) - 1));
120
+ textureHeight += (text.length - 1) * lineSpacingPixels;
121
+ var y = padding.top + firstLineOffset;
107
122
  var x = padding.left;
108
123
  if (!textureWidth || !textureHeight) {
109
124
  return { bitmapTexture: undefined, textureWidth: textureWidth, textureHeight: textureHeight };
110
125
  }
111
126
  var newTextureWidth = textureWidth;
112
127
  var newTextureHeight = textureHeight;
113
- // Save state
114
- this.ctx.save();
115
128
  if (rotation) {
116
129
  // convert to radians
117
130
  var rotationRad = (rotation * Math.PI) / 180;
118
131
  // We need to Math.ceil to fix rotation for WebGL1
119
- newTextureWidth = Math.ceil(textureWidth * Math.abs(Math.cos(rotationRad)) + textureHeight * Math.abs(Math.sin(rotationRad)));
120
- newTextureHeight = Math.ceil(textureWidth * Math.abs(Math.sin(rotationRad)) + textureHeight * Math.abs(Math.cos(rotationRad)));
132
+ newTextureWidth = Math.round(textureWidth * Math.abs(Math.cos(rotationRad)) + textureHeight * Math.abs(Math.sin(rotationRad)));
133
+ newTextureHeight = Math.round(textureWidth * Math.abs(Math.sin(rotationRad)) + textureHeight * Math.abs(Math.cos(rotationRad)));
121
134
  // translate to the center of rectangle
122
135
  this.ctx.translate(newTextureWidth / 2, newTextureHeight / 2);
123
136
  this.ctx.rotate(rotationRad);
124
137
  // translate to the new origin that is located in the left top center of the texture
125
138
  this.ctx.translate(-textureWidth / 2, -textureHeight / 2);
126
139
  }
127
- for (var _i = 0, text_1 = text; _i < text_1.length; _i++) {
128
- var line = text_1[_i];
129
- if (alignment === LabelAlignment_1.ELabelAlignment.Center || alignment === LabelAlignment_1.ELabelAlignment.Right) {
140
+ var multilineAlignment = (_a = textStyle.multilineAlignment) !== null && _a !== void 0 ? _a : alignment;
141
+ var maxLineTextWidth = textureWidth - padding.right - padding.left;
142
+ for (var index = 0; index < text.length; index++) {
143
+ var line = text[index];
144
+ if (multilineAlignment === LabelAlignment_1.ELabelAlignment.Center || multilineAlignment === LabelAlignment_1.ELabelAlignment.Right) {
130
145
  var lineWidth = (0, exports.measureTextWidth)(this.ctx, line);
131
146
  x =
132
- alignment === LabelAlignment_1.ELabelAlignment.Right
147
+ multilineAlignment === LabelAlignment_1.ELabelAlignment.Right
133
148
  ? textureWidth - lineWidth - padding.right
134
- : (textureWidth - lineWidth) / 2;
149
+ : (maxLineTextWidth - lineWidth) / 2 + padding.left;
135
150
  }
136
151
  this.ctx.fillText(line, Math.round(x), Math.round(y));
137
- y += extraLineHeight;
152
+ y += lineHeights[index] + lineSpacingPixels;
138
153
  }
139
154
  this.ctx.strokeStyle = color;
140
155
  this.ctx.restore();
@@ -512,7 +512,9 @@ var SciChart3DSurface = /** @class */ (function (_super) {
512
512
  this.webAssemblyContext3D.SCRT3DSetClearColor(0, 0, 0, 0);
513
513
  };
514
514
  SciChart3DSurface.prototype.detachSeries = function (renderableSeries) {
515
- this.rootEntity.children.remove(renderableSeries.sceneEntity);
515
+ if (this.rootEntity) {
516
+ this.rootEntity.children.remove(renderableSeries.sceneEntity);
517
+ }
516
518
  renderableSeries.onDetach();
517
519
  this.invalidateElement();
518
520
  };
@@ -521,7 +523,9 @@ var SciChart3DSurface = /** @class */ (function (_super) {
521
523
  if (!renderableSeries.sceneEntity) {
522
524
  throw new Error("IRenderableSeries3D.sceneEntity must be set before attaching to SciChart3DSurface");
523
525
  }
524
- this.rootEntity.children.add(renderableSeries.sceneEntity);
526
+ if (this.rootEntity) {
527
+ this.rootEntity.children.add(renderableSeries.sceneEntity);
528
+ }
525
529
  this.invalidateElement();
526
530
  };
527
531
  SciChart3DSurface.prototype.detachAxis = function (axis) {
@@ -1,4 +1,4 @@
1
1
  import { TSciChart } from "../types/TSciChart";
2
2
  import { TSciChart3D } from "../types/TSciChart3D";
3
- export declare const libraryVersion = "3.0.317";
3
+ export declare const libraryVersion = "3.1.333";
4
4
  export declare const checkBuildStamp: (wasmContext: TSciChart | TSciChart3D) => boolean;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkBuildStamp = exports.libraryVersion = void 0;
4
- var buildStamp = "2023-03-16T00:00:00";
4
+ var buildStamp = "2023-04-19T00:00:00";
5
5
  var result;
6
6
  // tslint:disable-next-line:no-var-requires
7
- exports.libraryVersion = "3.0.317";
7
+ exports.libraryVersion = "3.1.333";
8
8
  var checkBuildStamp = function (wasmContext) {
9
9
  if (result !== undefined)
10
10
  return result;