@rm-graph/core 0.1.5 → 0.1.7

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,12 +448,34 @@ 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
+ }
454
+ if (!this.container.id) {
455
+ this.container.id = this.id;
456
+ }
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
+ }
477
+ return;
453
478
  }
454
- const { sciChart3DSurface, wasmContext } = await scichart.SciChart3DSurface.create(
455
- this.container.id
456
- );
457
479
  this.surface = sciChart3DSurface;
458
480
  this.wasmContext = wasmContext;
459
481
  sciChart3DSurface.xAxis = new scichart.NumericAxis3D(wasmContext, {
@@ -574,12 +596,20 @@ var Surface3DChart = class {
574
596
  */
575
597
  destroy() {
576
598
  if (this.isDestroyed) return;
577
- this.clearSurface();
599
+ this.isDestroyed = true;
600
+ try {
601
+ this.clearSurface();
602
+ } catch (e) {
603
+ }
578
604
  if (this.surface) {
579
- this.surface.delete();
605
+ try {
606
+ this.surface.delete();
607
+ } catch (e) {
608
+ }
580
609
  this.surface = null;
581
610
  }
582
- this.isDestroyed = true;
611
+ this.container = null;
612
+ this.wasmContext = null;
583
613
  }
584
614
  /**
585
615
  * Get current configuration
@@ -653,15 +683,37 @@ var Column3DChart = class {
653
683
  * Create the SciChart 3D surface
654
684
  */
655
685
  async createSurface() {
656
- if (!this.container) {
657
- throw new Error("Container not set");
686
+ if (this.isDestroyed || !this.container) {
687
+ return;
688
+ }
689
+ if (!this.container.id) {
690
+ this.container.id = this.id;
658
691
  }
659
- const { sciChart3DSurface, wasmContext } = await scichart.SciChart3DSurface.create(
660
- this.container.id,
661
- {
662
- 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) {
663
714
  }
664
- );
715
+ return;
716
+ }
665
717
  this.surface = sciChart3DSurface;
666
718
  this.wasmContext = wasmContext;
667
719
  const cameraPos = this.config.cameraPosition ?? { x: -250, y: 450, z: 280 };
@@ -833,11 +885,16 @@ var Column3DChart = class {
833
885
  */
834
886
  destroy() {
835
887
  if (this.isDestroyed) return;
888
+ this.isDestroyed = true;
836
889
  if (this.surface) {
837
- this.surface.delete();
890
+ try {
891
+ this.surface.delete();
892
+ } catch (e) {
893
+ }
838
894
  this.surface = null;
839
895
  }
840
- this.isDestroyed = true;
896
+ this.container = null;
897
+ this.wasmContext = null;
841
898
  }
842
899
  /**
843
900
  * Get current configuration
@@ -1050,15 +1107,34 @@ var PRPDChart = class {
1050
1107
  * Create the SciChart surface
1051
1108
  */
1052
1109
  async createSurface() {
1053
- if (!this.container || !this.chartHost) {
1054
- 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;
1055
1115
  }
1056
1116
  configureSciChartCDN();
1057
1117
  const theme = createPRPDTheme();
1058
- const { sciChartSurface, wasmContext } = await scichart.SciChartSurface.create(
1059
- this.chartHost,
1060
- { theme }
1061
- );
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
+ }
1062
1138
  this.surface = sciChartSurface;
1063
1139
  this.wasmContext = wasmContext;
1064
1140
  const verticalScaleMax = this.config.maxPeak || VERTICAL_SCALE_MAX_DEFAULT;