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
@@ -65,4 +65,4 @@ export declare const getScrtPenFromCache: (penCache: Pen2DCache) => SCRTPen;
65
65
  * @param strokeDashArray the StrokeDashArray which defines any dash e.g. [2,2] means dash for 2pts, gap for 2pts (or undefined = solid line).
66
66
  * @returns the new or existing instance of {@link SCRTPen}}
67
67
  */
68
- export declare const createPenInCache: (penCache: Pen2DCache, stroke: string, strokeThickness: number, opacity: number, strokeDashArray?: number[]) => SCRTPen;
68
+ export declare const createPenInCache: (penCache: Pen2DCache, stroke: string, strokeThickness: number, opacity: number, strokeDashArray?: number[], antiAliased?: boolean) => SCRTPen;
@@ -119,13 +119,14 @@ exports.getScrtPenFromCache = getScrtPenFromCache;
119
119
  * @param strokeDashArray the StrokeDashArray which defines any dash e.g. [2,2] means dash for 2pts, gap for 2pts (or undefined = solid line).
120
120
  * @returns the new or existing instance of {@link SCRTPen}}
121
121
  */
122
- var createPenInCache = function (penCache, stroke, strokeThickness, opacity, strokeDashArray) {
122
+ var createPenInCache = function (penCache, stroke, strokeThickness, opacity, strokeDashArray, antiAliased) {
123
123
  Guard_1.Guard.notNull(penCache, "penCache");
124
124
  var cachedPen = penCache.create({
125
125
  stroke: stroke,
126
126
  strokeThickness: strokeThickness,
127
127
  opacity: opacity,
128
- strokeDashArray: strokeDashArray
128
+ strokeDashArray: strokeDashArray,
129
+ antiAliased: antiAliased
129
130
  });
130
131
  return cachedPen.scrtPen;
131
132
  };
@@ -0,0 +1,37 @@
1
+ import { Rect } from "../../Core/Rect";
2
+ import { Thickness } from "../../Core/Thickness";
3
+ import { TChartTitleStyle } from "../../types/TextStyle";
4
+ import { WebGlRenderContext2D } from "../Drawing/WebGlRenderContext2D";
5
+ import { IChartTitleRenderer, TitleRendererBase } from "./TitleRenderer";
6
+ /**
7
+ * Draws a chart title
8
+ */
9
+ export declare class ChartTitleRenderer extends TitleRendererBase<TChartTitleStyle> implements IChartTitleRenderer {
10
+ protected titleOffsetProperty: Thickness;
11
+ /**
12
+ * Defines a padding reserved for space taken by a title
13
+ */
14
+ get titleOffset(): Thickness;
15
+ /**
16
+ * Calculates {@link ChartTitleRenderer.titleOffset}
17
+ */
18
+ measure(title: string | string[], originalTextStyle: Required<TChartTitleStyle>, renderContext: WebGlRenderContext2D): void;
19
+ /**
20
+ * Calculates {@link ChartTitleRenderer.viewRect} of the title
21
+ * @param chartViewRect - the container area which is used as an origin for title layout calculation
22
+ */
23
+ layout(chartViewRect: Rect): void;
24
+ /**
25
+ * Performs rendering of the title
26
+ */
27
+ draw(renderContext: WebGlRenderContext2D): void;
28
+ protected getTitleTexture(): import("../Visuals/TextureManager/TextureManager").TTextureObject;
29
+ /**
30
+ * Calculates width and hight of the title text
31
+ */
32
+ protected getTextSize(title: string | string[], textStyle: TChartTitleStyle, renderContext: WebGlRenderContext2D): void;
33
+ /**
34
+ * Calculates the {@link ChartTitleRenderer.titleOffset}
35
+ */
36
+ protected getTitleOffset(title: string | string[], textStyle: TChartTitleStyle): Thickness;
37
+ }
@@ -0,0 +1,176 @@
1
+ "use strict";
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);
8
+ };
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
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.ChartTitleRenderer = void 0;
30
+ var Thickness_1 = require("../../Core/Thickness");
31
+ var TextStyle_1 = require("../../types/TextStyle");
32
+ var text_1 = require("../../utils/text");
33
+ var SciChartSurfaceBase_1 = require("../Visuals/SciChartSurfaceBase");
34
+ var TitleRenderer_1 = require("./TitleRenderer");
35
+ /**
36
+ * Draws a chart title
37
+ */
38
+ var ChartTitleRenderer = /** @class */ (function (_super) {
39
+ __extends(ChartTitleRenderer, _super);
40
+ function ChartTitleRenderer() {
41
+ var _this = _super !== null && _super.apply(this, arguments) || this;
42
+ _this.titleOffsetProperty = Thickness_1.Thickness.fromNumber(0);
43
+ return _this;
44
+ }
45
+ Object.defineProperty(ChartTitleRenderer.prototype, "titleOffset", {
46
+ /**
47
+ * Defines a padding reserved for space taken by a title
48
+ */
49
+ get: function () {
50
+ return this.titleOffsetProperty;
51
+ },
52
+ enumerable: false,
53
+ configurable: true
54
+ });
55
+ /**
56
+ * Calculates {@link ChartTitleRenderer.titleOffset}
57
+ */
58
+ ChartTitleRenderer.prototype.measure = function (title, originalTextStyle, renderContext) {
59
+ var _a;
60
+ var shouldUpdateTextSize = title !== this.text ||
61
+ !(0, TextStyle_1.areEqualTextStyles)(originalTextStyle, this.originalTextStyle) ||
62
+ ((_a = this.originalTextStyle) === null || _a === void 0 ? void 0 : _a.position) !== originalTextStyle.position;
63
+ this.text = title;
64
+ if (title) {
65
+ if (!this.useCache || !this.texture || shouldUpdateTextSize) {
66
+ // recalculate cached text size info or texture
67
+ this.originalTextStyle = __assign({}, originalTextStyle);
68
+ this.textStyle = (0, TextStyle_1.adjustTextStyle)(originalTextStyle);
69
+ this.getTextSize(title, this.textStyle, renderContext);
70
+ }
71
+ else {
72
+ // update text style properties that only affect placement
73
+ this.textStyle.alignment = originalTextStyle.alignment;
74
+ this.textStyle.placeWithinChart = originalTextStyle.placeWithinChart;
75
+ }
76
+ }
77
+ this.titleOffsetProperty = this.getTitleOffset(title, this.textStyle);
78
+ };
79
+ /**
80
+ * Calculates {@link ChartTitleRenderer.viewRect} of the title
81
+ * @param chartViewRect - the container area which is used as an origin for title layout calculation
82
+ */
83
+ ChartTitleRenderer.prototype.layout = function (chartViewRect) {
84
+ if (!this.text) {
85
+ this.viewRectProperty = undefined;
86
+ return;
87
+ }
88
+ this.viewRectProperty = this.getViewRect(this.text, chartViewRect, this.textStyle.position, this.textStyle.alignment);
89
+ };
90
+ /**
91
+ * Performs rendering of the title
92
+ */
93
+ ChartTitleRenderer.prototype.draw = function (renderContext) {
94
+ if (!this.text) {
95
+ return;
96
+ }
97
+ if (SciChartSurfaceBase_1.DebugForDpi) {
98
+ console.log("ChartTitleRenderer.draw fontSize: ".concat(this.textStyle.fontSize));
99
+ }
100
+ var _a = this.textStyle, useNativeText = _a.useNativeText, position = _a.position, lineSpacing = _a.lineSpacing;
101
+ this.drawInternal(renderContext, useNativeText, position, lineSpacing);
102
+ if (this.drawDebug) {
103
+ this.drawTitleDebugViewRect(renderContext);
104
+ }
105
+ };
106
+ ChartTitleRenderer.prototype.getTitleTexture = function () {
107
+ var position = this.textStyle.position;
108
+ var adjRotation = 0;
109
+ // let adjRotation = this.textStyle.rotation;
110
+ if (position === TextStyle_1.ETitlePosition.Left) {
111
+ adjRotation += -90;
112
+ }
113
+ else if (position === TextStyle_1.ETitlePosition.Right) {
114
+ adjRotation += 90;
115
+ }
116
+ // TODO try using rotation property here
117
+ var titleText = Array.isArray(this.text) ? this.text : this.text.split("\n");
118
+ var texture = this.textureManager.createTextTexture(titleText,
119
+ // @ts-ignore mismatch with TTextStyle
120
+ this.textStyle,
121
+ // { ...this.textStyle, padding: new Thickness(0, 0, 0, 0) },
122
+ adjRotation, this.textStyle.lineSpacing);
123
+ return texture;
124
+ };
125
+ /**
126
+ * Calculates width and hight of the title text
127
+ */
128
+ ChartTitleRenderer.prototype.getTextSize = function (title, textStyle, renderContext) {
129
+ if (title === void 0) { title = ""; }
130
+ var hasHorizontalPlacement = (0, TextStyle_1.getIsHorizontalPlacement)(textStyle.position);
131
+ if (textStyle.useNativeText) {
132
+ // @ts-ignore mismatch with TTextStyle
133
+ var nativeFont = renderContext.getFont(textStyle, !hasHorizontalPlacement);
134
+ var titleString = Array.isArray(title) ? title.join("\n") : title;
135
+ var _a = (0, text_1.getNativeTextSize)(titleString, nativeFont, textStyle, this.webAssemblyContext), textHeight = _a.textHeight, textWidth = _a.textWidth, nativeLineSpacing = _a.nativeLineSpacing, firstLineAscent = _a.firstLineAscent;
136
+ this.textHeight = textHeight;
137
+ this.textWidth = textWidth;
138
+ this.nativeLineSpacing = nativeLineSpacing;
139
+ this.firstLineAscent = firstLineAscent;
140
+ this.desiredHeightProperty = hasHorizontalPlacement ? this.textHeight : this.textWidth;
141
+ this.desiredWidthProperty = hasHorizontalPlacement ? this.textWidth : this.textHeight;
142
+ }
143
+ else {
144
+ // current title texture doesn't include paddings, so they should be added here
145
+ var texture = this.getTitleTexture();
146
+ this.texture = texture;
147
+ this.desiredHeightProperty = texture.textureHeight;
148
+ this.desiredWidthProperty = texture.textureWidth;
149
+ this.textHeight = hasHorizontalPlacement ? this.desiredHeightProperty : this.desiredWidthProperty;
150
+ this.textWidth = hasHorizontalPlacement ? this.desiredWidthProperty : this.desiredHeightProperty;
151
+ }
152
+ };
153
+ /**
154
+ * Calculates the {@link ChartTitleRenderer.titleOffset}
155
+ */
156
+ ChartTitleRenderer.prototype.getTitleOffset = function (title, textStyle) {
157
+ if (!title || textStyle.placeWithinChart) {
158
+ return Thickness_1.Thickness.fromNumber(0);
159
+ }
160
+ var height = this.textHeight;
161
+ switch (textStyle.position) {
162
+ case TextStyle_1.ETitlePosition.Top:
163
+ return new Thickness_1.Thickness(height, 0, 0, 0);
164
+ case TextStyle_1.ETitlePosition.Bottom:
165
+ return new Thickness_1.Thickness(0, 0, height, 0);
166
+ case TextStyle_1.ETitlePosition.Left:
167
+ return new Thickness_1.Thickness(0, 0, 0, height);
168
+ case TextStyle_1.ETitlePosition.Right:
169
+ return new Thickness_1.Thickness(0, height, 0, 0);
170
+ default:
171
+ return (0, TextStyle_1.handleInvalidChartTitlePosition)(textStyle.position);
172
+ }
173
+ };
174
+ return ChartTitleRenderer;
175
+ }(TitleRenderer_1.TitleRendererBase));
176
+ exports.ChartTitleRenderer = ChartTitleRenderer;
@@ -41,5 +41,11 @@ export declare class SciChartRenderer {
41
41
  private tryPerformAutoRangeOn;
42
42
  private onParentSurfaceRendered;
43
43
  private updateWatermark;
44
- private getViewportRect;
44
+ private getViewportSvgRect;
45
+ private scheduleTitleDraw;
46
+ private measureTitle;
47
+ private layoutTitle;
48
+ private getChartViewRect;
49
+ private getAbsoluteLayer;
50
+ private drawDebugSurfaceRect;
45
51
  }
