@operato/scene-scichart 7.3.8 → 7.3.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -49,13 +49,56 @@ import {
49
49
  } from 'scichart'
50
50
  import { AxisSynchroniser } from './axis-synchronizer'
51
51
 
52
- SciChartSurface.UseCommunityLicense()
53
-
54
52
  SciChartSurface.configure({
55
53
  dataUrl: `/node_modules/scichart/_wasm/scichart2d.data`,
56
54
  wasmUrl: `/node_modules/scichart/_wasm/scichart2d.wasm`
57
55
  })
58
56
 
57
+ var licenseInitialized: boolean = false
58
+
59
+ // 커뮤니티 라이선스 적용 함수
60
+ function useCommunityLicense() {
61
+ SciChartSurface.UseCommunityLicense()
62
+ }
63
+
64
+ // SciChart 라이선스 설정 함수
65
+ async function fetchSciChartLicense() {
66
+ try {
67
+ const response = await fetch('/frontend-config/scichart')
68
+ if (response.ok) {
69
+ const { licenseKey = '' } = (await response.json()) || {}
70
+
71
+ if (licenseKey) {
72
+ SciChartSurface.setRuntimeLicenseKey(licenseKey)
73
+ console.log('SciChart license key setting complete')
74
+ } else {
75
+ console.warn('License key not found. Using community version.')
76
+ useCommunityLicense()
77
+ }
78
+ } else {
79
+ console.warn('License server response not found. Using community version.')
80
+ useCommunityLicense()
81
+ }
82
+ } catch (error) {
83
+ console.error('Error fetching license. Using community version:', error)
84
+ useCommunityLicense()
85
+ }
86
+ }
87
+
88
+ // SciChart 초기화 함수
89
+ async function initializeSciChartLicense() {
90
+ if (!licenseInitialized) {
91
+ if (window.location.hostname === 'localhost') {
92
+ console.warn('Localhost detected. Using SciChart community license.')
93
+ useCommunityLicense() // localhost인 경우 커뮤니티 라이선스 적용
94
+ } else {
95
+ await fetchSciChartLicense() // 서버에서 라이선스 키 가져오기
96
+ }
97
+
98
+ licenseInitialized = true
99
+ }
100
+ }
101
+
59
102
  export const DEFAULT_COLOR = '#FF6600'
60
103
  const DEFAULT_STROKE = '#000000'
61
104
  const POINT_MARKER_SIZE = 10
@@ -265,6 +308,8 @@ export async function buildSciChart(
265
308
  ): Promise<{ chart: any; dataSeries: any[] } | undefined> {
266
309
  if (!config) return
267
310
 
311
+ await initializeSciChartLicense()
312
+
268
313
  const { type: chartType, options, data: fromData } = config
269
314
  const { datasets = [] } = fromData || {}
270
315
  var {