scichart 3.1.329 → 3.1.346

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 (45) hide show
  1. package/Charting/ChartModifiers/RolloverModifier.d.ts +11 -0
  2. package/Charting/ChartModifiers/RolloverModifier.js +59 -46
  3. package/Charting/ChartModifiers/ZoomExtentsModifier.js +2 -2
  4. package/Charting/ChartModifiers/ZoomPanModifier.js +2 -0
  5. package/Charting/Model/BaseDataSeries.js +3 -6
  6. package/Charting/Model/HlcDataSeries.js +4 -5
  7. package/Charting/Model/OhlcDataSeries.js +2 -3
  8. package/Charting/Model/XyyDataSeries.js +2 -2
  9. package/Charting/Services/ChartTitleRenderer.d.ts +0 -4
  10. package/Charting/Services/ChartTitleRenderer.js +11 -45
  11. package/Charting/Services/TitleRenderer.d.ts +14 -6
  12. package/Charting/Services/TitleRenderer.js +85 -21
  13. package/Charting/Visuals/Annotations/OverviewCustomResizableAnnotation.js +2 -0
  14. package/Charting/Visuals/Axis/AxisBase2D.js +5 -14
  15. package/Charting/Visuals/Axis/AxisCore.d.ts +17 -11
  16. package/Charting/Visuals/Axis/AxisCore.js +14 -9
  17. package/Charting/Visuals/Axis/AxisTitleRenderer.d.ts +13 -17
  18. package/Charting/Visuals/Axis/AxisTitleRenderer.js +88 -108
  19. package/Charting/Visuals/Axis/IAxisCoreOptions.d.ts +2 -2
  20. package/Charting/Visuals/Axis/LabelProvider/LabelCache.js +1 -0
  21. package/Charting/Visuals/RenderableSeries/HitTest/BandSeriesHitTestProvider.js +11 -4
  22. package/Charting/Visuals/RenderableSeries/HitTest/BaseHitTestProvider.js +11 -4
  23. package/Charting/Visuals/RenderableSeries/HitTest/LineSeriesHitTestProvider.js +11 -4
  24. package/Charting/Visuals/SciChartSurface.d.ts +2 -0
  25. package/Charting/Visuals/SciChartSurface.js +11 -2
  26. package/Charting/Visuals/TextureManager/TextureManager.js +2 -2
  27. package/Charting3D/Model/DataSeries/UniformGridDataSeries3D.d.ts +1 -1
  28. package/Charting3D/Model/DataSeries/UniformGridDataSeries3D.js +1 -1
  29. package/Core/BuildStamp.d.ts +1 -1
  30. package/Core/BuildStamp.js +2 -2
  31. package/_wasm/scichart.browser.js +1 -1
  32. package/_wasm/scichart2d.js +1 -1
  33. package/_wasm/scichart2d.wasm +0 -0
  34. package/_wasm/scichart3d.js +1 -1
  35. package/_wasm/scichart3d.wasm +0 -0
  36. package/constants/app.js +2 -1
  37. package/index.d.ts +2 -0
  38. package/index.js +13 -11
  39. package/index.min.js +1 -1
  40. package/package.json +1 -1
  41. package/types/TextStyle.d.ts +2 -0
  42. package/types/TextStyle.js +1 -1
  43. package/utils/date.js +2 -0
  44. package/utils/text.d.ts +3 -2
  45. package/utils/text.js +45 -2