@@ -20,12 +20,16 @@ var hash_1 = require("../../utils/hash");
20
20
  var WebGlRenderContext2D_1 = require("../Drawing/WebGlRenderContext2D");
21
21
  var ResamplingParams_1 = require("../Numerics/Resamplers/ResamplingParams");
22
22
  var IAnnotation_1 = require("../Visuals/Annotations/IAnnotation");
23
+ var SciChartSurface_1 = require("../Visuals/SciChartSurface");
23
24
  var SciChartSurfaceBase_1 = require("../Visuals/SciChartSurfaceBase");
24
25
  var DpiHelper_1 = require("../Visuals/TextureManager/DpiHelper");
25
26
  var RenderPassData_1 = require("./RenderPassData");
26
27
  var RenderPassInfo_1 = require("./RenderPassInfo");
27
28
  var SvgClippingMode_1 = require("../../types/SvgClippingMode");
28
29
  var WatermarkPosition_1 = require("../../types/WatermarkPosition");
30
+ var NativeObject_1 = require("../Visuals/Helpers/NativeObject");
31
+ var createNativeRect_1 = require("../Visuals/Helpers/createNativeRect");
32
+ var parseColor_1 = require("../../utils/parseColor");
29
33
  /**
30
34
  * A class used internally in SciChart to perform layout, arrangement, data-preparation and rendering on the Cartesian 2D {@link SciChartSurface}
31
35
  */
