scichart 3.3.560 → 3.3.567

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 (47) hide show
  1. package/Builder/buildSurface.d.ts +1 -1
  2. package/Builder/buildSurface.js +27 -14
  3. package/Charting/ChartModifiers/CursorModifier.js +3 -0
  4. package/Charting/ChartModifiers/RolloverModifier.js +3 -0
  5. package/Charting/Model/XyDataSeries.js +7 -0
  6. package/Charting/Services/SciChartRenderer.d.ts +1 -0
  7. package/Charting/Services/SciChartRenderer.js +19 -3
  8. package/Charting/Visuals/I2DSurfaceOptions.d.ts +5 -0
  9. package/Charting/Visuals/RenderableSeries/DrawingProviders/BaseSeriesDrawingProvider.js +4 -2
  10. package/Charting/Visuals/SciChartDefaults.d.ts +5 -0
  11. package/Charting/Visuals/SciChartDefaults.js +5 -0
  12. package/Charting/Visuals/SciChartPieSurface/SciChartPieSurface.d.ts +1 -1
  13. package/Charting/Visuals/SciChartPieSurface/SciChartPieSurface.js +6 -3
  14. package/Charting/Visuals/SciChartSurface.d.ts +14 -2
  15. package/Charting/Visuals/SciChartSurface.js +57 -5
  16. package/Charting/Visuals/SciChartSurfaceBase.d.ts +20 -5
  17. package/Charting/Visuals/SciChartSurfaceBase.js +100 -18
  18. package/Charting/Visuals/UpdateSuspender.d.ts +7 -3
  19. package/Charting/Visuals/UpdateSuspender.js +38 -8
  20. package/Charting/Visuals/copyCanvasUtils.d.ts +5 -0
  21. package/Charting/Visuals/copyCanvasUtils.js +24 -0
  22. package/Charting/Visuals/createMaster.js +25 -9
  23. package/Charting/Visuals/createSingle.js +10 -0
  24. package/Charting/Visuals/licenseManager2D.d.ts +1 -1
  25. package/Charting/Visuals/licenseManager2D.js +3 -3
  26. package/Charting/Visuals/sciChartInitCommon.js +5 -2
  27. package/Charting3D/Visuals/SciChart3DRenderer.d.ts +1 -0
  28. package/Charting3D/Visuals/SciChart3DRenderer.js +10 -1
  29. package/Charting3D/Visuals/SciChart3DSurface.d.ts +1 -0
  30. package/Charting3D/Visuals/SciChart3DSurface.js +28 -2
  31. package/Charting3D/Visuals/createMaster3d.js +2 -1
  32. package/Core/BuildStamp.d.ts +1 -1
  33. package/Core/BuildStamp.js +2 -2
  34. package/Core/Mouse/MouseManager.js +12 -7
  35. package/_wasm/scichart.browser.js +1 -1
  36. package/_wasm/scichart2d.js +1 -1
  37. package/_wasm/scichart2d.wasm +0 -0
  38. package/_wasm/scichart3d.js +1 -1
  39. package/_wasm/scichart3d.wasm +0 -0
  40. package/index.d.ts +2 -2
  41. package/index.dev.js +477 -63
  42. package/index.js +14 -12
  43. package/index.min.js +1 -1
  44. package/package.json +1 -1
  45. package/utils/logger.js +10 -1
  46. package/utils/perfomance.d.ts +139 -0
  47. package/utils/perfomance.js +150 -0
