@operato/scene-scichart 7.2.5 → 7.2.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/CHANGELOG.md +20 -0
- package/db.sqlite +0 -0
- package/dist/charts/ox-scichart-multiple copy.d.ts +53 -0
- package/dist/charts/ox-scichart-multiple copy.js +411 -0
- package/dist/charts/ox-scichart-multiple copy.js.map +1 -0
- package/dist/charts/ox-scichart-multiple.d.ts +9 -8
- package/dist/charts/ox-scichart-multiple.js +238 -98
- package/dist/charts/ox-scichart-multiple.js.map +1 -1
- package/dist/charts/scichart-builder copy.d.ts +22 -0
- package/dist/charts/scichart-builder copy.js +420 -0
- package/dist/charts/scichart-builder copy.js.map +1 -0
- package/dist/charts/scichart-builder.d.ts +2 -0
- package/dist/charts/scichart-builder.js +44 -30
- package/dist/charts/scichart-builder.js.map +1 -1
- package/dist/charts/scichart-overview-builder.d.ts +13 -0
- package/dist/charts/scichart-overview-builder.js +219 -0
- package/dist/charts/scichart-overview-builder.js.map +1 -0
- package/dist/templates/scichart-multiple-timeseries.d.ts +1 -1
- package/dist/templates/scichart-multiple-timeseries.js +1 -1
- package/dist/templates/scichart-multiple-timeseries.js.map +1 -1
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +35 -10
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +30 -0
- package/logs/{application-2024-08-02-17.log → application-2024-08-03-13.log} +8 -8
- package/logs/{application-2024-08-02-18.log → application-2024-08-03-14.log} +8 -8
- package/logs/application-2024-08-03-15.log +210 -0
- package/logs/application-2024-08-04-01.log +105 -0
- package/logs/application-2024-08-04-04.log +420 -0
- package/logs/application-2024-08-04-18.log +2 -0
- package/logs/application-2024-08-04-19.log +105 -0
- package/logs/connections-2024-08-03-13.log +50 -0
- package/logs/connections-2024-08-03-14.log +50 -0
- package/logs/connections-2024-08-03-15.log +100 -0
- package/logs/connections-2024-08-04-01.log +50 -0
- package/logs/connections-2024-08-04-04.log +200 -0
- package/logs/connections-2024-08-04-19.log +50 -0
- package/package.json +2 -2
- package/src/charts/ox-scichart-multiple.ts +295 -114
- package/src/charts/scichart-builder.ts +47 -30
- package/src/templates/scichart-multiple-timeseries.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -2,9 +2,23 @@ import { LitElement, html, css } from 'lit'
|
|
|
2
2
|
import { property, query, customElement } from 'lit/decorators.js'
|
|
3
3
|
import { keyed } from 'lit/directives/keyed.js'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
calculatePrecision,
|
|
7
|
+
buildSciChart,
|
|
8
|
+
buildSciChartOverview,
|
|
9
|
+
convertColor,
|
|
10
|
+
DEFAULT_COLOR
|
|
11
|
+
} from './scichart-builder'
|
|
6
12
|
import { AxisSynchroniser } from './axis-synchronizer'
|
|
7
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
EAutoRange,
|
|
15
|
+
FastLineRenderableSeries,
|
|
16
|
+
NumberRange,
|
|
17
|
+
NumericAxis,
|
|
18
|
+
scaleAxes,
|
|
19
|
+
SciChartVerticalGroup,
|
|
20
|
+
XyDataSeries
|
|
21
|
+
} from 'scichart'
|
|
8
22
|
|
|
9
23
|
import { ScrollbarStyles } from '@operato/styles'
|
|
10
24
|
|
|
@@ -18,7 +32,6 @@ export class OxSciChartMultiple extends LitElement {
|
|
|
18
32
|
private synchronizer: AxisSynchroniser = new AxisSynchroniser(new NumberRange(200, 500))
|
|
19
33
|
private verticalGroup: SciChartVerticalGroup = new SciChartVerticalGroup()
|
|
20
34
|
|
|
21
|
-
private isInitializing: boolean = false
|
|
22
35
|
private overviewChart: any = null
|
|
23
36
|
private overviewDataSeries: any[] = []
|
|
24
37
|
private groupCharts: {
|
|
@@ -27,6 +40,8 @@ export class OxSciChartMultiple extends LitElement {
|
|
|
27
40
|
dataSeries: any[]
|
|
28
41
|
}[] = []
|
|
29
42
|
|
|
43
|
+
private initializationQueue: Promise<void> = Promise.resolve()
|
|
44
|
+
|
|
30
45
|
/*
|
|
31
46
|
[주의]
|
|
32
47
|
ox-scichart container의 id를 글로벌 유니크하게 해야한다.
|
|
@@ -77,9 +92,20 @@ export class OxSciChartMultiple extends LitElement {
|
|
|
77
92
|
|
|
78
93
|
async initializeSciChart() {
|
|
79
94
|
this.cleanup()
|
|
95
|
+
await this.createOverviewChart()
|
|
96
|
+
}
|
|
80
97
|
|
|
98
|
+
async createOverviewChart() {
|
|
81
99
|
const { chart, dataSeries } =
|
|
82
|
-
(await buildSciChartOverview(
|
|
100
|
+
(await buildSciChartOverview(
|
|
101
|
+
{
|
|
102
|
+
...this.config,
|
|
103
|
+
data: { datasets: [] }
|
|
104
|
+
},
|
|
105
|
+
this.overviewContainer,
|
|
106
|
+
{},
|
|
107
|
+
this.synchronizer
|
|
108
|
+
)) || {}
|
|
83
109
|
|
|
84
110
|
this.verticalGroup.addSurfaceToGroup(chart.sciChartSurface)
|
|
85
111
|
|
|
@@ -88,45 +114,44 @@ export class OxSciChartMultiple extends LitElement {
|
|
|
88
114
|
}
|
|
89
115
|
|
|
90
116
|
async updated(changedProperties: Map<string | number | symbol, unknown>) {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
117
|
+
this.initializationQueue = this.initializationQueue
|
|
118
|
+
.then(async () => {
|
|
119
|
+
let needUpdateDataSeries = false
|
|
120
|
+
let needBuildChartGroup = false
|
|
121
|
+
|
|
122
|
+
if (changedProperties.has('config') && this.config) {
|
|
123
|
+
await this.initializeSciChart()
|
|
124
|
+
needBuildChartGroup = true
|
|
125
|
+
needUpdateDataSeries = true
|
|
126
|
+
}
|
|
99
127
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
128
|
+
if (changedProperties.has('visibleSeries')) {
|
|
129
|
+
await this.updateSeries(this.visibleSeries, changedProperties.get('visibleSeries') as string[])
|
|
130
|
+
/* [중요] buildChartGroup 을 visibleSeries 수정때마다 하는 이유는, render() 의 캐시 컨트롤이 안되기 때문이다. 가급적 시도하지 말라. */
|
|
131
|
+
needBuildChartGroup = true
|
|
132
|
+
needUpdateDataSeries = true
|
|
133
|
+
}
|
|
107
134
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
135
|
+
if (changedProperties.has('data')) {
|
|
136
|
+
needUpdateDataSeries = true
|
|
137
|
+
}
|
|
111
138
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
139
|
+
if (needBuildChartGroup) {
|
|
140
|
+
await this.buildChartGroup()
|
|
141
|
+
}
|
|
116
142
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
143
|
+
if (needUpdateDataSeries) {
|
|
144
|
+
await this.updateDataSeries()
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
.catch((error: any) => {
|
|
148
|
+
console.error('Error in updated queue:', error)
|
|
149
|
+
})
|
|
121
150
|
}
|
|
122
151
|
|
|
123
152
|
cleanup() {
|
|
124
153
|
this.cleanupGroup()
|
|
125
|
-
|
|
126
|
-
if (this.overviewChart) {
|
|
127
|
-
this.overviewChart.sciChartSurface?.delete()
|
|
128
|
-
this.overviewChart = null
|
|
129
|
-
}
|
|
154
|
+
this.cleanupOverview()
|
|
130
155
|
}
|
|
131
156
|
|
|
132
157
|
cleanupGroup() {
|
|
@@ -141,6 +166,16 @@ export class OxSciChartMultiple extends LitElement {
|
|
|
141
166
|
this.groupCharts.length = 0
|
|
142
167
|
}
|
|
143
168
|
|
|
169
|
+
cleanupOverview() {
|
|
170
|
+
if (this.overviewChart) {
|
|
171
|
+
this.overviewChart.sciChartSurface.renderableSeries.clear()
|
|
172
|
+
this.overviewDataSeries.forEach(ds => ds.delete())
|
|
173
|
+
this.overviewDataSeries.length = 0
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
this.overviewChart = null
|
|
177
|
+
}
|
|
178
|
+
|
|
144
179
|
async updateDataSeries() {
|
|
145
180
|
const { config, data } = this
|
|
146
181
|
const { datasets = [], labelDataKey: attrX } = config?.data || {}
|
|
@@ -151,47 +186,73 @@ export class OxSciChartMultiple extends LitElement {
|
|
|
151
186
|
|
|
152
187
|
const newData = this.dataSet
|
|
153
188
|
|
|
154
|
-
|
|
189
|
+
this.groupCharts.forEach(({ dataKey, sciChartSurface, dataSeries }) => {
|
|
155
190
|
try {
|
|
156
|
-
|
|
157
|
-
const
|
|
191
|
+
// dataKey로 시작하는 모든 시리즈를 업데이트
|
|
192
|
+
const relatedDatasets = datasets.filter(dataset => dataset.dataKey?.startsWith(dataKey))
|
|
158
193
|
|
|
159
|
-
|
|
160
|
-
|
|
194
|
+
// 각 relatedDatasets에 대해 해당하는 dataSeries를 업데이트
|
|
195
|
+
dataSeries.forEach((ds, index) => {
|
|
196
|
+
ds.clear()
|
|
161
197
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
198
|
+
const relatedDataset = relatedDatasets[index]
|
|
199
|
+
if (relatedDataset) {
|
|
200
|
+
const filteredData = newData[datasets.findIndex(ds => ds.dataKey === relatedDataset.dataKey)].filter(
|
|
201
|
+
d => typeof d.yValue === 'number'
|
|
166
202
|
)
|
|
203
|
+
|
|
204
|
+
if (filteredData.length > 0) {
|
|
205
|
+
ds.appendRange(
|
|
206
|
+
filteredData.map(d => d.xValue),
|
|
207
|
+
filteredData.map(d => d.yValue)
|
|
208
|
+
)
|
|
209
|
+
}
|
|
167
210
|
}
|
|
168
211
|
})
|
|
169
|
-
} catch (error) {
|
|
170
|
-
console.log(error)
|
|
171
|
-
}
|
|
172
212
|
|
|
173
|
-
setTimeout(() => {
|
|
174
213
|
sciChartSurface.zoomExtents()
|
|
175
214
|
sciChartSurface.invalidateElement()
|
|
176
|
-
}
|
|
215
|
+
} catch (error) {
|
|
216
|
+
console.error('Error updating data series:', error)
|
|
217
|
+
}
|
|
177
218
|
})
|
|
178
219
|
|
|
179
220
|
try {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
221
|
+
// Overview 차트 데이터 업데이트
|
|
222
|
+
this.overviewDataSeries.forEach((ds, index) => {
|
|
223
|
+
const visibleKey = this.visibleSeries[index]
|
|
224
|
+
const dataset = datasets.find(dataset => dataset.dataKey === visibleKey)
|
|
225
|
+
if (!dataset) {
|
|
226
|
+
return
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const dataIndex = datasets.findIndex(ds => ds.dataKey === dataset.dataKey)
|
|
230
|
+
const filteredData = newData[dataIndex]?.filter(d => typeof d.yValue === 'number') || []
|
|
231
|
+
|
|
232
|
+
ds.clear()
|
|
233
|
+
if (filteredData.length > 0) {
|
|
234
|
+
ds.appendRange(
|
|
235
|
+
filteredData.map(d => d.xValue),
|
|
236
|
+
filteredData.map(d => d.yValue)
|
|
237
|
+
)
|
|
191
238
|
}
|
|
192
239
|
})
|
|
240
|
+
|
|
241
|
+
// this.overviewDataSeries.forEach(ds => ds.clear())
|
|
242
|
+
|
|
243
|
+
// newData.forEach((data, index) => {
|
|
244
|
+
// if (this.visibleSeries.includes(datasets[index].dataKey!)) {
|
|
245
|
+
// const filteredData = data.filter(d => typeof d.yValue === 'number')
|
|
246
|
+
// if (filteredData.length > 0) {
|
|
247
|
+
// this.overviewDataSeries[index].appendRange(
|
|
248
|
+
// filteredData.map(d => d.xValue),
|
|
249
|
+
// filteredData.map(d => d.yValue)
|
|
250
|
+
// )
|
|
251
|
+
// }
|
|
252
|
+
// }
|
|
253
|
+
// })
|
|
193
254
|
} catch (error) {
|
|
194
|
-
console.
|
|
255
|
+
console.error('Error updating overview data series:', error)
|
|
195
256
|
}
|
|
196
257
|
}
|
|
197
258
|
|
|
@@ -231,7 +292,7 @@ export class OxSciChartMultiple extends LitElement {
|
|
|
231
292
|
return html`
|
|
232
293
|
<div id=${this.containerId + '-overview'} class="overview" ?hidden=${!this.showOverview}></div>
|
|
233
294
|
<div id="chart-group">
|
|
234
|
-
${
|
|
295
|
+
${this.visibleSeries.map(dataKey =>
|
|
235
296
|
keyed(
|
|
236
297
|
dataKey,
|
|
237
298
|
html`
|
|
@@ -263,108 +324,228 @@ export class OxSciChartMultiple extends LitElement {
|
|
|
263
324
|
}
|
|
264
325
|
|
|
265
326
|
async updateSeries(after: string[], before: string[]) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
327
|
+
const addSeries = after?.filter(series => !before.includes(series)) || []
|
|
328
|
+
const removeSeries = before?.filter(series => !after.includes(series)) || []
|
|
329
|
+
|
|
330
|
+
for (const series of removeSeries) {
|
|
331
|
+
await this.removeChart(series)
|
|
272
332
|
}
|
|
273
333
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (!before || !before.includes(series)) {
|
|
277
|
-
await this.addChart(series)
|
|
278
|
-
}
|
|
334
|
+
for (const series of addSeries) {
|
|
335
|
+
await this.addChart(series)
|
|
279
336
|
}
|
|
280
337
|
}
|
|
281
338
|
|
|
282
339
|
async addChart(dataKey: string) {
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
dataSeries
|
|
340
|
+
const chartData = await this.createChart(dataKey)
|
|
341
|
+
|
|
342
|
+
if (chartData) {
|
|
343
|
+
const { chart, dataSeries, dataKey } = chartData
|
|
344
|
+
this.verticalGroup.addSurfaceToGroup(chart.sciChartSurface)
|
|
345
|
+
|
|
346
|
+
this.groupCharts = this.groupSorter([
|
|
347
|
+
...this.groupCharts,
|
|
348
|
+
{ dataKey, sciChartSurface: chart.sciChartSurface, dataSeries }
|
|
349
|
+
])
|
|
350
|
+
|
|
351
|
+
await this.addSeriesToOverviewChart(dataKey)
|
|
287
352
|
}
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
async removeChart(dataKey: string) {
|
|
356
|
+
const index = this.groupCharts.findIndex(chart => chart.dataKey == dataKey)
|
|
357
|
+
if (index === -1) return
|
|
358
|
+
|
|
359
|
+
const [groupedChart] = this.groupCharts.splice(index, 1)
|
|
360
|
+
this.destroyChart(groupedChart)
|
|
361
|
+
|
|
362
|
+
this.groupCharts = this.groupSorter(this.groupCharts)
|
|
363
|
+
|
|
364
|
+
await this.removeSeriesFromOverviewChart(dataKey)
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
groupSorter(group: any[]) {
|
|
368
|
+
return group.sort(
|
|
369
|
+
(a, b) =>
|
|
370
|
+
this.visibleSeries.findIndex((s: any) => s.dataKey == a.dataKey) -
|
|
371
|
+
this.visibleSeries.findIndex((s: any) => s.dataKey == b.dataKey)
|
|
372
|
+
)
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
async appendData(appendum: { [attr: string]: any }[]) {}
|
|
288
376
|
|
|
377
|
+
private async createChart(dataKey: string) {
|
|
289
378
|
const { data = {}, options = {} } = this.config || {}
|
|
290
379
|
const { datasets = [] } = data as OperatoChart.ChartData
|
|
291
|
-
const
|
|
380
|
+
const primaryDataset = datasets.find(dataset => dataset.dataKey == dataKey)
|
|
292
381
|
|
|
293
|
-
if (!
|
|
294
|
-
return
|
|
382
|
+
if (!primaryDataset) {
|
|
383
|
+
return null
|
|
295
384
|
}
|
|
296
385
|
|
|
297
|
-
const
|
|
298
|
-
const { yAxes = [] } = scales || {}
|
|
299
|
-
const { valueFormat } = dataset
|
|
386
|
+
const relatedDatasets = datasets.filter(dataset => dataset.dataKey?.startsWith(dataKey))
|
|
300
387
|
|
|
301
388
|
const yAxis = {
|
|
302
|
-
...yAxes[0],
|
|
303
|
-
axisTitle:
|
|
389
|
+
...options.scales?.yAxes?.[0],
|
|
390
|
+
axisTitle: primaryDataset?.label
|
|
304
391
|
}
|
|
305
392
|
|
|
306
393
|
const config = {
|
|
307
394
|
...this.config,
|
|
308
395
|
data: {
|
|
309
|
-
datasets:
|
|
396
|
+
datasets: relatedDatasets
|
|
310
397
|
},
|
|
311
398
|
options: {
|
|
312
399
|
...options,
|
|
313
400
|
scales: {
|
|
314
|
-
...scales,
|
|
401
|
+
...options.scales,
|
|
315
402
|
yAxes: [yAxis]
|
|
316
403
|
}
|
|
317
404
|
}
|
|
318
405
|
}
|
|
319
406
|
|
|
320
407
|
const container = this.renderRoot.querySelector(`#${this.containerId + '-' + dataKey}`)
|
|
321
|
-
|
|
408
|
+
const { chart, dataSeries } = (await buildSciChart(
|
|
322
409
|
config,
|
|
323
410
|
container,
|
|
324
411
|
{ fontSize: 14, fontFamily: 'Roboto', fontColor: undefined },
|
|
325
|
-
{
|
|
412
|
+
{
|
|
413
|
+
precision: primaryDataset.valueFormat ? calculatePrecision(primaryDataset.valueFormat) : undefined,
|
|
414
|
+
grouped: this.containerId
|
|
415
|
+
}
|
|
326
416
|
))!
|
|
327
417
|
|
|
328
|
-
this.verticalGroup.addSurfaceToGroup(chart.sciChartSurface)
|
|
329
418
|
this.synchronizer.addAxis(chart.sciChartSurface.xAxes.get(0))
|
|
330
419
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
420
|
+
// 각 시리즈에 대해 올바른 데이터를 추가
|
|
421
|
+
const newData = this.dataSet
|
|
422
|
+
dataSeries.forEach((ds, seriesIndex) => {
|
|
423
|
+
const dataset = relatedDatasets[seriesIndex]
|
|
424
|
+
const filteredData = newData[seriesIndex]?.filter(d => typeof d.yValue === 'number') || []
|
|
425
|
+
if (filteredData.length > 0) {
|
|
426
|
+
ds.appendRange(
|
|
427
|
+
filteredData.map(d => d.xValue),
|
|
428
|
+
filteredData.map(d => d.yValue)
|
|
429
|
+
)
|
|
430
|
+
}
|
|
431
|
+
})
|
|
334
432
|
|
|
335
|
-
|
|
433
|
+
return { chart, dataSeries, dataKey }
|
|
336
434
|
}
|
|
337
435
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
436
|
+
private destroyChart(groupedChart: { dataKey: string; sciChartSurface: any; dataSeries: any[] }) {
|
|
437
|
+
this.verticalGroup.removeSurface(groupedChart.sciChartSurface)
|
|
438
|
+
this.synchronizer.removeAxis(groupedChart.sciChartSurface.xAxes.get(0))
|
|
439
|
+
groupedChart.sciChartSurface.delete()
|
|
440
|
+
}
|
|
341
441
|
|
|
342
|
-
|
|
442
|
+
private async addSeriesToOverviewChart(dataKey: string) {
|
|
443
|
+
if (!this.overviewChart || !this.overviewDataSeries) {
|
|
444
|
+
console.error('Overview chart is not initialized.')
|
|
343
445
|
return
|
|
344
446
|
}
|
|
345
447
|
|
|
346
|
-
|
|
347
|
-
this.
|
|
448
|
+
// Check if the series already exists in the overview chart
|
|
449
|
+
const existingSeries = this.overviewChart.sciChartSurface.renderableSeries.asArray().find((series: any) => {
|
|
450
|
+
return series.dataSeries.dataSeriesName === dataKey
|
|
451
|
+
})
|
|
348
452
|
|
|
349
|
-
|
|
350
|
-
|
|
453
|
+
if (existingSeries) {
|
|
454
|
+
console.warn(`Series for dataKey ${dataKey} already exists in the overview chart.`)
|
|
455
|
+
return // Exit the function without adding the series again
|
|
456
|
+
}
|
|
351
457
|
|
|
352
|
-
|
|
458
|
+
const dataset = this.config?.data.datasets.find(dataset => dataset.dataKey === dataKey)
|
|
459
|
+
if (!dataset) {
|
|
460
|
+
console.error('Dataset not found for dataKey:', dataKey)
|
|
461
|
+
return
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
const newSeries = await this.createSeriesForOverview(dataset)
|
|
465
|
+
|
|
466
|
+
if (newSeries) {
|
|
467
|
+
this.overviewChart.sciChartSurface.renderableSeries.add(newSeries.series)
|
|
468
|
+
this.overviewDataSeries.push(newSeries.dataSeries)
|
|
469
|
+
}
|
|
353
470
|
}
|
|
354
471
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
(
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
472
|
+
private async removeSeriesFromOverviewChart(dataKey: string) {
|
|
473
|
+
if (!this.overviewChart || !this.overviewDataSeries) {
|
|
474
|
+
console.error('Overview chart is not initialized.')
|
|
475
|
+
return
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
const { sciChartSurface } = this.overviewChart
|
|
479
|
+
|
|
480
|
+
// 오버뷰 차트의 renderableSeries에서 해당 시리즈 제거
|
|
481
|
+
const seriesIndex = sciChartSurface.renderableSeries.asArray().findIndex((series: any) => {
|
|
482
|
+
return series.dataSeries.dataSeriesName === dataKey
|
|
483
|
+
})
|
|
484
|
+
|
|
485
|
+
if (seriesIndex !== -1) {
|
|
486
|
+
const series = sciChartSurface.renderableSeries.get(seriesIndex)
|
|
487
|
+
const yAxisId = series.yAxisId
|
|
488
|
+
|
|
489
|
+
// 시리즈 제거
|
|
490
|
+
sciChartSurface.renderableSeries.removeAt(seriesIndex)
|
|
491
|
+
this.overviewDataSeries.splice(seriesIndex, 1) // 데이터 시리즈도 제거
|
|
492
|
+
|
|
493
|
+
// 고유 Y축 제거
|
|
494
|
+
if (yAxisId) {
|
|
495
|
+
const yAxisIndex = sciChartSurface.yAxes.asArray().findIndex((axis: any) => axis.id === yAxisId)
|
|
496
|
+
if (yAxisIndex !== -1) {
|
|
497
|
+
sciChartSurface.yAxes.removeAt(yAxisIndex)
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
} else {
|
|
501
|
+
console.error('Series not found in overview chart for dataKey:', dataKey)
|
|
502
|
+
}
|
|
361
503
|
}
|
|
362
504
|
|
|
363
|
-
async
|
|
364
|
-
|
|
505
|
+
private async createSeriesForOverview(dataset: any) {
|
|
506
|
+
if (!this.overviewChart) return null
|
|
507
|
+
|
|
508
|
+
const { sciChartSurface, wasmContext } = this.overviewChart
|
|
509
|
+
const dataSeries = new XyDataSeries(wasmContext, {
|
|
510
|
+
dataSeriesName: dataset.dataKey,
|
|
511
|
+
containsNaN: false
|
|
512
|
+
})
|
|
513
|
+
|
|
514
|
+
// 새로운 Y축을 추가하여 노멀라이즈 효과를 제공
|
|
515
|
+
const yAxisId = `yAxis_${dataset.dataKey}`
|
|
516
|
+
const yAxis = new NumericAxis(wasmContext, {
|
|
517
|
+
id: yAxisId,
|
|
518
|
+
autoRange: EAutoRange.Always,
|
|
519
|
+
drawLabels: false,
|
|
520
|
+
drawMajorTickLines: false,
|
|
521
|
+
drawMinorTickLines: false,
|
|
522
|
+
drawMajorGridLines: false,
|
|
523
|
+
drawMinorGridLines: false
|
|
524
|
+
})
|
|
525
|
+
|
|
526
|
+
sciChartSurface.yAxes.add(yAxis)
|
|
527
|
+
|
|
528
|
+
const series = new FastLineRenderableSeries(wasmContext, {
|
|
529
|
+
dataSeries,
|
|
530
|
+
strokeThickness: 1,
|
|
531
|
+
stroke: convertColor(dataset.color, DEFAULT_COLOR),
|
|
532
|
+
yAxisId
|
|
533
|
+
})
|
|
534
|
+
|
|
535
|
+
// 초기 데이터 추가
|
|
536
|
+
const newData = this.dataSet.find((data, index) => this.config?.data.datasets[index].dataKey === dataset.dataKey)
|
|
537
|
+
if (newData && newData.length > 0) {
|
|
538
|
+
const xValues = newData.map(d => d.xValue)
|
|
539
|
+
const yValues = newData.map(d => d.yValue).filter(y => typeof y === 'number' && !isNaN(y)) // y 값 검증
|
|
540
|
+
|
|
541
|
+
if (yValues.length > 0) {
|
|
542
|
+
// 유효한 y 값이 있을 때만 추가
|
|
543
|
+
dataSeries.appendRange(xValues, yValues)
|
|
544
|
+
} else {
|
|
545
|
+
console.warn('No valid yValues found for dataset:', dataset.dataKey)
|
|
546
|
+
}
|
|
547
|
+
}
|
|
365
548
|
|
|
366
|
-
|
|
367
|
-
interface HTMLElementTagNameMap {
|
|
368
|
-
'ox-scichart-multiple': OxSciChartMultiple
|
|
549
|
+
return { series, dataSeries }
|
|
369
550
|
}
|
|
370
551
|
}
|
|
@@ -56,7 +56,7 @@ SciChartSurface.configure({
|
|
|
56
56
|
wasmUrl: `/node_modules/scichart/_wasm/scichart2d.wasm`
|
|
57
57
|
})
|
|
58
58
|
|
|
59
|
-
const DEFAULT_COLOR = '#FF6600'
|
|
59
|
+
export const DEFAULT_COLOR = '#FF6600'
|
|
60
60
|
const DEFAULT_STROKE = '#000000'
|
|
61
61
|
const POINT_MARKER_SIZE = 10
|
|
62
62
|
const STROKE_THICKNESS = 2
|
|
@@ -75,7 +75,7 @@ function getThemeFromBrowser() {
|
|
|
75
75
|
return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
function convertColor(color: string | string[] | undefined, defaultColor?: string) {
|
|
78
|
+
export function convertColor(color: string | string[] | undefined, defaultColor?: string) {
|
|
79
79
|
const tinyColor = new TinyColor(color as string)
|
|
80
80
|
return tinyColor.toHex8String() || defaultColor
|
|
81
81
|
}
|
|
@@ -488,7 +488,7 @@ export async function buildSciChartOverview(
|
|
|
488
488
|
|
|
489
489
|
const { type: chartType, options, data: fromData } = config
|
|
490
490
|
const { datasets = [] } = fromData || {}
|
|
491
|
-
var { theme,
|
|
491
|
+
var { theme, scales: fromScales } = options || {}
|
|
492
492
|
|
|
493
493
|
var baseColor = getBaseColorFromTheme(theme)
|
|
494
494
|
|
|
@@ -515,36 +515,38 @@ export async function buildSciChartOverview(
|
|
|
515
515
|
sciChartSurface.xAxes.add(xAxis)
|
|
516
516
|
})
|
|
517
517
|
|
|
518
|
-
|
|
519
|
-
const yAxisId = `yAxis${index}`
|
|
520
|
-
const dataSeries = new XyDataSeries(wasmContext, {
|
|
521
|
-
dataSeriesName: dataset.label,
|
|
522
|
-
containsNaN: false
|
|
523
|
-
})
|
|
518
|
+
getDefaultYAxis(wasmContext, sciChartSurface)
|
|
524
519
|
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
drawMajorGridLines: false,
|
|
532
|
-
drawMinorGridLines: false
|
|
533
|
-
})
|
|
520
|
+
// const dataSeriesArray = datasets.map((dataset, index) => {
|
|
521
|
+
// const yAxisId = `yAxis${index}`
|
|
522
|
+
// const dataSeries = new XyDataSeries(wasmContext, {
|
|
523
|
+
// dataSeriesName: dataset.label,
|
|
524
|
+
// containsNaN: false
|
|
525
|
+
// })
|
|
534
526
|
|
|
535
|
-
|
|
527
|
+
// const yAxis = new NumericAxis(wasmContext, {
|
|
528
|
+
// id: yAxisId,
|
|
529
|
+
// autoRange: EAutoRange.Always,
|
|
530
|
+
// drawLabels: false,
|
|
531
|
+
// drawMajorTickLines: false,
|
|
532
|
+
// drawMinorTickLines: false,
|
|
533
|
+
// drawMajorGridLines: false,
|
|
534
|
+
// drawMinorGridLines: false
|
|
535
|
+
// })
|
|
536
536
|
|
|
537
|
-
|
|
538
|
-
dataSeries,
|
|
539
|
-
strokeThickness: 1,
|
|
540
|
-
stroke: convertColor(dataset.color, DEFAULT_COLOR),
|
|
541
|
-
yAxisId: yAxisId
|
|
542
|
-
})
|
|
537
|
+
// sciChartSurface.yAxes.add(yAxis)
|
|
543
538
|
|
|
544
|
-
|
|
539
|
+
// const series = new FastLineRenderableSeries(wasmContext, {
|
|
540
|
+
// dataSeries,
|
|
541
|
+
// strokeThickness: 1,
|
|
542
|
+
// stroke: convertColor(dataset.color, DEFAULT_COLOR),
|
|
543
|
+
// yAxisId: yAxisId
|
|
544
|
+
// })
|
|
545
545
|
|
|
546
|
-
|
|
547
|
-
|
|
546
|
+
// sciChartSurface.renderableSeries.add(series)
|
|
547
|
+
|
|
548
|
+
// return dataSeries
|
|
549
|
+
// })
|
|
548
550
|
|
|
549
551
|
const rangeSelectionModifier = new OverviewRangeSelectionModifier()
|
|
550
552
|
rangeSelectionModifier.onSelectedAreaChanged = (selectedRange?: NumberRange) => {
|
|
@@ -557,12 +559,27 @@ export async function buildSciChartOverview(
|
|
|
557
559
|
sciChartSurface.chartModifiers.add(rangeSelectionModifier)
|
|
558
560
|
|
|
559
561
|
axisSynchroniser.visibleRangeChanged.subscribe(({ visibleRange }: any) => {
|
|
560
|
-
const
|
|
562
|
+
const xAxis = sciChartSurface.xAxes.get(0)
|
|
563
|
+
const updatedSelectedRange = visibleRange.clip(xAxis.visibleRange)
|
|
561
564
|
const shouldUpdateSelectedRange = !updatedSelectedRange.equals(rangeSelectionModifier.selectedArea)
|
|
562
565
|
if (shouldUpdateSelectedRange) {
|
|
563
566
|
rangeSelectionModifier.selectedArea = updatedSelectedRange
|
|
564
567
|
}
|
|
565
568
|
})
|
|
566
569
|
|
|
567
|
-
return { chart, dataSeries:
|
|
570
|
+
return { chart, dataSeries: [] }
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function getDefaultYAxis(wasmContext: any, sciChartSurface: any): void {
|
|
574
|
+
const yAxis = new NumericAxis(wasmContext, {
|
|
575
|
+
id: 'DefaultAxisId',
|
|
576
|
+
autoRange: EAutoRange.Always,
|
|
577
|
+
drawLabels: false,
|
|
578
|
+
drawMajorTickLines: false,
|
|
579
|
+
drawMinorTickLines: false,
|
|
580
|
+
drawMajorGridLines: false,
|
|
581
|
+
drawMinorGridLines: false
|
|
582
|
+
})
|
|
583
|
+
|
|
584
|
+
sciChartSurface.yAxes.add(yAxis)
|
|
568
585
|
}
|