@@ -122,23 +126,26 @@ var SciChartRenderer = /** @class */ (function () {
122
126
  this.sciChartSurface.onAnimate(timeElapsed);
123
127
  renderContext.enqueueLayeredDraw(function () {
124
128
  _this.sciChartSurface.updateBackground();
125
- }, (0, WebGlRenderContext2D_1.calculateAbsoluteRenderLayer)(this.sciChartSurface.layersOffset, this.sciChartSurface.stepBetweenLayers, DefaultRenderLayer_1.EDefaultRenderLayer.AxisBandsLayer));
129
+ }, this.getAbsoluteLayer(DefaultRenderLayer_1.EDefaultRenderLayer.AxisBandsLayer));
126
130
  // Step 2 autorange
127
131
  this.sciChartSurface.updateStackedCollectionAccumulatedVectors();
128
132
  this.sciChartSurface.xAxes.asArray().forEach(function (axis) { return _this.tryPerformAutoRangeOn(axis, _this.sciChartSurface); });
129
133
  this.sciChartSurface.yAxes.asArray().forEach(function (axis) { return _this.tryPerformAutoRangeOn(axis, _this.sciChartSurface); });
130
134
  // Step 3 layout
131
- var seriesViewRect = this.sciChartSurface.layoutManager.layoutChart(renderContext.viewportSize);
132
- var viewportSvgRect = this.getViewportRect(renderContext.viewportSize, seriesViewRect);
135
+ var titleOffset = this.measureTitle(renderContext);
136
+ var seriesViewRect = this.sciChartSurface.layoutManager.layoutChart(renderContext.viewportSize, titleOffset);
137
+ var viewportSvgRect = this.getViewportSvgRect(renderContext.viewportSize, seriesViewRect);
133
138
  this.sciChartSurface.setCoordSvgTranslation(seriesViewRect.x - viewportSvgRect.x, seriesViewRect.y - viewportSvgRect.y);