@@ -569,6 +569,7 @@ var AxisBase2D = /** @class */ (function (_super) {
569
569
  */
570
570
  AxisBase2D.prototype.onAttach = function (parentSurface, isXAxis, isPrimaryAxis) {
571
571
  this.parentSurface = parentSurface;
572
+ this.axisTitleRenderer.parentSurface = parentSurface;
572
573
  this.setIsXAxis(isXAxis);
573
574
  this.isPrimaryAxisProperty = isPrimaryAxis;
574
575
  };
@@ -585,7 +586,7 @@ var AxisBase2D = /** @class */ (function (_super) {
585
586
  console.log("Measure. fontSize: ".concat(this.labelStyle.fontSize, ", dpiAdjusted: ").concat(this.dpiAdjustedLabelStyle.fontSize));
586
587
  }
587
588
  this.axisRenderer.measure(this.isHorizontalAxis, this.dpiAdjustedLabelStyle, majorTickLabels, this.getTicksMaxSize(), this.labelProvider, this.drawLabels, drawTicks);
588
- this.axisTitleRenderer.measure(this.dpiAdjustedAxisTitleStyle, this.isHorizontalAxis);
589
+ this.axisTitleRenderer.measure(this.axisTitle, this.dpiAdjustedAxisTitleStyle, this.axisAlignment);
589
590
  }
590
591
  else {
591
592
  this.axisRenderer.desiredHeight = 0;
@@ -648,7 +649,6 @@ var AxisBase2D = /** @class */ (function (_super) {
648
649
  var viewTitleRect = _this.axisTitleRenderer.viewRect;
649
650
  var brush = _this.solidBrushCacheAxisBackground.newBrush(_this.backgroundColorProperty, false);
650
651
  var nativeAxisRect = void 0;
651
- var nativeTitleRect = void 0;
652
652
  // Empty space covering for axis coloring
653
653
  // let shift: number = 0;
654
654
  // let additionalSize: number = 0;
@@ -675,17 +675,11 @@ var AxisBase2D = /** @class */ (function (_super) {
675
675
  // nativeAxisRect = createNativeRect(this.webAssemblyContext2D, 0, 0 - shift, viewAxisRect.width, viewAxisRect.height + additionalSize);
676
676
  // nativeTitleRect = createNativeRect(this.webAssemblyContext2D, 0, 0 - shift, viewTitleRect.width, viewTitleRect.height + additionalSize);
677
677
  // }
678
- nativeAxisRect = (0, createNativeRect_1.createNativeRect)(_this.webAssemblyContext2D, 0, 0, viewAxisRect.width, viewAxisRect.height);
678
+ nativeAxisRect = (0, createNativeRect_1.createNativeRect)(_this.webAssemblyContext2D, 0, 0, _this.viewRect.width, _this.viewRect.height);
679
679
  if (nativeAxisRect) {
680
680
  var vecRects = (0, NativeObject_1.getVectorRectVertex)(_this.webAssemblyContext2D);
681
681
  vecRects.push_back(nativeAxisRect);
682
- renderContext.drawRects(vecRects, brush, viewAxisRect.left, viewAxisRect.top);
683
- }
684
- nativeTitleRect = (0, createNativeRect_1.createNativeRect)(_this.webAssemblyContext2D, 0, 0, viewTitleRect.width, viewTitleRect.height);
685
- if (nativeTitleRect) {
686
- var vecRects = (0, NativeObject_1.getVectorRectVertex)(_this.webAssemblyContext2D);
687
- vecRects.push_back(nativeTitleRect);
688
- renderContext.drawRects(vecRects, brush, viewTitleRect.left, viewTitleRect.top);
682
+ renderContext.drawRects(vecRects, brush, _this.viewRect.x, _this.viewRect.y);
689
683
  }
690
684
  }
691
685
  // Draw axis labels
@@ -703,7 +697,7 @@ var AxisBase2D = /** @class */ (function (_super) {
703
697
  _this.axisRenderer.drawTicks(renderContext, _this.axisAlignment, _this.isInnerAxis, tickObject.majorTickCoords, _this.offset, penForMajorTickLines, majorTickStyle);
704
698
  }
705
699
  // Draw axis title
706
- _this.axisTitleRenderer.draw(renderContext, _this.dpiAdjustedAxisTitleStyle, _this.axisAlignment, _this.parentSurface.debugRendering);
700
+ _this.axisTitleRenderer.draw(renderContext);
707
701
  if (_this.labelProvider.useNativeText && _this.parentSurface.renderNativeAxisLabelsImmediately) {
708
702
  renderContext.endFonts(true);
709
703
  }
@@ -1105,9 +1099,6 @@ var AxisBase2D = /** @class */ (function (_super) {
1105
1099
  * @inheritDoc
1106
1100
  */
1107
1101
  AxisBase2D.prototype.notifyPropertyChanged = function (propertyName) {
1108
- if (propertyName === constants_1.PROPERTY.AXIS_TITLE && this.axisTitleRenderer) {
1109
- this.axisTitleRenderer.text = this.axisTitle;
1110
- }
1111
1102
  if (propertyName === constants_1.PROPERTY.IS_XAXIS) {
1112
1103
  if (this.axisAlignmentProperty === undefined) {
1113
1104
  this.axisAlignmentProperty = this.isXAxisProperty ? AxisAlignment_1.EAxisAlignment.Bottom : AxisAlignment_1.EAxisAlignment.Right;
@@ -69,6 +69,10 @@ export declare type TTextStyle = {
69
69
  /** Horizontal text alignment for multiline text. */
70
70
  multilineAlignment?: EMultiLineAlignment;
71
71
  };
72
+ export declare type TAxisTitleStyle = TTextStyle & {
73
+ /** Text rotation in degrees. */
74
+ rotation?: number;
75
+ };
72
76
  /**
73
77
  * Interface to minimal set of parameters which define an {@link AxisCore | Axis} in SciChart
74
78
  */
@@ -82,7 +86,7 @@ export interface IAxisParams {
82
86
  * axis.visibleRange = new NumberRange(15, 25);
83
87
  * ```
84
88
  * @remarks
85
- * The visibleRange is a data-value for {@link NumericAxis}, @{link NumericAxis3D} but refers to an **index** to the data
89
+ * The visibleRange is a data-value for {@link NumericAxis}, {@link NumericAxis3D} but refers to an **index** to the data
86
90
  * for {@link CategoryAxis} types.
87
91
  */
88
92
  visibleRange: NumberRange;
@@ -147,6 +151,8 @@ export declare abstract class AxisCore implements IAxisParams, IDeletable {
147
151
  visibleRangeChanged: EventHandler<VisibleRangeChangedArgs>;
148
152
  /** A flag to indicate if measure has been called this frame. Properties updated after measure must trigger a redraw */
149
153
  isMeasured: boolean;
154
+ /** If the diff of the visibleRange is 0, this growby fraction will be applied */
155
+ ZeroRangeGrowBy: number;
150
156
  /**
151
157
  * Internal backing property for {@link AxisCore.id}. To fire {@link AxisCore.invalidateParentCallback}, set the public property
152
158
  */
@@ -246,7 +252,7 @@ export declare abstract class AxisCore implements IAxisParams, IDeletable {
246
252
  /**
247
253
  * Internal backing property for {@link AxisCore.axisTitleStyle}. To fire {@link AxisCore.invalidateParentCallback}, set the public property
248
254
  */
249
- protected axisTitleStyleProperty: TTextStyle;
255
+ protected axisTitleStyleProperty: TAxisTitleStyle;
250
256
  /**
251
257
  * Internal backing property for {@link AxisCore.tickProvider}. To fire {@link AxisCore.invalidateParentCallback}, set the public property
252
258
  */
@@ -401,7 +407,7 @@ export declare abstract class AxisCore implements IAxisParams, IDeletable {
401
407
  * axis.visibleRange = new NumberRange(15, 25);
402
408
  * ```
403
409
  * @remarks
404
- * The visibleRange is a data-value for {@link NumericAxis}, @{link NumericAxis3D} but refers to an **index** to the data
410
+ * The visibleRange is a data-value for {@link NumericAxis}, {@link NumericAxis3D} but refers to an **index** to the data
405
411
  * for {@link CategoryAxis} types.
406
412
  */
407
413
  get visibleRange(): NumberRange;
@@ -414,7 +420,7 @@ export declare abstract class AxisCore implements IAxisParams, IDeletable {
414
420
  * axis.visibleRange = new NumberRange(15, 25);
415
421
  * ```
416
422
  * @remarks
417
- * The visibleRange is a data-value for {@link NumericAxis}, @{link NumericAxis3D} but refers to an **index** to the data
423
+ * The visibleRange is a data-value for {@link NumericAxis}, {@link NumericAxis3D} but refers to an **index** to the data
418
424
  * for {@link CategoryAxis} types.
419
425
  */
420
426
  set visibleRange(visibleRange: NumberRange);
@@ -597,12 +603,12 @@ export declare abstract class AxisCore implements IAxisParams, IDeletable {
597
603
  */
598
604
  set drawLabels(drawLabels: boolean);
599
605
  /**
600
- * When true, axis coordinates are flipped, e.g. a {@link NumericAxis} with @{link AxisCore.visibleRange | VisibleRange}
606
+ * When true, axis coordinates are flipped, e.g. a {@link NumericAxis} with {@link AxisCore.visibleRange | VisibleRange}
601
607
  * 0..10 will render from 10 to 0
602
608
  */
603
609
  get flippedCoordinates(): boolean;
604
610
  /**
605
- * When true, axis coordinates are flipped, e.g. a {@link NumericAxis} with @{link AxisCore.visibleRange | VisibleRange}
611
+ * When true, axis coordinates are flipped, e.g. a {@link NumericAxis} with {@link AxisCore.visibleRange | VisibleRange}
606
612
  * 0..10 will render from 10 to 0
607
613
  */
608
614
  set flippedCoordinates(flippedCoordinates: boolean);
@@ -669,17 +675,17 @@ export declare abstract class AxisCore implements IAxisParams, IDeletable {
669
675
  /**
670
676
  * Gets the {@link axisTitleStyle} adjusted for current DPI / Browser zoom level
671
677
  */
672
- get dpiAdjustedAxisTitleStyle(): TTextStyle;
678
+ get dpiAdjustedAxisTitleStyle(): TAxisTitleStyle;
673
679
  /**
674
680
  * @summary Gets or sets the Axis Title style
675
- * @remarks See {@link TTextStyle} for the type which contains style options
681
+ * @remarks See {@link TAxisTitleStyle} for the type which contains style options
676
682
  */
677
- get axisTitleStyle(): TTextStyle;
683
+ get axisTitleStyle(): TAxisTitleStyle;
678
684
  /**
679
685
  * @summary Gets or sets the Axis Title style
680
- * @remarks See {@link TTextStyle} for the type which contains style options
686
+ * @remarks See {@link TAxisTitleStyle} for the type which contains style options
681
687
  */
682
- set axisTitleStyle(textStyle: TTextStyle);
688
+ set axisTitleStyle(textStyle: TAxisTitleStyle);
683
689
  /**
684
690
  * Gets or sets the Axis title string
685
691
  * Use an array to create a multiLine title
@@ -24,8 +24,6 @@ var SciChartSurfaceBase_1 = require("../SciChartSurfaceBase");
24
24
  var DpiHelper_1 = require("../TextureManager/DpiHelper");
25
25
  var constants_1 = require("./constants");
26
26
  var VisibleRangeChangedArgs_1 = require("./VisibleRangeChangedArgs");
27
- /** @ignore */
28
- var ZeroRangeGrowBy = 0.01;
29
27
  /**
30
28
  * The base class for Axis within SciChart - High Performance {@link https://www.scichart.com/javascript-chart-features | JavaScript Charts}.
31
29
  * @description
@@ -52,6 +50,8 @@ var AxisCore = /** @class */ (function () {
52
50
  this.visibleRangeChanged = new EventHandler_1.EventHandler();
53
51
  /** A flag to indicate if measure has been called this frame. Properties updated after measure must trigger a redraw */
54
52
  this.isMeasured = false;
53
+ /** If the diff of the visibleRange is 0, this growby fraction will be applied */
54
+ this.ZeroRangeGrowBy = 0.01;
55
55
  /**
56
56
  * Internal backing property for {@link AxisCore.id}. To fire {@link AxisCore.invalidateParentCallback}, set the public property
57
57
  */
@@ -357,7 +357,7 @@ var AxisCore = /** @class */ (function () {
357
357
  * axis.visibleRange = new NumberRange(15, 25);
358
358
  * ```
359
359
  * @remarks
360
- * The visibleRange is a data-value for {@link NumericAxis}, @{link NumericAxis3D} but refers to an **index** to the data
360
+ * The visibleRange is a data-value for {@link NumericAxis}, {@link NumericAxis3D} but refers to an **index** to the data
361
361
  * for {@link CategoryAxis} types.
362
362
  */
363
363
  get: function () {
@@ -372,7 +372,7 @@ var AxisCore = /** @class */ (function () {
372
372
  * axis.visibleRange = new NumberRange(15, 25);
373
373
  * ```
374
374
  * @remarks
375
- * The visibleRange is a data-value for {@link NumericAxis}, @{link NumericAxis3D} but refers to an **index** to the data
375
+ * The visibleRange is a data-value for {@link NumericAxis}, {@link NumericAxis3D} but refers to an **index** to the data
376
376
  * for {@link CategoryAxis} types.
377
377
  */
378
378
  set: function (visibleRange) {
@@ -670,14 +670,14 @@ var AxisCore = /** @class */ (function () {
670
670
  });
671
671
  Object.defineProperty(AxisCore.prototype, "flippedCoordinates", {
672
672
  /**
673
- * When true, axis coordinates are flipped, e.g. a {@link NumericAxis} with @{link AxisCore.visibleRange | VisibleRange}
673
+ * When true, axis coordinates are flipped, e.g. a {@link NumericAxis} with {@link AxisCore.visibleRange | VisibleRange}
674
674
  * 0..10 will render from 10 to 0
675
675
  */
676
676
  get: function () {
677
677
  return this.flippedCoordinatesProperty;
678
678
  },
679
679
  /**
680
- * When true, axis coordinates are flipped, e.g. a {@link NumericAxis} with @{link AxisCore.visibleRange | VisibleRange}
680
+ * When true, axis coordinates are flipped, e.g. a {@link NumericAxis} with {@link AxisCore.visibleRange | VisibleRange}
681
681
  * 0..10 will render from 10 to 0
682
682
  */
683
683
  set: function (flippedCoordinates) {
@@ -817,14 +817,14 @@ var AxisCore = /** @class */ (function () {
817
817
  Object.defineProperty(AxisCore.prototype, "axisTitleStyle", {
818
818
  /**
819
819
  * @summary Gets or sets the Axis Title style
820
- * @remarks See {@link TTextStyle} for the type which contains style options
820
+ * @remarks See {@link TAxisTitleStyle} for the type which contains style options
821
821
  */
822
822
  get: function () {
823
823
  return this.axisTitleStyleProperty;
824
824
  },
825
825
  /**
826
826
  * @summary Gets or sets the Axis Title style
827
- * @remarks See {@link TTextStyle} for the type which contains style options
827
+ * @remarks See {@link TAxisTitleStyle} for the type which contains style options
828
828
  */
829
829
  set: function (textStyle) {
830
830
  this.axisTitleStyleProperty = __assign(__assign({}, this.axisTitleStyle), textStyle);
@@ -1006,7 +1006,12 @@ var AxisCore = /** @class */ (function () {
1006
1006
  AxisCore.prototype.coerceZeroVisibleRange = function (range) {
1007
1007
  Guard_1.Guard.notNull(range, "range");
1008
1008
  if (range.isZero()) {
1009
- return range.growBy(new NumberRange_1.NumberRange(ZeroRangeGrowBy, ZeroRangeGrowBy));
1009
+ if (range.min === 0) {
1010
+ return new NumberRange_1.NumberRange(-1, 1);
1011
+ }
1012
+ else {
1013
+ return range.growBy(new NumberRange_1.NumberRange(this.ZeroRangeGrowBy, this.ZeroRangeGrowBy));
1014
+ }
1010
1015
  }
1011
1016
  return range;
1012
1017
  };
@@ -1,32 +1,28 @@
1
1
  import { Rect } from "../../../Core/Rect";
2
2
  import { EAxisAlignment } from "../../../types/AxisAlignment";
3
- import { TSciChart } from "../../../types/TSciChart";
4
3
  import { WebGlRenderContext2D } from "../../Drawing/WebGlRenderContext2D";
5
- import { TextureManager, TTextureObject } from "../TextureManager/TextureManager";
6
- import { TTextStyle } from "./AxisCore";
4
+ import { TitleRendererBase } from "../../Services/TitleRenderer";
5
+ import { SciChartSurface } from "../SciChartSurface";
6
+ import { TAxisTitleStyle } from "./AxisCore";
7
7
  /**
8
8
  * Draws an axis title using our WebGL Rendering engine
9
9
  */
10
- export declare class AxisTitleRenderer {
11
- useCache: boolean;
12
- viewRect: Rect;
13
- text: string | string[];
10
+ export declare class AxisTitleRenderer extends TitleRendererBase<TAxisTitleStyle> {
14
11
  lineSpacing: number;
12
+ /** For internal use */
13
+ parentSurface: SciChartSurface;
15
14
  private previousText;
16
- private textStyle;
17
15
  private previousLineSpacing;
18
- private texture;
19
- private webAssemblyContext;
20
- private desiredHeightProperty;
21
- private desiredWidthProperty;
22
- private textureManager;
23
- constructor(webAssemblyContext: TSciChart);
24
- measure(textStyle: TTextStyle, isHorizontal: boolean): void;
16
+ private previousNativeTextMode;
17
+ private previousAxisAlignment;
18
+ measure(text: string | string[], textStyle: TAxisTitleStyle, axisAlignment: EAxisAlignment): void;
19
+ get useNativeText(): boolean;
20
+ set useNativeText(value: boolean);
25
21
  get desiredHeight(): number;
26
22
  set desiredHeight(value: number);
27
23
  get desiredWidth(): number;
28
24
  set desiredWidth(value: number);
29
25
  layout(rect: Rect): void;
30
- getTitleTexture(text: string | string[], textStyle: TTextStyle, textureManager: TextureManager): TTextureObject;
31
- draw(renderContext: WebGlRenderContext2D, textStyle: TTextStyle, axisAlignment: EAxisAlignment, debugRendering: boolean): void;
26
+ protected getTitleTexture(): import("../TextureManager/TextureManager").TTextureObject;
27
+ draw(renderContext: WebGlRenderContext2D): void;
32
28
  }
@@ -1,63 +1,70 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
10
8
  };
11
- return __assign.apply(this, arguments);
12
- };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
13
17
  Object.defineProperty(exports, "__esModule", { value: true });
14
18
  exports.AxisTitleRenderer = void 0;
15
- var Deleter_1 = require("../../../Core/Deleter");
16
- var Rect_1 = require("../../../Core/Rect");
17
- var Thickness_1 = require("../../../Core/Thickness");
18
- var AxisAlignment_1 = require("../../../types/AxisAlignment");
19
- var parseColor_1 = require("../../../utils/parseColor");
20
- var WebGlPen_1 = require("../../Drawing/WebGlPen");
21
- var TextureManager_1 = require("../TextureManager/TextureManager");
22
- /** @ignore */
23
- var PADDING = {
24
- // TOP: 13,
25
- // BOTTOM: 8,
26
- NO_TITLE: 0
27
- };
19
+ var LabelAlignment_1 = require("../../../types/LabelAlignment");
20
+ var TextStyle_1 = require("../../../types/TextStyle");
21
+ var TitleRenderer_1 = require("../../Services/TitleRenderer");
28
22
  /**
29
23
  * Draws an axis title using our WebGL Rendering engine
30
24
  */
31
- var AxisTitleRenderer = /** @class */ (function () {
32
- function AxisTitleRenderer(webAssemblyContext) {
33
- this.useCache = true;
34
- this.viewRect = Rect_1.Rect.createZero();
35
- this.text = "";
36
- this.lineSpacing = 1.1;
37
- this.desiredHeightProperty = 0;
38
- this.desiredWidthProperty = 0;
39
- this.webAssemblyContext = webAssemblyContext;
40
- this.textureManager = new TextureManager_1.TextureManager(webAssemblyContext);
25
+ var AxisTitleRenderer = /** @class */ (function (_super) {
26
+ __extends(AxisTitleRenderer, _super);
27
+ function AxisTitleRenderer() {
28
+ var _this = _super !== null && _super.apply(this, arguments) || this;
29
+ _this.lineSpacing = 1.1;
30
+ return _this;
41
31
  }
42
- AxisTitleRenderer.prototype.measure = function (textStyle, isHorizontal) {
43
- var _a, _b, _c, _d;
44
- var lines = Array.isArray(this.text) ? this.text.length : 1;
45
- var lineWithSpacing = lines > 1 ? 1 + this.lineSpacing * (lines - 1) : lines;
46
- if (isHorizontal) {
47
- this.desiredHeightProperty = this.text
48
- ? lineWithSpacing * (0, TextureManager_1.measureTextHeight)(textStyle.fontSize) +
49
- ((_a = textStyle === null || textStyle === void 0 ? void 0 : textStyle.padding) === null || _a === void 0 ? void 0 : _a.bottom) +
50
- ((_b = textStyle === null || textStyle === void 0 ? void 0 : textStyle.padding) === null || _b === void 0 ? void 0 : _b.top)
51
- : PADDING.NO_TITLE;
52
- }
53
- else {
54
- this.desiredWidthProperty = this.text
55
- ? lineWithSpacing * (0, TextureManager_1.measureTextHeight)(textStyle.fontSize) +
56
- ((_c = textStyle === null || textStyle === void 0 ? void 0 : textStyle.padding) === null || _c === void 0 ? void 0 : _c.left) +
57
- ((_d = textStyle === null || textStyle === void 0 ? void 0 : textStyle.padding) === null || _d === void 0 ? void 0 : _d.right)
58
- : PADDING.NO_TITLE;
32
+ AxisTitleRenderer.prototype.measure = function (text, textStyle, axisAlignment) {
33
+ if (text === void 0) { text = ""; }
34
+ this.text = text;
35
+ var shouldUpdateTextSize = !this.useCache ||
36
+ (!this.texture && !this.useNativeText) ||
37
+ this.text !== this.previousText ||
38
+ this.lineSpacing !== this.previousLineSpacing ||
39
+ axisAlignment !== this.previousAxisAlignment ||
40
+ this.previousNativeTextMode !== this.useNativeText ||
41
+ !checkAreEqualTextStyles(textStyle, this.textStyle);
42
+ if (shouldUpdateTextSize) {
43
+ this.invalidateCache();
44
+ this.previousLineSpacing = this.lineSpacing;
45
+ this.previousNativeTextMode = this.useNativeText;
46
+ this.previousAxisAlignment = axisAlignment;
47
+ this.previousText = text;
48
+ this.textStyle = textStyle;
49
+ this.titlePosition = TextStyle_1.ETitlePosition[axisAlignment];
50
+ this.textStyle = textStyle;
51
+ // @ts-ignore mismatch with TTextStyle
52
+ this.textStyle.lineSpacing = this.lineSpacing;
53
+ var renderContext = this.parentSurface.currentWebGlRenderContext;
54
+ // @ts-ignore mismatch with TTextStyle
55
+ this.getTextSize(text, this.textStyle, renderContext);
59
56
  }
60
57
  };
58
+ Object.defineProperty(AxisTitleRenderer.prototype, "useNativeText", {
59
+ get: function () {
60
+ return this.useNativeTextProperty;
61
+ },
62
+ set: function (value) {
63
+ this.useNativeTextProperty = value;
64
+ },
65
+ enumerable: false,
66
+ configurable: true
67
+ });
61
68
  Object.defineProperty(AxisTitleRenderer.prototype, "desiredHeight", {
62
69
  get: function () {
63
70
  return this.desiredHeightProperty;
@@ -79,76 +86,49 @@ var AxisTitleRenderer = /** @class */ (function () {
79
86
  configurable: true
80
87
  });
81
88
  AxisTitleRenderer.prototype.layout = function (rect) {
82
- this.viewRect = rect;
83
- };
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;
89
+ if (!this.text) {
90
+ this.viewRectProperty = rect;
91
+ return;
91
92
  }
92
- this.previousLineSpacing = this.lineSpacing;
93
- this.previousText = text;
94
- this.textStyle = textStyle;
95
- var lines = Array.isArray(text) ? text : [text];
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;
93
+ var alignment = convertLabelAlignmentToTextAlignment(this.textStyle.alignment);
94
+ this.viewRectProperty = this.getViewRect(this.text, rect, this.titlePosition, alignment);
95
+ };
96
+ AxisTitleRenderer.prototype.getTitleTexture = function () {
97
+ var position = this.titlePosition;
98
+ var adjRotation = (0, TitleRenderer_1.getAdjustedRotation)(this.textStyle.rotation, position);
99
+ var titleText = Array.isArray(this.text) ? this.text : this.text.split("\n");
100
+ var texture = this.textureManager.createTextTexture(titleText,
101
+ // @ts-ignore mismatch with TTextStyle
102
+ this.textStyle,
103
+ // { ...this.textStyle, padding: new Thickness(0, 0, 0, 0) },
104
+ adjRotation, this.lineSpacing);
98
105
  return texture;
99
106
  };
100
- AxisTitleRenderer.prototype.draw = function (renderContext, textStyle, axisAlignment, debugRendering) {
101
- if (!this.text)
102
- return;
103
- var nativeContext = renderContext.getNativeContext();
104
- var _a = this.getTitleTexture(this.text, textStyle, this.textureManager), bitmapTexture = _a.bitmapTexture, textureHeight = _a.textureHeight, textureWidth = _a.textureWidth;
105
- var padding = textStyle.padding;
106
- if (axisAlignment === AxisAlignment_1.EAxisAlignment.Top || axisAlignment === AxisAlignment_1.EAxisAlignment.Bottom) {
107
- var deltaToCenter = (this.viewRect.width - textureWidth) / 2;
108
- var xPositionCenter = this.viewRect.x + deltaToCenter;
109
- var yPosition = this.viewRect.y + (padding === null || padding === void 0 ? void 0 : padding.top);
110
- // (axisAlignment === EAxisAlignment.Bottom ? padding?.top : padding?.bottom);
111
- nativeContext.DrawTexture(bitmapTexture, Math.round(xPositionCenter), Math.round(yPosition), textureWidth, textureHeight);
112
- // for debugging width and height measure
113
- if (debugRendering) {
114
- var pen = new WebGlPen_1.WebGlPen(new this.webAssemblyContext.SCRTPen((0, parseColor_1.parseColorToUIntArgb)("Red"), 1, true));
115
- renderContext.drawRect(new Rect_1.Rect(xPositionCenter, yPosition, textureWidth, textureHeight), Rect_1.Rect.create(0, 0, 999, 999), pen);
116
- pen.delete();
117
- }
118
- // End debug
119
- }
120
- if (axisAlignment === AxisAlignment_1.EAxisAlignment.Left) {
121
- nativeContext.PushMatrix();
122
- nativeContext.Rotate(-90);
123
- var deltaToCenter = (this.viewRect.height - textureWidth) / 2;
124
- var xPositionCenter = -(this.viewRect.y + this.viewRect.height) + deltaToCenter;
125
- nativeContext.Translate(Math.round(xPositionCenter), Math.round(this.viewRect.x + (padding === null || padding === void 0 ? void 0 : padding.left)));
126
- nativeContext.DrawTexture(bitmapTexture, 0, 0, textureWidth, textureHeight);
127
- nativeContext.PopMatrix();
128
- }
129
- if (axisAlignment === AxisAlignment_1.EAxisAlignment.Right) {
130
- nativeContext.PushMatrix();
131
- nativeContext.Rotate(90);
132
- var deltaToCenter = (this.viewRect.height - textureWidth) / 2;
133
- var xPositionCenter = this.viewRect.y + deltaToCenter;
134
- nativeContext.Translate(Math.round(xPositionCenter), Math.round(-(this.viewRect.x + this.viewRect.width) + (padding === null || padding === void 0 ? void 0 : padding.right)));
135
- nativeContext.DrawTexture(bitmapTexture, 0, 0, textureWidth, textureHeight);
136
- nativeContext.PopMatrix();
137
- }
138
- if (!this.useCache) {
139
- (0, Deleter_1.deleteSafe)(bitmapTexture);
140
- this.texture = undefined;
141
- }
107
+ AxisTitleRenderer.prototype.draw = function (renderContext) {
108
+ return this.drawInternal(renderContext, this.useNativeText, this.titlePosition);
142
109
  };
143
110
  return AxisTitleRenderer;
144
- }());
111
+ }(TitleRenderer_1.TitleRendererBase));
145
112
  exports.AxisTitleRenderer = AxisTitleRenderer;
146
113
  var checkAreEqualTextStyles = function (style1, style2) {
114
+ if (!style1 || !style2) {
115
+ return false;
116
+ }
147
117
  return (style1.color === style2.color &&
148
118
  style1.fontFamily === style2.fontFamily &&
149
119
  style1.fontSize === style2.fontSize &&
150
120
  style1.fontStyle === style2.fontStyle &&
151
121
  style1.fontWeight === style2.fontWeight &&
122
+ style1.alignment === style2.alignment &&
123
+ style1.rotation === style2.rotation &&
152
124
  style1.multilineAlignment === style2.multilineAlignment &&
153
125
  ((style1.padding === undefined && style2.padding === undefined) || style1.padding.equals(style2.padding)));
154
126
  };
127
+ // TODO consider refactoring
128
+ // helper function used to unify title renderer types & interfaces
129
+ var convertLabelAlignmentToTextAlignment = function (alignment) {
130
+ if (alignment === LabelAlignment_1.ELabelAlignment.Auto) {
131
+ return TextStyle_1.ETextAlignment.Center;
132
+ }
133
+ return TextStyle_1.ETextAlignment[alignment];
134
+ };
@@ -19,7 +19,7 @@ export interface IAxisCoreOptions {
19
19
  * axis.visibleRange = new NumberRange(15, 25);
20
20
  * ```
21
21
  * @remarks
22
- * The visibleRange is a data-value for {@link NumericAxis}, @{link NumericAxis3D} but refers to an **index** to the data
22
+ * The visibleRange is a data-value for {@link NumericAxis}, {@link NumericAxis3D} but refers to an **index** to the data
23
23
  * for {@link CategoryAxis} types.
24
24
  */
25
25
  visibleRange?: NumberRange;
@@ -152,7 +152,7 @@ export interface IAxisCoreOptions {
152
152
  */
153
153
  axisBandsFill?: string;
154
154
  /**
155
- * When true, axis coordinates are flipped, e.g. a {@link NumericAxis} with @{link AxisCore.visibleRange | VisibleRange}
155
+ * When true, axis coordinates are flipped, e.g. a {@link NumericAxis} with {@link AxisCore.visibleRange | VisibleRange}
156
156
  * 0..10 will render from 10 to 0
157
157
  */
158
158
  flippedCoordinates?: boolean;
@@ -113,6 +113,7 @@ var pruneCache = function () {
113
113
  };
114
114
  var checkTextStyleEqual = function (style1, style2) {
115
115
  return (style1.alignment === style2.alignment &&
116
+ style1.multilineAlignment === style2.multilineAlignment &&
116
117
  style1.color === style2.color &&
117
118
  style1.fontFamily === style2.fontFamily &&
118
119
  style1.fontSize === style2.fontSize &&
@@ -128,10 +128,17 @@ var BandSeriesHitTestProvider = /** @class */ (function (_super) {
128
128
  }
129
129
  if (dataSeries.dataDistributionCalculator.isSortedAscending && nearestPointIndex >= 0) {
130
130
  var dataSeriesCount = xNativeValues.size();
131
- var xValue = xNativeValues.get(nearestPointIndex);
132
- var xHitValue = xCoordinateCalculator.getDataValue(xHitCoord);
133
- if (!(nearestPointIndex === dataSeriesCount - 1 && xHitValue >= xValue) &&
134
- !(nearestPointIndex === 0 && xHitValue <= xValue)) {
131
+ var nearestXCoord = xCoordinateCalculator.getCoordinate(xCoordinateCalculator.isCategoryCoordinateCalculator
132
+ ? nearestPointIndex
133
+ : xNativeValues.get(nearestPointIndex));
134
+ if (!(nearestPointIndex === dataSeriesCount - 1 &&
135
+ (xCoordinateCalculator.hasFlippedCoordinates
136
+ ? xHitCoord >= nearestXCoord
137
+ : xHitCoord <= nearestXCoord)) &&
138
+ !(nearestPointIndex === 0 &&
139
+ (xCoordinateCalculator.hasFlippedCoordinates
140
+ ? xHitCoord <= nearestXCoord
141
+ : xHitCoord >= nearestXCoord))) {
135
142
  var hitRes = hitTestHelpers_1.hitTestHelpers.testIsHitForLine(xCoordinateCalculator, yCoordinateCalculator, xNativeValues, yNativeValues, nearestPointIndex, xHitCoord, yHitCoord, 0);
136
143
  hitTestInfo.point2dataSeriesIndex = hitRes.secondPointIndex;
137
144
  if (hitRes.secondPointIndex !== undefined) {
@@ -84,10 +84,17 @@ var BaseHitTestProvider = /** @class */ (function () {
84
84
  hitTestInfo.isHit = hitTestInfo.isWithinDataBounds;
85
85
  if (dataSeries.dataDistributionCalculator.isSortedAscending && nearestPointIndex >= 0) {
86
86
  var dataSeriesCount = xNativeValues.size();
87
- var xValue = xNativeValues.get(nearestPointIndex);
88
- var xHitValue = xCoordinateCalculator.getDataValue(xHitCoord);
89
- if (!(nearestPointIndex === dataSeriesCount - 1 && xHitValue >= xValue) &&
90
- !(nearestPointIndex === 0 && xHitValue <= xValue)) {
87
+ var nearestXCoord = xCoordinateCalculator.getCoordinate(xCoordinateCalculator.isCategoryCoordinateCalculator
88
+ ? nearestPointIndex
89
+ : xNativeValues.get(nearestPointIndex));
90
+ if (!(nearestPointIndex === dataSeriesCount - 1 &&
91
+ (xCoordinateCalculator.hasFlippedCoordinates
92
+ ? xHitCoord >= nearestXCoord
93
+ : xHitCoord <= nearestXCoord)) &&
94
+ !(nearestPointIndex === 0 &&
95
+ (xCoordinateCalculator.hasFlippedCoordinates
96
+ ? xHitCoord <= nearestXCoord
97
+ : xHitCoord >= nearestXCoord))) {
91
98
  var hitRes = hitTestHelpers_1.hitTestHelpers.testIsHitForLine(xCoordinateCalculator, yCoordinateCalculator, xNativeValues, yNativeValues, nearestPointIndex, xHitCoord, yHitCoord, 0);
92
99
  hitTestInfo.point2dataSeriesIndex = hitRes.secondPointIndex;
93
100
  hitTestInfo.point2xValue = xNativeValues.get(hitRes.secondPointIndex);
@@ -60,10 +60,17 @@ var LineSeriesHitTestProvider = /** @class */ (function (_super) {
60
60
  var hitTestInfo = hitTestHelpers_1.hitTestHelpers.createHitTestInfo(this.parentSeries, xCoordinateCalculator, yCoordinateCalculator, isVerticalChart, dataSeries, xNativeValues, yNativeValues, xHitCoord, yHitCoord, nearestPointIndex, hitTestRadius);
61
61
  if (nearestPointIndex >= 0) {
62
62
  var dataSeriesCount = xNativeValues.size();
63
- var xValue = xNativeValues.get(nearestPointIndex);
64
- var xHitValue = xCoordinateCalculator.getDataValue(xHitCoord);
65
- if ((nearestPointIndex === dataSeriesCount - 1 && xHitValue >= xValue) ||
66
- (nearestPointIndex === 0 && xHitValue <= xValue)) {
63
+ var nearestXCoord = xCoordinateCalculator.getCoordinate(xCoordinateCalculator.isCategoryCoordinateCalculator
64
+ ? nearestPointIndex
65
+ : xNativeValues.get(nearestPointIndex));
66
+ if ((nearestPointIndex === dataSeriesCount - 1 &&
67
+ (xCoordinateCalculator.hasFlippedCoordinates
68
+ ? xHitCoord >= nearestXCoord
69
+ : xHitCoord <= nearestXCoord)) ||
70
+ (nearestPointIndex === 0 &&
71
+ (xCoordinateCalculator.hasFlippedCoordinates
72
+ ? xHitCoord <= nearestXCoord
73
+ : xHitCoord >= nearestXCoord))) {
67
74
  hitTestInfo.isHit = hitTestHelpers_1.hitTestHelpers.testIsHitForPoint(xCoordinateCalculator, yCoordinateCalculator, xNativeValues, yNativeValues, nearestPointIndex, xHitCoord, yHitCoord, hitTestRadius);
68
75
  }
69
76
  else {
@@ -225,6 +225,7 @@ export declare class SciChartSurface extends SciChartSurfaceBase {
225
225
  protected titleStyleProperty: Readonly<Required<TChartTitleStyle>>;
226
226
  protected chartTitleRendererProperty: IChartTitleRenderer;
227
227
  protected paddingProperty: Thickness;
228
+ protected currentWebGlRenderContextProperty: WebGlRenderContext2D;
228
229
  private readonly sciChartRenderer;
229
230
  private layoutManagerProperty;
230
231
  private dataLabelLayoutManagerProperty;
@@ -468,6 +469,7 @@ export declare class SciChartSurface extends SciChartSurfaceBase {
468
469
  * Gets the SciChartSurface Canvas Bottom Border
469
470
  */
470
471
  get bottomCanvasBorder(): number;
472
+ get currentWebGlRenderContext(): WebGlRenderContext2D;
471
473
  /**
472
474
  * Is being called on each render, to run animations
473
475
  * @param timeElapsed