@rm-graph/core 0.1.6 → 0.1.8

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.
package/dist/index.js CHANGED
@@ -448,17 +448,32 @@ var Surface3DChart = class {
448
448
  * Create the SciChart 3D surface
449
449
  */
450
450
  async createSurface() {
451
- if (!this.container) {
452
- throw new Error("Container not set");
451
+ if (this.isDestroyed || !this.container) {
452
+ return;
453
453
  }
454
454
  if (!this.container.id) {
455
455
  this.container.id = this.id;
456
456
  }
457
- const { sciChart3DSurface, wasmContext } = await scichart.SciChart3DSurface.create(
458
- this.container.id
459
- );
460
- if (this.isDestroyed) {
461
- sciChart3DSurface.delete();
457
+ if (!document.body.contains(this.container)) {
458
+ return;
459
+ }
460
+ let sciChart3DSurface;
461
+ let wasmContext;
462
+ try {
463
+ const result = await scichart.SciChart3DSurface.create(
464
+ this.container.id
465
+ );
466
+ sciChart3DSurface = result.sciChart3DSurface;
467
+ wasmContext = result.wasmContext;
468
+ } catch (e) {
469
+ console.warn("Surface3DChart: Failed to create surface", e);
470
+ return;
471
+ }
472
+ if (this.isDestroyed || !this.container) {
473
+ try {
474
+ sciChart3DSurface.delete();
475
+ } catch (e) {
476
+ }
462
477
  return;
463
478
  }
464
479
  this.surface = sciChart3DSurface;
@@ -668,20 +683,35 @@ var Column3DChart = class {
668
683
  * Create the SciChart 3D surface
669
684
  */
670
685
  async createSurface() {
671
- if (!this.container) {
672
- throw new Error("Container not set");
686
+ if (this.isDestroyed || !this.container) {
687
+ return;
673
688
  }
674
689
  if (!this.container.id) {
675
690
  this.container.id = this.id;
676
691
  }
677
- const { sciChart3DSurface, wasmContext } = await scichart.SciChart3DSurface.create(
678
- this.container.id,
679
- {
680
- isZYPlaneVisible: false
692
+ if (!document.body.contains(this.container)) {
693
+ return;
694
+ }
695
+ let sciChart3DSurface;
696
+ let wasmContext;
697
+ try {
698
+ const result = await scichart.SciChart3DSurface.create(
699
+ this.container.id,
700
+ {
701
+ isZYPlaneVisible: false
702
+ }
703
+ );
704
+ sciChart3DSurface = result.sciChart3DSurface;
705
+ wasmContext = result.wasmContext;
706
+ } catch (e) {
707
+ console.warn("Column3DChart: Failed to create surface", e);
708
+ return;
709
+ }
710
+ if (this.isDestroyed || !this.container) {
711
+ try {
712
+ sciChart3DSurface.delete();
713
+ } catch (e) {
681
714
  }
682
- );
683
- if (this.isDestroyed) {
684
- sciChart3DSurface.delete();
685
715
  return;
686
716
  }
687
717
  this.surface = sciChart3DSurface;
@@ -1077,15 +1107,34 @@ var PRPDChart = class {
1077
1107
  * Create the SciChart surface
1078
1108
  */
1079
1109
  async createSurface() {
1080
- if (!this.container || !this.chartHost) {
1081
- throw new Error("Container not set");
1110
+ if (this.isDestroyed || !this.container || !this.chartHost) {
1111
+ return;
1112
+ }
1113
+ if (!document.body.contains(this.container)) {
1114
+ return;
1082
1115
  }
1083
1116
  configureSciChartCDN();
1084
1117
  const theme = createPRPDTheme();
1085
- const { sciChartSurface, wasmContext } = await scichart.SciChartSurface.create(
1086
- this.chartHost,
1087
- { theme }
1088
- );
1118
+ let sciChartSurface;
1119
+ let wasmContext;
1120
+ try {
1121
+ const result = await scichart.SciChartSurface.create(
1122
+ this.chartHost,
1123
+ { theme }
1124
+ );
1125
+ sciChartSurface = result.sciChartSurface;
1126
+ wasmContext = result.wasmContext;
1127
+ } catch (e) {
1128
+ console.warn("PRPDChart: Failed to create surface", e);
1129
+ return;
1130
+ }
1131
+ if (this.isDestroyed || !this.container) {
1132
+ try {
1133
+ sciChartSurface.delete();
1134
+ } catch (e) {
1135
+ }
1136
+ return;
1137
+ }
1089
1138
  this.surface = sciChartSurface;
1090
1139
  this.wasmContext = wasmContext;
1091
1140
  const verticalScaleMax = this.config.maxPeak || VERTICAL_SCALE_MAX_DEFAULT;
@@ -1138,24 +1187,34 @@ var PRPDChart = class {
1138
1187
  visibleRange: yRange,
1139
1188
  visibleRangeLimit: yRange
1140
1189
  });
1190
+ if (this.isDestroyed) return;
1141
1191
  sciChartSurface.xAxes.add(this.xAxis);
1142
1192
  sciChartSurface.yAxes.add(this.yAxis);
1193
+ if (this.isDestroyed) return;
1143
1194
  this.createHeatmap(zValues, multiplier, verticalResolution, isUnipolar);
1144
- if (this.config.showSineWave) {
1195
+ if (this.config.showSineWave && !this.isDestroyed) {
1145
1196
  this.createSineWave(yAxisRange, isUnipolar);
1146
1197
  }
1147
- const cursorModifier = new scichart.CursorModifier();
1148
- cursorModifier.axisLabelFill = "#FFFFFF";
1149
- cursorModifier.axisLabelStroke = "#000000";
1150
- sciChartSurface.chartModifiers.add(
1151
- cursorModifier,
1152
- new scichart.RubberBandXyZoomModifier(),
1153
- new scichart.ZoomExtentsModifier()
1154
- );
1198
+ if (this.isDestroyed) return;
1199
+ try {
1200
+ const cursorModifier = new scichart.CursorModifier();
1201
+ cursorModifier.axisLabelFill = "#FFFFFF";
1202
+ cursorModifier.axisLabelStroke = "#000000";
1203
+ sciChartSurface.chartModifiers.add(
1204
+ cursorModifier,
1205
+ new scichart.RubberBandXyZoomModifier(),
1206
+ new scichart.ZoomExtentsModifier()
1207
+ );
1208
+ } catch (e) {
1209
+ console.warn("PRPDChart: Failed to add modifiers", e);
1210
+ }
1211
+ if (this.isDestroyed) return;
1155
1212
  if (this.config.showColorPalette) {
1156
1213
  await this.createHeatmapLegend();
1157
1214
  }
1158
- this.onStatsChange?.(this.stats);
1215
+ if (!this.isDestroyed) {
1216
+ this.onStatsChange?.(this.stats);
1217
+ }
1159
1218
  }
1160
1219
  createHeatmap(zValues, multiplier, verticalResolution, isUnipolar) {
1161
1220
  if (!this.surface || !this.wasmContext) return;