134
139
  this.updateSvgCanvasSize(viewportSvgRect);
140
+ this.layoutTitle(seriesViewRect);
141
+ this.scheduleTitleDraw(renderContext);
135
142
  // Step 4 prepare render data
136
143
  var _a = this.prepareAxesRenderData(), xAxesById = _a.xAxesById, yAxesById = _a.yAxesById;
137
144
  var renderPassInfo = this.prepareSeriesRenderData(seriesViewRect, xAxesById);
138
145
  // Draw seriesViewRect border
139
146
  renderContext.enqueueLayeredDraw(function () {
140
147
  _this.sciChartSurface.drawBorder(renderContext);
141
- }, (0, WebGlRenderContext2D_1.calculateAbsoluteRenderLayer)(this.sciChartSurface.layersOffset, this.sciChartSurface.stepBetweenLayers, DefaultRenderLayer_1.EDefaultRenderLayer.AxisBandsLayer));
148
+ }, this.getAbsoluteLayer(DefaultRenderLayer_1.EDefaultRenderLayer.AxisBandsLayer));
142
149
  // Step 5 Draw X, Y axis and gridlines
143
150
  if (this.sciChartSurface.debugRendering) {
144
151
  this.drawDebugAxes(this.sciChartSurface, renderContext);
@@ -157,14 +164,14 @@ var SciChartRenderer = /** @class */ (function () {
157
164
  el.type === IAnnotation_1.EAnnotationType.RenderContextAxisMarkerAnnotation ||
158
165
  el.type === IAnnotation_1.EAnnotationType.RenderContextNativeTextAnnotation);
159
166
  });