@@ -34,7 +34,7 @@ export interface ISciChart2DDefinition {
34
34
  * A function, or name of a registered OnCreated function that will be run after the chart is built,
35
35
  * receiving the sciChartSurface as a parameter
36
36
  */
37
- onCreated?: ((surface: SciChartSurface) => void) | string;
37
+ onCreated?: ((surface: SciChartSurface) => Promise<void>) | string;
38
38
  /**
39
39
  * Subcharts to be added to this surface
40
40
  */
@@ -70,6 +70,7 @@ var buildSeries_1 = require("./buildSeries");
70
70
  var chartBuilder_1 = require("./chartBuilder");
71
71
  var classFactory_1 = require("./classFactory");
72
72
  var ThemeProviderType_1 = require("../types/ThemeProviderType");
73
+ var perfomance_1 = require("../utils/perfomance");
73
74
  // register themes
74
75
  (0, classFactory_1.registerType)(BaseType_1.EBaseType.ThemeProvider, ThemeProviderType_1.EThemeProviderType.Light, function () { return new SciChartJSLightTheme_1.SciChartJSLightTheme(); }, true);
75
76
  (0, classFactory_1.registerType)(BaseType_1.EBaseType.ThemeProvider, ThemeProviderType_1.EThemeProviderType.DarkV2, function () { return new SciChartJSDarkv2Theme_1.SciChartJSDarkv2Theme(); }, true);
@@ -102,9 +103,10 @@ var ThemeProviderType_1 = require("../types/ThemeProviderType");
102
103
  * @param definition the {@link ISciChart2DDefinition}
103
104
  */
104
105
  var build2DChart = function (divElementId, definition) { return __awaiter(void 0, void 0, void 0, function () {
105
- var wasmChart, wasmContext, sciChartSurface;
106
- return __generator(this, function (_a) {
107
- switch (_a.label) {
106
+ var wasmChart, wasmContext, sciChartSurface, mark;
107
+ var _a;
108
+ return __generator(this, function (_b) {
109
+ switch (_b.label) {
108
110
  case 0:
109
111
  if (typeof definition === "string") {
110
112
  definition = JSON.parse(definition, chartBuilder_1.chartReviver);
@@ -112,24 +114,35 @@ var build2DChart = function (divElementId, definition) { return __awaiter(void 0
112
114
  if (!(definition === null || definition === void 0 ? void 0 : definition.createSingle)) return [3 /*break*/, 2];
113
115
  return [4 /*yield*/, SciChartSurface_1.SciChartSurface.createSingle(divElementId, definition === null || definition === void 0 ? void 0 : definition.surface)];
114
116
  case 1:
115
- wasmChart = _a.sent();
117
+ wasmChart = _b.sent();
116
118
  return [3 /*break*/, 4];
117
119
  case 2: return [4 /*yield*/, SciChartSurface_1.SciChartSurface.create(divElementId, definition === null || definition === void 0 ? void 0 : definition.surface)];
118
120
  case 3:
119
- wasmChart = _a.sent();
120
- _a.label = 4;
121
+ wasmChart = _b.sent();
122
+ _b.label = 4;
121
123
  case 4:
122
124
  wasmContext = wasmChart.wasmContext, sciChartSurface = wasmChart.sciChartSurface;
125
+ mark = perfomance_1.PerformanceDebugHelper.mark(perfomance_1.EPerformanceMarkType.SetupStart, { contextId: sciChartSurface.id });
123
126
  configure2DSurface(definition, sciChartSurface, wasmContext);
124
- if (definition.onCreated) {
125
- if (typeof definition.onCreated === "string") {
126
- sciChartSurface.onCreatedName = definition.onCreated;
127
- // @ts-ignore
128
- definition.onCreated = (0, classFactory_1.getFunction)(BaseType_1.EBaseType.OnCreateFunction, definition.onCreated);
129
- }
130
- // @ts-ignore
131
- definition.onCreated(sciChartSurface);
127
+ if (!definition.onCreated) return [3 /*break*/, 6];
128
+ if (typeof definition.onCreated === "string") {
129
+ sciChartSurface.onCreatedName = definition.onCreated;
130
+ definition.onCreated = (0, classFactory_1.getFunction)(BaseType_1.EBaseType.OnCreateFunction, definition.onCreated);
132
131
  }
132
+ return [4 /*yield*/, definition.onCreated(sciChartSurface)];
133
+ case 5:
134
+ _b.sent();
135
+ _b.label = 6;
136
+ case 6:
137
+ // TODO consider if this makes sense:
138
+ // if suspended, allows to execute onCreated before doing actual rendering
139
+ // if (definition.surface?.createSuspended ?? SciChartDefaults.createSuspended) {
140
+ // sciChartSurface.resume();
141
+ // }
142
+ perfomance_1.PerformanceDebugHelper.mark(perfomance_1.EPerformanceMarkType.SetupEnd, {
143
+ contextId: sciChartSurface.id,
144
+ relatedId: (_a = mark === null || mark === void 0 ? void 0 : mark.detail) === null || _a === void 0 ? void 0 : _a.relatedId
145
+ });
133
146
  return [2 /*return*/, { wasmContext: wasmContext, sciChartSurface: sciChartSurface }];
134
147
  }
135
148
  });
@@ -253,6 +253,9 @@ var CursorModifier = /** @class */ (function (_super) {
253
253
  * @inheritDoc
254
254
  */
255
255
  CursorModifier.prototype.modifierMouseMove = function (args) {
256
+ // If this is on a subchart, only respond to events from the active subchart
257
+ if (this.parentSurface.isSubSurface && !args.isActiveSubChartEvent)
258
+ return;
256
259
  this.activePointerEvents.set(args.pointerId, args);
257
260
  _super.prototype.modifierMouseMove.call(this, args);
258
261
  var translatedMousePoint;
@@ -275,6 +275,9 @@ var RolloverModifier = /** @class */ (function (_super) {
275
275
  * @inheritDoc
276
276
  */
277
277
  RolloverModifier.prototype.modifierMouseMove = function (args) {
278
+ // If this is on a subchart, only respond to events from the active subchart
279
+ if (this.parentSurface.isSubSurface && !args.isActiveSubChartEvent)
280
+ return;
278
281
  this.activePointerEvents.set(args.pointerId, args);
279
282
  _super.prototype.modifierMouseMove.call(this, args);
280
283
  var translatedMousePoint;
@@ -19,6 +19,7 @@ exports.XyDataSeries = void 0;
19
19
  var Guard_1 = require("../../Core/Guard");
20
20
  var NumberArray_1 = require("../../types/NumberArray");
21
21
  var appendDoubleVectorFromJsArray_1 = require("../../utils/ccall/appendDoubleVectorFromJsArray");
22
+ var perfomance_1 = require("../../utils/perfomance");
22
23
  var BaseDataSeries_1 = require("./BaseDataSeries");
23
24
  var IDataSeries_1 = require("./IDataSeries");
24
25
  /**
@@ -103,7 +104,9 @@ var XyDataSeries = /** @class */ (function (_super) {
103
104
  * @param metadata The array of point metadata
104
105
  */
105
106
  XyDataSeries.prototype.appendRange = function (xValues, yValues, metadata) {
107
+ var _a;
106
108
  if (!this.getIsDeleted()) {
109
+ var startMark = perfomance_1.PerformanceDebugHelper.mark(perfomance_1.EPerformanceMarkType.DataUpdateStart, { contextId: this.id });
107
110
  Guard_1.Guard.isTrue((0, NumberArray_1.isNumberArray)(xValues) || (0, NumberArray_1.isTypedArray)(xValues), "xValues must be an array of numbers");
108
111
  Guard_1.Guard.isTrue((0, NumberArray_1.isNumberArray)(yValues) || (0, NumberArray_1.isTypedArray)(yValues), "yValues must be an array of numbers");
109
112
  Guard_1.Guard.arraysSameLength(xValues, "xValues", yValues, "yValues");
@@ -121,6 +124,10 @@ var XyDataSeries = /** @class */ (function (_super) {
121
124
  this.doubleVectorProvider.appendArray(this.webAssemblyContext, nativeX, xValues);
122
125
  this.doubleVectorProvider.appendArray(this.webAssemblyContext, nativeY, yValues);
123
126
  this.notifyDataChanged(IDataSeries_1.EDataChangeType.Append, null, xValues.length);
127
+ perfomance_1.PerformanceDebugHelper.mark(perfomance_1.EPerformanceMarkType.DataUpdateEnd, {
128
+ relatedId: (_a = startMark === null || startMark === void 0 ? void 0 : startMark.detail) === null || _a === void 0 ? void 0 : _a.relatedId,
129
+ contextId: this.id
130
+ });
124
131
  }
125
132
  };
126
133
  /**
@@ -16,6 +16,7 @@ export declare class SciChartRenderer {
16
16
  */
17
17
  static resampleSeries(xAxis: AxisBase2D, rs: IRenderableSeries, seriesViewRect: Rect): TSeriesRenderPassInfo;
18
18
  private static calculateResamplingHash;
19
+ isInvalidated: boolean;
19
20
  private sciChartSurface;
20
21
  private previousTime;
21
22
  private prevRect;
@@ -30,6 +30,8 @@ var WatermarkPosition_1 = require("../../types/WatermarkPosition");
30
30
  var NativeObject_1 = require("../Visuals/Helpers/NativeObject");
31
31
  var createNativeRect_1 = require("../Visuals/Helpers/createNativeRect");
32
32
  var parseColor_1 = require("../../utils/parseColor");
33
+ var logger_1 = require("../../utils/logger");
34
+ var perfomance_1 = require("../../utils/perfomance");
33
35
  /**
34
36
  * A class used internally in SciChart to perform layout, arrangement, data-preparation and rendering on the Cartesian 2D {@link SciChartSurface}
35
37
  */
@@ -39,6 +41,7 @@ var SciChartRenderer = /** @class */ (function () {
39
41
  * @param sciChartSurface The {@link SciChartSurface} that we are rendering
40
42
  */
41
43
  function SciChartRenderer(sciChartSurface) {
44
+ this.isInvalidated = false;
42
45
  this.sciChartSurface = sciChartSurface;
43
46
  }
44
47
  /**
@@ -107,10 +110,15 @@ var SciChartRenderer = /** @class */ (function () {
107
110
  */
108
111
  SciChartRenderer.prototype.render = function (renderContext) {
109
112
  var _this = this;
113
+ var _a;
110
114
  if (this.sciChartSurface.isDeleted) {
111
115
  return;
112
116
  }
113
- //console.log("render start");
117
+ var mark = perfomance_1.PerformanceDebugHelper.mark(perfomance_1.EPerformanceMarkType.RenderStart, {
118
+ contextId: this.sciChartSurface.id
119
+ });
120
+ logger_1.Logger.debug("render start");
121
+ this.isInvalidated = false;
114
122
  var nativeContext = renderContext.getNativeContext();
115
123
  var wasmContext = this.sciChartSurface.webAssemblyContext2D;
116
124
  var oldBlendMode;
@@ -140,7 +148,7 @@ var SciChartRenderer = /** @class */ (function () {
140
148
  this.layoutTitle(seriesViewRect);
141
149
  this.scheduleTitleDraw(renderContext);
142
150
  // Step 4 prepare render data
143
- var _a = this.prepareAxesRenderData(), xAxesById = _a.xAxesById, yAxesById = _a.yAxesById;
151
+ var _b = this.prepareAxesRenderData(), xAxesById = _b.xAxesById, yAxesById = _b.yAxesById;
144
152
  var renderPassInfo = this.prepareSeriesRenderData(seriesViewRect, xAxesById);
145
153
  // Draw seriesViewRect border
146
154
  renderContext.enqueueLayeredDraw(function () {
@@ -198,6 +206,10 @@ var SciChartRenderer = /** @class */ (function () {
198
206
  else if (renderContext.doDraw) {
199
207
  this.updateWatermark(renderContext, this.sciChartSurface.parentSurface.seriesViewRect);
200
208
  }
209
+ perfomance_1.PerformanceDebugHelper.mark(perfomance_1.EPerformanceMarkType.RenderEnd, {
210
+ contextId: this.sciChartSurface.id,
211
+ relatedId: (_a = mark === null || mark === void 0 ? void 0 : mark.detail) === null || _a === void 0 ? void 0 : _a.relatedId
212
+ });
201
213
  // Step 10 Call OnParentSurfaceRendered
202
214
  this.onParentSurfaceRendered();
203
215
  if (!app_1.IS_TEST_ENV) {
@@ -207,6 +219,7 @@ var SciChartRenderer = /** @class */ (function () {
207
219
  if (this.sciChartSurface.isRunningAnimation) {
208
220
  setTimeout(this.sciChartSurface.invalidateElement, 0);
209
221
  }
222
+ logger_1.Logger.debug("render end");
210
223
  };
211
224
  SciChartRenderer.prototype.drawRenderContextAnnotations = function (annotations, xAxisById, yAxisById, annotationLayer, renderContext, seriesViewRect) {
212
225
  annotations
@@ -445,7 +458,10 @@ var SciChartRenderer = /** @class */ (function () {
445
458
  cm.onParentSurfaceRendered();
446
459
  });
447
460
  });
448
- this.sciChartSurface.rendered.raiseEvent();
461
+ // TODO add another event handler for multichart
462
+ if (!this.sciChartSurface.isCopyCanvasSurface || this.sciChartSurface.isSubSurface) {
463
+ this.sciChartSurface.rendered.raiseEvent(this.isInvalidated);
464
+ }
449
465
  };
450
466
  SciChartRenderer.prototype.updateWatermark = function (renderContext, seriesViewRect) {
451
467
  var chartHeight = this.sciChartSurface.isCopyCanvasSurface
@@ -39,6 +39,11 @@ export interface I2DSurfaceOptions extends ISurfaceOptionsBase {
39
39
  * The title text style and placement for the SciChartSurface as {@link TChartTitleStyle}
40
40
  */
41
41
  titleStyle?: TChartTitleStyle;
42
+ /**
43
+ * @experimental
44
+ * Optional - enabling prevents chart rendering until {@link SciChartSurface.resume} is called on the surface instance
45
+ */
46
+ createSuspended?: boolean;
42
47
  }
43
48
  export interface I2DSubSurfaceOptions extends I2DSurfaceOptions {
44
49
  /**
@@ -124,8 +124,9 @@ var BaseSeriesDrawingProvider = /** @class */ (function (_super) {
124
124
  }
125
125
  this.palettingState.palettedColors.clear();
126
126
  this.palettingState.palettedColors.reserve(count);
127
+ var hasPSIndexes = pointSeries && pointSeries.indexes.size() > 0;
127
128
  for (var index = startIndex; index < startIndex + count; index++) {
128
- var originalDataIndex = pointSeries ? pointSeries.indexes.get(index) : index;
129
+ var originalDataIndex = hasPSIndexes ? pointSeries.indexes.get(index) : index;
129
130
  if (originalDataIndex < 0)
130
131
  originalDataIndex = 0;
131
132
  else if (originalDataIndex >= dataSeries.count())
@@ -222,8 +223,9 @@ var BaseSeriesDrawingProvider = /** @class */ (function (_super) {
222
223
  }
223
224
  // Override stroke and fill colors
224
225
  var hashCode = 0;
226
+ var hasPSIndexes = pointSeries && pointSeries.indexes.size() > 0;
225
227
  for (var index = startIndex; index < startIndex + count; index++) {
226
- var originalDataIndex = pointSeries ? pointSeries.indexes.get(index) : index;
228
+ var originalDataIndex = hasPSIndexes ? pointSeries.indexes.get(index) : index;
227
229
  if (originalDataIndex < 0)
228
230
  originalDataIndex = 0;
229
231
  else if (originalDataIndex >= dataSeries.count())
@@ -40,4 +40,9 @@ export declare class SciChartDefaults {
40
40
  * Do not set lower than 1024kb or higher than 32MB (1024 x 32). Values outside this range will be clamped
41
41
  */
42
42
  static wasmBufferSizesKb: number;
43
+ /**
44
+ * Defines if newly created charts should be rendered as soon as possible after initialization.
45
+ * Setting to `true` will require surfaces to be "resumed" in order to perform actual rendering.
46
+ */
47
+ static createSuspended: boolean;
43
48
  }
@@ -45,6 +45,11 @@ var SciChartDefaults = /** @class */ (function () {
45
45
  * Do not set lower than 1024kb or higher than 32MB (1024 x 32). Values outside this range will be clamped
46
46
  */
47
47
  SciChartDefaults.wasmBufferSizesKb = 1024 * 8;
48
+ /**
49
+ * Defines if newly created charts should be rendered as soon as possible after initialization.
50
+ * Setting to `true` will require surfaces to be "resumed" in order to perform actual rendering.
51
+ */
52
+ SciChartDefaults.createSuspended = false;
48
53
  return SciChartDefaults;
49
54
  }());
50
55
  exports.SciChartDefaults = SciChartDefaults;
@@ -82,7 +82,7 @@ export declare class SciChartPieSurface extends DeletableEntity implements ISciC
82
82
  * An event handler which notifies its subscribers when a render operation has finished. Use this
83
83
  * to time render performance, or to update elements of the chart or your UI on redraw.
84
84
  */
85
- rendered: EventHandler<void>;
85
+ rendered: EventHandler<boolean>;
86
86
  protected widthAspect: number;
87
87
  protected heightAspect: number;
88
88
  protected labelProviderProperty: PieLabelProvider;
@@ -55,6 +55,7 @@ var PieLabelProvider_1 = require("../Axis/LabelProvider/PieLabelProvider");
55
55
  var SciChartPieLegend_1 = require("../Legend/SciChartPieLegend");
56
56
  var sciChartInitCommon_1 = require("../sciChartInitCommon");
57
57
  var SciChartSurfaceBase_1 = require("../SciChartSurfaceBase");
58
+ var DpiHelper_1 = require("../TextureManager/DpiHelper");
58
59
  var constants_1 = require("./constants");
59
60
  var constants_2 = require("./PieSegment/constants");
60
61
  /** @ignore */
@@ -136,10 +137,12 @@ var SciChartPieSurface = /** @class */ (function (_super) {
136
137
  _this.domSvgContainer = canvases.domSvgContainer;
137
138
  _this.domSvgAdornerLayer = canvases.domSvgAdornerLayer;
138
139
  _this.domDivContainer = canvases.domDivContainer;
139
- var width = _this.domCanvas2D.width;
140
- var height = _this.domCanvas2D.height;
140
+ var width = _this.domCanvas2D.width / DpiHelper_1.DpiHelper.PIXEL_RATIO;
141
+ var height = _this.domCanvas2D.height / DpiHelper_1.DpiHelper.PIXEL_RATIO;
141
142
  _this.viewRect = new Rect_1.Rect(0, 0, width, height);
142
- _this.resizeSubscriptionToken = sciChartInitCommon_1.default.subscribeToResize(canvases.domChartRoot, canvases.aspect, _this);
143
+ _this.resizeSubscriptionToken = sciChartInitCommon_1.default.subscribeToResize(
144
+ // @ts-ignore
145
+ canvases.domCanvas2D, canvases.aspect, _this);
143
146
  _this.drawChart = _this.drawChart.bind(_this);
144
147
  _this.deleteInternals = _this.deleteInternals.bind(_this);
145
148
  _this.invalidateElement = _this.invalidateElement.bind(_this);
@@ -16,6 +16,7 @@ import { IChartModifierBase } from "../ChartModifiers/ChartModifierBase";
16
16
  import { RenderSurface } from "../Drawing/RenderSurface";
17
17
  import { WebGlRenderContext2D } from "../Drawing/WebGlRenderContext2D";
18
18
  import { LayoutManager } from "../LayoutManager/LayoutManager";
19
+ import { SciChartRenderer } from "../Services/SciChartRenderer";
19
20
  import { IThemeProvider } from "../Themes/IThemeProvider";
20
21
  import { ECoordinateMode } from "./Annotations/AnnotationBase";
21
22
  import { AxisBase2D } from "./Axis/AxisBase2D";
@@ -199,13 +200,13 @@ export declare class SciChartSurface extends SciChartSurfaceBase {
199
200
  watermarkPosition: EWatermarkPosition;
200
201
  /** Set true to position the watermark relative to the overall canvas, rather than the series area. */
201
202
  watermarkRelativeToCanvas: boolean;
203
+ sciChartRenderer: SciChartRenderer;
202
204
  protected animationList: IGenericAnimation[];
203
205
  protected titleProperty: string | string[];
204
206
  protected titleStyleProperty: Readonly<Required<TChartTitleStyle>>;
205
207
  protected chartTitleRendererProperty: IChartTitleRenderer;
206
208
  protected paddingProperty: Thickness;
207
209
  protected currentWebGlRenderContextProperty: WebGlRenderContext2D;
208
- private sciChartRenderer;
209
210
  private layoutManagerProperty;
210
211
  private dataLabelLayoutManagerProperty;
211
212
  private zoomStateProperty;
@@ -326,6 +327,7 @@ export declare class SciChartSurface extends SciChartSurfaceBase {
326
327
  * Gets or sets the {@link EAutoColorMode} which determines when resolution of AUTO_COLOR should occur
327
328
  */
328
329
  set autoColorMode(autoColorMode: EAutoColorMode);
330
+ get isInvalidated(): boolean;
329
331
  /**
330
332
  * @inheritDoc
331
333
  */
@@ -337,7 +339,9 @@ export declare class SciChartSurface extends SciChartSurfaceBase {
337
339
  /**
338
340
  * @inheritDoc
339
341
  */
340
- invalidateElement(): void;
342
+ invalidateElement(options?: {
343
+ force?: boolean;
344
+ }): void;
341
345
  doDrawingLoop(context?: WebGlRenderContext2D): void;
342
346
  /**
343
347
  * @inheritDoc
@@ -499,6 +503,14 @@ export declare class SciChartSurface extends SciChartSurfaceBase {
499
503
  * @param excludeData if set true, data values will not be included in the json.
500
504
  */
501
505
  toJSON(excludeData?: boolean): ISciChart2DDefinition;
506
+ /**
507
+ * Triggers the rerendering of the surface and after the chart rerendering is completed,
508
+ * returns its serialized state retrieved with {@link SciChartSurface.toJSON}.
509
+ *
510
+ * @param excludeData - if set true, data values will not be included in the json.
511
+ * @returns JSON-like object {@link ISciChart2DDefinition}
512
+ */
513
+ getNextState(excludeData?: boolean): Promise<ISciChart2DDefinition>;
502
514
  protected applyOptions(options: I2DSurfaceOptions): void;
503
515
  /**
504
516
  * @inheritDoc
@@ -114,6 +114,8 @@ var TextPosition_1 = require("../../types/TextPosition");
114
114
  var Globals_1 = require("../../Core/Globals");
115
115
  var createMaster3d_1 = require("../../Charting3D/Visuals/createMaster3d");
116
116
  var LayoutMangerType_1 = require("../../types/LayoutMangerType");
117
+ var logger_1 = require("../../utils/logger");
118
+ var perfomance_1 = require("../../utils/perfomance");
117
119
  exports.sciChartConfig = {};
118
120
  /**
119
121
  * @summary The {@link SciChartSurface} is the root 2D Chart control in SciChart's High Performance Real-time
@@ -283,6 +285,7 @@ var SciChartSurface = /** @class */ (function (_super) {
283
285
  * @param options Optional - Optional parameters for chart creation. See {@link I2DSurfaceOptions} for more details
284
286
  */
285
287
  SciChartSurface.create = function (divElement, options) {
288
+ var mark = perfomance_1.PerformanceDebugHelper.mark(perfomance_1.EPerformanceMarkType.InitializationStart, { contextId: options === null || options === void 0 ? void 0 : options.id });
286
289
  (0, chartBuilder_1.ensureRegistrations)();
287
290
  options = SciChartSurface.resolveOptions(options);
288
291
  if (app_1.IS_TEST_ENV) {
@@ -290,7 +293,12 @@ var SciChartSurface = /** @class */ (function (_super) {
290
293
  }
291
294
  else {
292
295
  return (0, createMaster_1.createMultichart)(divElement, options).then(function (result) {
296
+ var _a;
293
297
  result.sciChartSurface.applyOptions(options);
298
+ perfomance_1.PerformanceDebugHelper.mark(perfomance_1.EPerformanceMarkType.InitializationEnd, {
299
+ contextId: result.sciChartSurface.id,
300
+ relatedId: (_a = mark === null || mark === void 0 ? void 0 : mark.detail) === null || _a === void 0 ? void 0 : _a.relatedId
301
+ });
294
302
  return result;
295
303
  });
296
304
  }
@@ -310,6 +318,7 @@ var SciChartSurface = /** @class */ (function (_super) {
310
318
  * @param options - optional parameters for chart creation. See {@link I2DSurfaceOptions} for more details
311
319
  */
312
320
  SciChartSurface.createSingle = function (divElement, options) {
321
+ var mark = perfomance_1.PerformanceDebugHelper.mark(perfomance_1.EPerformanceMarkType.InitializationStart, { contextId: options === null || options === void 0 ? void 0 : options.id });
313
322
  (0, chartBuilder_1.ensureRegistrations)();
314
323
  options = SciChartSurface.resolveOptions(options);
315
324
  if (app_1.IS_TEST_ENV) {
@@ -317,7 +326,12 @@ var SciChartSurface = /** @class */ (function (_super) {
317
326
  }
318
327
  else {
319
328
  return (0, createSingle_1.createSingleInternal)(divElement, options).then(function (result) {
329
+ var _a;
320
330
  result.sciChartSurface.applyOptions(options);
331
+ perfomance_1.PerformanceDebugHelper.mark(perfomance_1.EPerformanceMarkType.InitializationEnd, {
332
+ contextId: result.sciChartSurface.id,
333
+ relatedId: (_a = mark === null || mark === void 0 ? void 0 : mark.detail) === null || _a === void 0 ? void 0 : _a.relatedId
334
+ });
321
335
  return result;
322
336
  });
323
337
  }
@@ -434,6 +448,7 @@ var SciChartSurface = /** @class */ (function (_super) {
434
448
  subSurface.mouseManager.unsubscribe();
435
449
  this.subChartsProperty.push(subSurface);
436
450
  this.onAttachSubSurface(subSurface);
451
+ subSurface.setIsInitialized();
437
452
  return subSurface;
438
453
  };
439
454
  /**
@@ -635,6 +650,14 @@ var SciChartSurface = /** @class */ (function (_super) {
635
650
  enumerable: false,
636
651
  configurable: true
637
652
  });
653
+ Object.defineProperty(SciChartSurface.prototype, "isInvalidated", {
654
+ get: function () {
655
+ var _a;
656
+ return (_a = this.sciChartRenderer) === null || _a === void 0 ? void 0 : _a.isInvalidated;
657
+ },
658
+ enumerable: false,
659
+ configurable: true
660
+ });
638
661
  /**
639
662
  * @inheritDoc
640
663
  */
@@ -653,6 +676,7 @@ var SciChartSurface = /** @class */ (function (_super) {
653
676
  * @inheritDoc
654
677
  */
655
678
  SciChartSurface.prototype.changeViewportSize = function (pixelWidth, pixelHeight) {
679
+ logger_1.Logger.debug("changeViewportSize");
656
680
  if (!pixelWidth || !pixelHeight || this.isDeleted) {
657
681
  return;
658
682
  }
@@ -679,18 +703,22 @@ var SciChartSurface = /** @class */ (function (_super) {
679
703
  chart.updateSubLayout();
680
704
  }
681
705
  // Bypass the isSuspended check, otherwise the chart will go blank if it is resized while suspended
682
- var canvasId = this.domCanvas2D ? this.domCanvas2D.id : "undefinedCanvasId";
683
- this.renderSurface.invalidateElement(canvasId);
706
+ this.invalidateElement({ force: true });
684
707
  };
685
708
  /**
686
709
  * @inheritDoc
687
710
  */
688
- SciChartSurface.prototype.invalidateElement = function () {
711
+ SciChartSurface.prototype.invalidateElement = function (options) {
712
+ var _a, _b;
713
+ logger_1.Logger.debug("Invalidating ".concat((_b = (_a = this.domChartRoot) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : this.id, ": force=").concat(options === null || options === void 0 ? void 0 : options.force, " isSuspended=").concat(this.isSuspended, " isInitialized=").concat(this.isInitialized, "."));
689
714
  // When isSuspended (see suspendUpdates() function) ignore drawing
690
- if (this.isSuspended || this.isDeleted) {
691
- // Logger.log("SciChartSurface.isSuspended = true. Ignoring invalidateElement() call");
715
+ if (!(options === null || options === void 0 ? void 0 : options.force) && (this.isSuspended || this.isDeleted || !this.isInitialized)) {
692
716
  return;
693
717
  }
718
+ perfomance_1.PerformanceDebugHelper.mark(this.sciChartRenderer.isInvalidated
719
+ ? perfomance_1.EPerformanceMarkType.Invalidate
720
+ : perfomance_1.EPerformanceMarkType.LeadingInvalidate, { contextId: this.id });
721
+ this.sciChartRenderer.isInvalidated = true;
694
722
  // console.trace("Invalidating ", this.domChartRoot.id);
695
723
  var canvasId = this.domCanvas2D ? this.domCanvas2D.id : "undefinedCanvasId";
696
724
  this.renderSurface.invalidateElement(canvasId);
@@ -722,6 +750,7 @@ var SciChartSurface = /** @class */ (function (_super) {
722
750
  }
723
751
  finally {
724
752
  sus.resume();
753
+ sus.delete();
725
754
  }
726
755
  this.sciChartRenderer.render(context);
727
756
  }
@@ -786,6 +815,8 @@ var SciChartSurface = /** @class */ (function (_super) {
786
815
  */
787
816
  SciChartSurface.prototype.onDpiChanged = function (args) {
788
817
  var _a, _b;
818
+ perfomance_1.PerformanceDebugHelper.mark(perfomance_1.EPerformanceMarkType.DpiChange, { contextId: this.id });
819
+ logger_1.Logger.debug("onDpiChanged");
789
820
  this.renderableSeries.asArray().forEach(function (rs) { return rs.onDpiChanged(args); });
790
821
  this.xAxes.asArray().forEach(function (a) { return a.onDpiChanged(); });
791
822
  this.yAxes.asArray().forEach(function (a) { return a.onDpiChanged(); });
@@ -1212,6 +1243,7 @@ var SciChartSurface = /** @class */ (function (_super) {
1212
1243
  loader: this.loaderJson,
1213
1244
  drawSeriesBehindAxis: this.drawSeriesBehindAxis,
1214
1245
  disableAspect: this.disableAspect,
1246
+ createSuspended: this.createSuspended,
1215
1247
  autoColorMode: this.autoColorMode,
1216
1248
  touchAction: this.touchActionProperty
1217
1249
  };
@@ -1228,6 +1260,26 @@ var SciChartSurface = /** @class */ (function (_super) {
1228
1260
  };
1229
1261
  return definition;
1230
1262
  };
1263
+ /**
1264
+ * Triggers the rerendering of the surface and after the chart rerendering is completed,
1265
+ * returns its serialized state retrieved with {@link SciChartSurface.toJSON}.
1266
+ *
1267
+ * @param excludeData - if set true, data values will not be included in the json.
1268
+ * @returns JSON-like object {@link ISciChart2DDefinition}
1269
+ */
1270
+ SciChartSurface.prototype.getNextState = function (excludeData) {
1271
+ if (excludeData === void 0) { excludeData = false; }
1272
+ return __awaiter(this, void 0, void 0, function () {
1273
+ return __generator(this, function (_a) {
1274
+ switch (_a.label) {
1275
+ case 0: return [4 /*yield*/, this.nextStateRender({ resumeBefore: true, invalidateOnResume: true, suspendAfter: true })];
1276
+ case 1:
1277
+ _a.sent();
1278
+ return [2 /*return*/, this.toJSON(excludeData)];
1279
+ }
1280
+ });
1281
+ });
1282
+ };
1231
1283
  SciChartSurface.prototype.applyOptions = function (options) {
1232
1284
  _super.prototype.applyOptions.call(this, options);
1233
1285
  if (options === null || options === void 0 ? void 0 : options.layoutManager) {
@@ -18,7 +18,7 @@ import { IAnnotation } from "./Annotations/IAnnotation";
18
18
  import { AxisCore } from "./Axis/AxisCore";
19
19
  import { ISciChartLoader } from "./loader";
20
20
  import { INotifyOnDpiChanged, TDpiChangedEventArgs } from "./TextureManager/DpiHelper";
21
- import { ISuspendable, IUpdateSuspender } from "./UpdateSuspender";
21
+ import { ISuspendable, IUpdateSuspender, UpdateSuspender } from "./UpdateSuspender";
22
22
  export declare type TSciChartDestination = {
23
23
  canvasElementId: string;
24
24
  width: number;
@@ -110,7 +110,7 @@ export interface ISciChartSurfaceBase extends IDeletable, IThemeable {
110
110
  * An event handler which notifies its subscribers when a render operation has finished. Use this
111
111
  * to time render performance, or to update elements of the chart or your UI on redraw.
112
112
  */
113
- rendered: EventHandler<void>;
113
+ rendered: EventHandler<boolean>;
114
114
  }
115
115
  /**
116
116
  * Enum constants to specify SciChartSurface type
@@ -257,11 +257,12 @@ export declare abstract class SciChartSurfaceBase extends DeletableEntity implem
257
257
  */
258
258
  readonly modifierAnnotations: ObservableArray<IAnnotation>;
259
259
  adornerLayer: AdornerLayer;
260
+ abstract isInvalidated: boolean;
260
261
  /**
261
262
  * An event handler which notifies its subscribers when a render operation has finished. Use this
262
263
  * to time render performance, or to update elements of the chart or your UI on redraw.
263
264
  */
264
- rendered: EventHandler<void>;
265
+ rendered: EventHandler<boolean>;
265
266
  protected destinations: TSciChartDestination[];
266
267
  protected themeProviderProperty: IThemeProvider;
267
268
  protected previousThemeProviderProperty: IThemeProvider;
@@ -274,6 +275,8 @@ export declare abstract class SciChartSurfaceBase extends DeletableEntity implem
274
275
  protected heightAspect: number;
275
276
  protected disableAspect: boolean;
276
277
  protected loaderJson: any;
278
+ protected suspender: UpdateSuspender;
279
+ protected createSuspended: boolean;
277
280
  private sharedWasmContext;
278
281
  private readonly suspendableIdProperty;
279
282
  private seriesViewRectProperty;
@@ -343,6 +346,7 @@ export declare abstract class SciChartSurfaceBase extends DeletableEntity implem
343
346
  * @inheritDoc
344
347
  */
345
348
  resumeUpdates(suspender: IUpdateSuspender): void;
349
+ resume(): void;
346
350
  /**
347
351
  * @inheritDoc
348
352
  */
@@ -408,7 +412,20 @@ export declare abstract class SciChartSurfaceBase extends DeletableEntity implem
408
412
  * @inheritDoc
409
413
  */
410
414
  onDpiChanged(args: TDpiChangedEventArgs): void;
415
+ /**
416
+ * Creates a promise which resolves when the chart is updated to the next fully rendered state
417
+ *
418
+ * @remarks
419
+ * If the surface is initialized with `createSingle` the promise resolves after the main `render` function is executed.
420
+ * Otherwise, if it is initialized with `create` - the promise resolves after image data is copied to the 2D canvas.
421
+ */
422
+ nextStateRender(options?: {
423
+ resumeBefore?: boolean;
424
+ suspendAfter?: boolean;
425
+ invalidateOnResume?: boolean;
426
+ }): Promise<unknown>;
411
427
  get chartModifierGroups(): string[];
428
+ protected enableRenderListener(): void;
412
429
  protected clearRootElement(clearHtml: boolean): void;
413
430
  protected applyOptions(options: ISurfaceOptionsBase): void;
414
431
  /**
@@ -451,7 +468,5 @@ export declare const createChartDestination: (canvas: HTMLCanvasElement) => {
451
468
  };
452
469
  /** @ignore */
453
470
  export declare const getMasterCanvas: () => HTMLCanvasElement;
454
- export declare type TGetDestinationFn = (destinationId: string) => TSciChartDestination;
455
- export declare const copyToCanvas: (sourceCanvas: HTMLCanvasElement, getDestinationById: TGetDestinationFn) => (destinationId: string) => void;
456
471
  /** @ignore */
457
472
  export declare const getLocateFile: (sciChartConfig: TSciChartConfig) => (path: string, prefix: string) => string;