160
- var annotationsBelowLayer = (0, WebGlRenderContext2D_1.calculateAbsoluteRenderLayer)(this.sciChartSurface.layersOffset, this.sciChartSurface.stepBetweenLayers, DefaultRenderLayer_1.EDefaultRenderLayer.AnnotationsBelowSeriesLayer);
167
+ var annotationsBelowLayer = this.getAbsoluteLayer(DefaultRenderLayer_1.EDefaultRenderLayer.AnnotationsBelowSeriesLayer);
161
168
  renderContext.enqueueLayeredDraw(function () {
162
169
  _this.drawRenderContextAnnotations(renderContextAnnotations, xAxesById, yAxesById, IAnnotation_1.EAnnotationLayer.BelowChart, renderContext, seriesViewRect);
163
170
  }, annotationsBelowLayer);
164
- var seriesLayer = (0, WebGlRenderContext2D_1.calculateAbsoluteRenderLayer)(this.sciChartSurface.layersOffset, this.sciChartSurface.stepBetweenLayers, DefaultRenderLayer_1.EDefaultRenderLayer.SeriesLayer);
171
+ var seriesLayer = this.getAbsoluteLayer(DefaultRenderLayer_1.EDefaultRenderLayer.SeriesLayer);
165
172
  // Step 7 Draw series. Queue series rendering after grid lines and bands, but before the axes
166
173
  renderContext.enqueueLayeredDraw(function () { return _this.drawSeries(_this.sciChartSurface, renderPassInfo, renderContext); }, seriesLayer);
167
- var annotationsAboveLayer = (0, WebGlRenderContext2D_1.calculateAbsoluteRenderLayer)(this.sciChartSurface.layersOffset, this.sciChartSurface.stepBetweenLayers, DefaultRenderLayer_1.EDefaultRenderLayer.AnnotationsAboveSeriesLayer);
174
+ var annotationsAboveLayer = this.getAbsoluteLayer(DefaultRenderLayer_1.EDefaultRenderLayer.AnnotationsAboveSeriesLayer);
168
175
  // Step 8 Draw annotations above the series
169
176
  renderContext.enqueueLayeredDraw(function () {
170
177
  _this.drawRenderContextAnnotations(renderContextAnnotations, xAxesById, yAxesById, IAnnotation_1.EAnnotationLayer.AboveChart, renderContext, seriesViewRect);
@@ -180,7 +187,12 @@ var SciChartRenderer = /** @class */ (function () {
180
187
  });
181
188
  this.drawSvgAnnotations(svgAnnotations, xAxesById, yAxesById, this.sciChartSurface.getCoordSvgTranslation());
182
189
  // Update watermark
183
- this.updateWatermark(renderContext, seriesViewRect);
190
+ if (!this.sciChartSurface.isSubSurface) {
191
+ this.updateWatermark(renderContext, seriesViewRect);
192
+ }
193
+ else if (renderContext.doDraw) {
194
+ this.updateWatermark(renderContext, this.sciChartSurface.parentSurface.seriesViewRect);
195
+ }
184
196
  // Step 10 Call OnParentSurfaceRendered
185
197
  this.onParentSurfaceRendered();
186
198
  if (!app_1.IS_TEST_ENV) {
@@ -472,7 +484,7 @@ var SciChartRenderer = /** @class */ (function () {
472
484
  }
473
485
  this.sciChartSurface.updateWatermark(left, bottom);
474
486
  };
475
- SciChartRenderer.prototype.getViewportRect = function (viewportSize, seriesViewRect) {
487
+ SciChartRenderer.prototype.getViewportSvgRect = function (viewportSize, seriesViewRect) {
476
488
  switch (this.sciChartSurface.svgClippingMode) {
477
489
  case SvgClippingMode_1.ESvgClippingMode.SeriesViewRect:
478
490
  return seriesViewRect;
@@ -489,6 +501,45 @@ var SciChartRenderer = /** @class */ (function () {
489
501
  return seriesViewRect;
490
502
  }
491
503
  };
504
+ SciChartRenderer.prototype.scheduleTitleDraw = function (renderContext) {
505
+ var _this = this;
506
+ renderContext.enqueueLayeredDraw(function () {
507
+ _this.sciChartSurface.chartTitleRenderer.draw(renderContext);
508
+ }, this.getAbsoluteLayer(DefaultRenderLayer_1.EDefaultRenderLayer.AnnotationsAboveSeriesLayer));
509
+ };
510
+ SciChartRenderer.prototype.measureTitle = function (renderContext) {
511
+ this.sciChartSurface.chartTitleRenderer.measure(this.sciChartSurface.title, this.sciChartSurface.titleStyle, renderContext);
512
+ return this.sciChartSurface.chartTitleRenderer.titleOffset;
513
+ };
514
+ SciChartRenderer.prototype.layoutTitle = function (seriesViewRect) {
515
+ // current surface area which will contain title
516
+ var chartViewRect = this.sciChartSurface.titleStyle.placeWithinChart
517
+ ? seriesViewRect
518
+ : this.getChartViewRect();
519
+ // title position calculation
520
+ this.sciChartSurface.chartTitleRenderer.layout(chartViewRect);
521
+ };
522
+ SciChartRenderer.prototype.getChartViewRect = function () {
523
+ var viewportSize = this.sciChartSurface.renderSurface.viewportSize;
524
+ if (SciChartSurface_1.SciChartSurface.isSubSurface(this.sciChartSurface)) {
525
+ var viewportRect = new Rect_1.Rect(0, 0, viewportSize.width, viewportSize.height);
526
+ var sub = this.sciChartSurface;
527
+ viewportRect = sub.getSubChartRect();
528
+ return viewportRect;
529
+ }
530
+ return new Rect_1.Rect(0, 0, viewportSize.width, viewportSize.height);
531
+ };
532
+ SciChartRenderer.prototype.getAbsoluteLayer = function (relativeRenderLayer) {
533
+ return (0, WebGlRenderContext2D_1.calculateAbsoluteRenderLayer)(this.sciChartSurface.layersOffset, this.sciChartSurface.stepBetweenLayers, relativeRenderLayer);
534
+ };
535
+ SciChartRenderer.prototype.drawDebugSurfaceRect = function (renderContext, viewRect, wasmContext) {
536
+ var vecRects = (0, NativeObject_1.getVectorRectVertex)(wasmContext);
537
+ var brush = new wasmContext.SCRTSolidBrush((0, parseColor_1.parseColorToUIntArgb)("rgba(0,255,0,0.7)"), false);
538
+ var nativeRect = (0, createNativeRect_1.createNativeRect)(wasmContext, 0, 0, viewRect.width, viewRect.height);
539
+ vecRects.push_back(nativeRect);
540
+ renderContext.drawRects(vecRects, brush, viewRect.left, viewRect.top);
541
+ brush.delete();
542
+ };
492
543
  return SciChartRenderer;
493
544
  }());
494
545
  exports.SciChartRenderer = SciChartRenderer;
@@ -0,0 +1,91 @@
1
+ import { ICacheable } from "../../Core/ICacheable";
2
+ import { IDeletable } from "../../Core/IDeletable";
3
+ import { Rect } from "../../Core/Rect";
4
+ import { Thickness } from "../../Core/Thickness";
5
+ import { ETextAlignment, ETitlePosition, TChartTitleStyle } from "../../types/TextStyle";
6
+ import { WebGlRenderContext2D } from "../Drawing/WebGlRenderContext2D";
7
+ import { TTextStyle } from "../Visuals/Axis/AxisCore";
8
+ import { TSciChart } from "../Visuals/SciChartSurface";
9
+ import { INotifyOnDpiChanged, TDpiChangedEventArgs } from "../Visuals/TextureManager/DpiHelper";
10
+ import { TextureManager, TTextureObject } from "../Visuals/TextureManager/TextureManager";
11
+ export interface ITitleRenderer extends IDeletable, ICacheable, INotifyOnDpiChanged {
12
+ viewRect: Rect;
13
+ measure(...params: any[]): void;
14
+ draw(...params: any[]): void;
15
+ layout(viewRectOrigin: Rect): void;
16
+ }
17
+ export interface IChartTitleRenderer extends ITitleRenderer {
18
+ titleOffset: Thickness;
19
+ measure(title: string | string[], originalTextStyle: Required<TChartTitleStyle>, renderContext: WebGlRenderContext2D): void;
20
+ }
21
+ export declare class TitleRendererBase<TextStyleType extends TTextStyle | TChartTitleStyle> implements ITitleRenderer {
22
+ /**
23
+ * Defines a bounding {@link Rect} containing the title text
24
+ */
25
+ get viewRect(): Rect;
26
+ drawDebug: boolean;
27
+ useCache: boolean;
28
+ /**
29
+ * Current title
30
+ */
31
+ text: string | string[];
32
+ protected viewRectProperty: Rect;
33
+ protected webAssemblyContext: TSciChart;
34
+ protected textureManager: TextureManager;
35
+ /**
36
+ * Adjusted text style for the title
37
+ */
38
+ protected textStyle: TextStyleType;
39
+ /**
40
+ * Current not adjusted text style for the title
41
+ */
42
+ protected originalTextStyle: TextStyleType;
43
+ /**
44
+ * The height taken by the text with normal(horizontal) orientation including padding
45
+ */
46
+ protected textHeight: number;
47
+ /**
48
+ * The width taken by the text with normal(horizontal) orientation including padding
49
+ */
50
+ protected textWidth: number;
51
+ /**
52
+ * The height taken by the text considering current orientation orientation including padding
53
+ */
54
+ protected desiredHeightProperty: number;
55
+ /**
56
+ * The width taken by the text considering current orientation orientation including padding
57
+ */
58
+ protected desiredWidthProperty: number;
59
+ /**
60
+ * The text texture corresponding to current title and text style.
61
+ * @remarks The texture is created if {@link textStyle.useNativeText} is set to false
62
+ */
63
+ protected texture: TTextureObject;
64
+ /** The line spacing for native text calculated during measure */
65
+ protected nativeLineSpacing: number;
66
+ /** The height of the first line above baseline for native text, calculated during measure*/
67
+ protected firstLineAscent: number;
68
+ constructor(webAssemblyContext: TSciChart);
69
+ measure(...params: any[]): void;
70
+ layout(originRect: Rect): void;
71
+ draw(...params: any[]): void;
72
+ delete(): void;
73
+ resetCache(): void;
74
+ invalidateCache(): void;
75
+ onDpiChanged(args: TDpiChangedEventArgs): void;
76
+ /**
77
+ * Performs rendering of the title
78
+ */
79
+ protected drawInternal(renderContext: WebGlRenderContext2D, useNativeText: boolean, titlePosition: ETitlePosition, lineSpacing: number): void;
80
+ protected drawWithNativeText(renderContext: WebGlRenderContext2D, position: ETitlePosition): void;
81
+ protected drawWithTexture(renderContext: WebGlRenderContext2D, titlePosition: ETitlePosition): void;
82
+ /**
83
+ * Calculates the {@link TitleRenderer.viewRect}
84
+ */
85
+ protected getViewRect(title: string | string[], originRect: Rect, titlePosition: ETitlePosition, alignment: ETextAlignment): Rect;
86
+ protected drawTitleDebugViewRect(renderContext: WebGlRenderContext2D): void;
87
+ /**
88
+ * Calculates the offset of title text alignment defined by {@link TChartTitleStyle.alignment} or {@link TTextStyle.alignment}
89
+ */
90
+ private getAlignmentAdjustmentDelta;
91
+ }