@operato/scene-scichart 8.0.0-beta.1 → 8.0.0
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/package.json +6 -6
- package/CHANGELOG.md +0 -278
- package/db.sqlite +0 -0
- package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +0 -15
- package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +0 -15
- package/logs/application-2024-09-10-23.log +0 -105
- package/logs/connections-2024-09-10-23.log +0 -50
- package/schema.graphql +0 -4455
- package/src/charts/axis-synchronizer.ts +0 -37
- package/src/charts/ox-scichart-multiple.ts +0 -579
- package/src/charts/ox-scichart.ts +0 -155
- package/src/charts/scichart-builder.ts +0 -630
- package/src/editors/index.ts +0 -8
- package/src/groups/index.ts +0 -0
- package/src/index.ts +0 -2
- package/src/scichart-multiple-timeseries.ts +0 -69
- package/src/scichart-timeseries.ts +0 -51
- package/src/templates/index.ts +0 -4
- package/src/templates/scichart-multiple-timeseries.ts +0 -87
- package/src/templates/scichart-timeseries.ts +0 -73
- package/tsconfig.json +0 -23
- package/tsconfig.tsbuildinfo +0 -1
@@ -1,630 +0,0 @@
|
|
1
|
-
import { TinyColor } from '@ctrl/tinycolor'
|
2
|
-
import {
|
3
|
-
SciChartSurface,
|
4
|
-
SciChartJSLightTheme,
|
5
|
-
SciChartJSDarkv2Theme,
|
6
|
-
XyDataSeries,
|
7
|
-
FastLineRenderableSeries,
|
8
|
-
SplineLineRenderableSeries,
|
9
|
-
FastColumnRenderableSeries,
|
10
|
-
StackedColumnRenderableSeries,
|
11
|
-
StackedMountainRenderableSeries,
|
12
|
-
StackedColumnCollection,
|
13
|
-
StackedMountainCollection,
|
14
|
-
NumericAxis,
|
15
|
-
DateTimeNumericAxis,
|
16
|
-
EAutoRange,
|
17
|
-
EAxisAlignment,
|
18
|
-
EExecuteOn,
|
19
|
-
ECoordinateMode,
|
20
|
-
EHorizontalAnchorPoint,
|
21
|
-
EVerticalAnchorPoint,
|
22
|
-
NumberRange,
|
23
|
-
MouseWheelZoomModifier,
|
24
|
-
RubberBandXyZoomModifier,
|
25
|
-
ZoomPanModifier,
|
26
|
-
ZoomExtentsModifier,
|
27
|
-
RolloverModifier,
|
28
|
-
NumericLabelProvider,
|
29
|
-
SmartDateLabelProvider,
|
30
|
-
EllipsePointMarker,
|
31
|
-
SquarePointMarker,
|
32
|
-
TrianglePointMarker,
|
33
|
-
CrossPointMarker,
|
34
|
-
XPointMarker,
|
35
|
-
WaveAnimation,
|
36
|
-
LegendModifier,
|
37
|
-
ELegendPlacement,
|
38
|
-
EXyDirection,
|
39
|
-
XAxisDragModifier,
|
40
|
-
YAxisDragModifier,
|
41
|
-
TextAnnotation,
|
42
|
-
LineAnnotation,
|
43
|
-
BoxAnnotation,
|
44
|
-
HorizontalLineAnnotation,
|
45
|
-
VerticalLineAnnotation,
|
46
|
-
OverviewRangeSelectionModifier,
|
47
|
-
ENumericFormat,
|
48
|
-
XySeriesInfo
|
49
|
-
} from 'scichart'
|
50
|
-
import { AxisSynchroniser } from './axis-synchronizer'
|
51
|
-
|
52
|
-
SciChartSurface.configure({
|
53
|
-
dataUrl: `/node_modules/scichart/_wasm/scichart2d.data`,
|
54
|
-
wasmUrl: `/node_modules/scichart/_wasm/scichart2d.wasm`
|
55
|
-
})
|
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
|
-
|
102
|
-
export const DEFAULT_COLOR = '#FF6600'
|
103
|
-
const DEFAULT_STROKE = '#000000'
|
104
|
-
const POINT_MARKER_SIZE = 10
|
105
|
-
const STROKE_THICKNESS = 2
|
106
|
-
const ANIMATION_DURATION = 1000
|
107
|
-
|
108
|
-
function getLocalTimeOffset() {
|
109
|
-
const now = new Date()
|
110
|
-
return now.getTimezoneOffset() * -60
|
111
|
-
}
|
112
|
-
|
113
|
-
function getBaseColorFromTheme(theme?: 'light' | 'dark' | 'auto') {
|
114
|
-
return new TinyColor(theme == 'dark' ? '#fff' : '#000')
|
115
|
-
}
|
116
|
-
|
117
|
-
function getThemeFromBrowser() {
|
118
|
-
return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
119
|
-
}
|
120
|
-
|
121
|
-
export function convertColor(color: string | string[] | undefined, defaultColor?: string) {
|
122
|
-
const tinyColor = new TinyColor(color as string)
|
123
|
-
return tinyColor.toHex8String() || defaultColor
|
124
|
-
}
|
125
|
-
|
126
|
-
export function calculatePrecision(format: string | number = '') {
|
127
|
-
const formatString = format.toString()
|
128
|
-
|
129
|
-
if (formatString.indexOf('.') !== -1) {
|
130
|
-
return formatString.split('.')[1].length
|
131
|
-
}
|
132
|
-
|
133
|
-
return 0
|
134
|
-
}
|
135
|
-
|
136
|
-
function createPointMarker(wasmContext: any, dataset: any, color: string = DEFAULT_COLOR) {
|
137
|
-
const { pointStyle, pointRadius = POINT_MARKER_SIZE } = dataset || {}
|
138
|
-
|
139
|
-
if (!pointStyle) {
|
140
|
-
return
|
141
|
-
}
|
142
|
-
|
143
|
-
const pointMarkerOptions = {
|
144
|
-
width: pointRadius,
|
145
|
-
height: pointRadius,
|
146
|
-
strokeThickness: STROKE_THICKNESS,
|
147
|
-
fill: color,
|
148
|
-
stroke: DEFAULT_STROKE
|
149
|
-
}
|
150
|
-
|
151
|
-
switch (pointStyle) {
|
152
|
-
case 'triangle':
|
153
|
-
return new TrianglePointMarker(wasmContext, pointMarkerOptions)
|
154
|
-
case 'rect':
|
155
|
-
return new SquarePointMarker(wasmContext, pointMarkerOptions)
|
156
|
-
case 'cross':
|
157
|
-
return new CrossPointMarker(wasmContext, pointMarkerOptions)
|
158
|
-
case 'crossRot':
|
159
|
-
return new XPointMarker(wasmContext, pointMarkerOptions)
|
160
|
-
default:
|
161
|
-
return new EllipsePointMarker(wasmContext, pointMarkerOptions)
|
162
|
-
}
|
163
|
-
}
|
164
|
-
|
165
|
-
function createAxis(
|
166
|
-
wasmContext: any,
|
167
|
-
axis: any,
|
168
|
-
index: number,
|
169
|
-
isXAxis: boolean,
|
170
|
-
fontColor: string,
|
171
|
-
fontFamily?: string,
|
172
|
-
fontSize?: number,
|
173
|
-
precision?: number,
|
174
|
-
options?: any
|
175
|
-
) {
|
176
|
-
const { axisTitle, ticks } = axis
|
177
|
-
const {
|
178
|
-
autoMax,
|
179
|
-
autoMin,
|
180
|
-
min,
|
181
|
-
max,
|
182
|
-
stepSize,
|
183
|
-
beginAtZero,
|
184
|
-
color = fontColor,
|
185
|
-
textStrokeColor = fontColor,
|
186
|
-
display = false
|
187
|
-
} = ticks || {}
|
188
|
-
|
189
|
-
const axisOptions = {
|
190
|
-
axisTitle,
|
191
|
-
autoRange: autoMin || autoMax ? EAutoRange.Always : EAutoRange.Once,
|
192
|
-
axisAlignment: isXAxis ? EAxisAlignment.Bottom : index === 0 ? EAxisAlignment.Left : EAxisAlignment.Right,
|
193
|
-
visibleRange: min !== undefined && max !== undefined ? new NumberRange(min, max) : undefined,
|
194
|
-
majorDelta: stepSize,
|
195
|
-
growBy: beginAtZero ? new NumberRange(0.1, 0.1) : undefined,
|
196
|
-
labelStyle: {
|
197
|
-
fontFamily,
|
198
|
-
fontSize,
|
199
|
-
color
|
200
|
-
},
|
201
|
-
axisTitleStyle: {
|
202
|
-
fontFamily,
|
203
|
-
fontSize,
|
204
|
-
color: textStrokeColor
|
205
|
-
},
|
206
|
-
...options,
|
207
|
-
drawLabels: display
|
208
|
-
}
|
209
|
-
|
210
|
-
const labelProvider = isXAxis
|
211
|
-
? new SmartDateLabelProvider({
|
212
|
-
showWiderDateOnFirstLabel: true,
|
213
|
-
showYearOnWiderDate: false,
|
214
|
-
dateOffset: getLocalTimeOffset()
|
215
|
-
})
|
216
|
-
: new NumericLabelProvider()
|
217
|
-
|
218
|
-
if (isXAxis) {
|
219
|
-
labelProvider!.cursorNumericFormat = ENumericFormat.Date_HHMMSS
|
220
|
-
} else {
|
221
|
-
labelProvider!.numericFormat = ENumericFormat.Decimal
|
222
|
-
labelProvider!.precision = precision || calculatePrecision(stepSize || 0.1)
|
223
|
-
labelProvider!.cursorNumericFormat = ENumericFormat.NoFormat
|
224
|
-
}
|
225
|
-
|
226
|
-
return isXAxis
|
227
|
-
? new DateTimeNumericAxis(wasmContext, {
|
228
|
-
...axisOptions,
|
229
|
-
labelProvider
|
230
|
-
})
|
231
|
-
: new NumericAxis(wasmContext, {
|
232
|
-
...axisOptions,
|
233
|
-
id: index !== 0 ? `yAxis${index}` : undefined,
|
234
|
-
labelProvider
|
235
|
-
})
|
236
|
-
}
|
237
|
-
|
238
|
-
function createSeries(
|
239
|
-
wasmContext: any,
|
240
|
-
dataset: any,
|
241
|
-
index: number,
|
242
|
-
stacked: boolean,
|
243
|
-
animation: boolean,
|
244
|
-
yAxisId: string | undefined
|
245
|
-
) {
|
246
|
-
const dataSeries = new XyDataSeries(wasmContext, {
|
247
|
-
dataSeriesName: dataset.label,
|
248
|
-
containsNaN: false
|
249
|
-
})
|
250
|
-
|
251
|
-
const stackGroupId = dataset.stack || `__stack${index}__`
|
252
|
-
const color = convertColor(dataset.backgroundColor, DEFAULT_COLOR)
|
253
|
-
const strokeColor = convertColor(dataset.color, DEFAULT_COLOR)
|
254
|
-
const borderWidth = dataset.borderWidth || STROKE_THICKNESS
|
255
|
-
const pointMarker = createPointMarker(wasmContext, dataset, strokeColor)
|
256
|
-
|
257
|
-
let series
|
258
|
-
if (dataset.type === 'bar') {
|
259
|
-
series = stacked
|
260
|
-
? new StackedColumnRenderableSeries(wasmContext, {
|
261
|
-
dataSeries,
|
262
|
-
strokeThickness: borderWidth,
|
263
|
-
fill: color,
|
264
|
-
stackedGroupId: stackGroupId
|
265
|
-
})
|
266
|
-
: new FastColumnRenderableSeries(wasmContext, {
|
267
|
-
dataSeries,
|
268
|
-
strokeThickness: borderWidth,
|
269
|
-
fill: color,
|
270
|
-
animation: animation ? new WaveAnimation({ duration: ANIMATION_DURATION, fadeEffect: true }) : undefined,
|
271
|
-
yAxisId
|
272
|
-
})
|
273
|
-
} else {
|
274
|
-
series = stacked
|
275
|
-
? new StackedMountainRenderableSeries(wasmContext, {
|
276
|
-
dataSeries,
|
277
|
-
strokeThickness: borderWidth,
|
278
|
-
stroke: strokeColor,
|
279
|
-
fill: color
|
280
|
-
})
|
281
|
-
: dataset.lineTension && dataset.lineTension > 0
|
282
|
-
? new SplineLineRenderableSeries(wasmContext, {
|
283
|
-
dataSeries,
|
284
|
-
strokeThickness: borderWidth,
|
285
|
-
stroke: strokeColor,
|
286
|
-
pointMarker,
|
287
|
-
animation: animation ? new WaveAnimation({ duration: ANIMATION_DURATION, fadeEffect: true }) : undefined,
|
288
|
-
yAxisId
|
289
|
-
})
|
290
|
-
: new FastLineRenderableSeries(wasmContext, {
|
291
|
-
dataSeries,
|
292
|
-
strokeThickness: borderWidth,
|
293
|
-
stroke: strokeColor,
|
294
|
-
pointMarker,
|
295
|
-
animation: animation ? new WaveAnimation({ duration: ANIMATION_DURATION, fadeEffect: true }) : undefined,
|
296
|
-
yAxisId
|
297
|
-
})
|
298
|
-
}
|
299
|
-
|
300
|
-
return { series, dataSeries }
|
301
|
-
}
|
302
|
-
|
303
|
-
export async function buildSciChart(
|
304
|
-
config: OperatoChart.ChartConfig | undefined | null,
|
305
|
-
container: any,
|
306
|
-
{ fontSize = 14, fontFamily = 'Roboto', fontColor }: { fontSize?: number; fontFamily?: string; fontColor?: string },
|
307
|
-
{ grouped, precision }: { grouped?: string; precision?: number }
|
308
|
-
): Promise<{ chart: any; dataSeries: any[] } | undefined> {
|
309
|
-
if (!config) return
|
310
|
-
|
311
|
-
await initializeSciChartLicense()
|
312
|
-
|
313
|
-
const { type: chartType, options, data: fromData } = config
|
314
|
-
const { datasets = [] } = fromData || {}
|
315
|
-
var {
|
316
|
-
theme,
|
317
|
-
tooltip = true,
|
318
|
-
animation = true,
|
319
|
-
legend = {
|
320
|
-
display: true,
|
321
|
-
position: 'top'
|
322
|
-
},
|
323
|
-
scales: fromScales,
|
324
|
-
xGridLine = false,
|
325
|
-
yGridLine = false,
|
326
|
-
y2ndGridLine = false,
|
327
|
-
stacked = false,
|
328
|
-
multiAxis = false,
|
329
|
-
annotations = []
|
330
|
-
} = options || {}
|
331
|
-
|
332
|
-
var baseColor = getBaseColorFromTheme(theme)
|
333
|
-
|
334
|
-
if (theme === 'auto') {
|
335
|
-
theme = getThemeFromBrowser()
|
336
|
-
}
|
337
|
-
|
338
|
-
fontColor = fontColor || baseColor.clone().toString()
|
339
|
-
|
340
|
-
const { xAxes = [], yAxes = [] } = fromScales || {}
|
341
|
-
|
342
|
-
const chart = await SciChartSurface.create(container, {
|
343
|
-
theme: theme == 'dark' ? new SciChartJSDarkv2Theme() : new SciChartJSLightTheme()
|
344
|
-
})
|
345
|
-
const { sciChartSurface, wasmContext } = chart
|
346
|
-
|
347
|
-
xAxes.forEach((axis, index) => {
|
348
|
-
const xAxis = createAxis(wasmContext, axis, index, true, fontColor, fontFamily, fontSize, undefined, {
|
349
|
-
drawMajorTickLines: true,
|
350
|
-
drawMinorTickLines: true,
|
351
|
-
drawMajorGridLines: xGridLine,
|
352
|
-
drawMinorGridLines: xGridLine
|
353
|
-
})
|
354
|
-
sciChartSurface.xAxes.add(xAxis)
|
355
|
-
})
|
356
|
-
;(multiAxis ? yAxes : [yAxes[0]]).forEach((axis, index) => {
|
357
|
-
const yAxis = createAxis(wasmContext, axis, index, false, fontColor, fontFamily, fontSize, precision, {
|
358
|
-
drawMajorTickLines: true,
|
359
|
-
drawMinorTickLines: true,
|
360
|
-
drawMajorGridLines: index == 0 ? yGridLine : y2ndGridLine,
|
361
|
-
drawMinorGridLines: index == 0 ? yGridLine : y2ndGridLine
|
362
|
-
})
|
363
|
-
sciChartSurface.yAxes.add(yAxis)
|
364
|
-
})
|
365
|
-
|
366
|
-
const dataSeriesArray = datasets.map((dataset, index) => {
|
367
|
-
const yAxisId = dataset.yAxisID == 'right' && multiAxis ? 'yAxis1' : undefined
|
368
|
-
const { series, dataSeries } = createSeries(wasmContext, dataset, index, !!stacked, !!animation, yAxisId)
|
369
|
-
|
370
|
-
sciChartSurface.renderableSeries.add(series)
|
371
|
-
|
372
|
-
if (tooltip) {
|
373
|
-
const rolloverModifier = new RolloverModifier({
|
374
|
-
showTooltip: true,
|
375
|
-
showAxisLabel: true /* show x-axis label for cursor */,
|
376
|
-
modifierGroup: grouped,
|
377
|
-
tooltipDataTemplate: (seriesInfo: XySeriesInfo): string[] => {
|
378
|
-
const valuesWithLabels: string[] = []
|
379
|
-
const xySeriesInfo = seriesInfo as XySeriesInfo
|
380
|
-
valuesWithLabels.push(xySeriesInfo.formattedYValue)
|
381
|
-
return valuesWithLabels
|
382
|
-
}
|
383
|
-
})
|
384
|
-
|
385
|
-
sciChartSurface.chartModifiers.add(rolloverModifier)
|
386
|
-
}
|
387
|
-
|
388
|
-
return dataSeries
|
389
|
-
})
|
390
|
-
|
391
|
-
if (stacked) {
|
392
|
-
const stackedColumnCollection = new StackedColumnCollection(wasmContext)
|
393
|
-
const stackedMountainCollection = new StackedMountainCollection(wasmContext)
|
394
|
-
|
395
|
-
sciChartSurface.renderableSeries.asArray().forEach((series: any) => {
|
396
|
-
if (series instanceof StackedColumnRenderableSeries) {
|
397
|
-
stackedColumnCollection.add(series)
|
398
|
-
} else if (series instanceof StackedMountainRenderableSeries) {
|
399
|
-
stackedMountainCollection.add(series)
|
400
|
-
}
|
401
|
-
})
|
402
|
-
|
403
|
-
if (stackedColumnCollection.size() > 0) {
|
404
|
-
sciChartSurface.renderableSeries.add(stackedColumnCollection)
|
405
|
-
}
|
406
|
-
|
407
|
-
if (stackedMountainCollection.size() > 0) {
|
408
|
-
sciChartSurface.renderableSeries.add(stackedMountainCollection)
|
409
|
-
}
|
410
|
-
}
|
411
|
-
|
412
|
-
if (annotations) {
|
413
|
-
annotations.forEach(annotation => {
|
414
|
-
let sciAnnotation
|
415
|
-
let horizontalAnchorPoint: EHorizontalAnchorPoint =
|
416
|
-
annotation.horizontalAnchorPoint == 'Right'
|
417
|
-
? EHorizontalAnchorPoint.Right
|
418
|
-
: annotation.horizontalAnchorPoint == 'Left'
|
419
|
-
? EHorizontalAnchorPoint.Left
|
420
|
-
: EHorizontalAnchorPoint.Center
|
421
|
-
let verticalAnchorPoint: EVerticalAnchorPoint =
|
422
|
-
annotation.verticalAnchorPoint == 'Top'
|
423
|
-
? EVerticalAnchorPoint.Top
|
424
|
-
: annotation.verticalAnchorPoint == 'Bottom'
|
425
|
-
? EVerticalAnchorPoint.Bottom
|
426
|
-
: EVerticalAnchorPoint.Center
|
427
|
-
|
428
|
-
switch (annotation.type) {
|
429
|
-
case 'text':
|
430
|
-
sciAnnotation = new TextAnnotation({
|
431
|
-
x1: annotation.x1,
|
432
|
-
y1: annotation.y1,
|
433
|
-
text: annotation.text,
|
434
|
-
horizontalAnchorPoint,
|
435
|
-
verticalAnchorPoint,
|
436
|
-
fontSize: annotation.fontSize,
|
437
|
-
fontFamily: annotation.fontFamily,
|
438
|
-
textColor: convertColor(annotation.stroke, fontColor),
|
439
|
-
xCoordinateMode: (annotation.xCoordinateMode || ECoordinateMode.DataValue) as ECoordinateMode,
|
440
|
-
yCoordinateMode: (annotation.yCoordinateMode || ECoordinateMode.DataValue) as ECoordinateMode
|
441
|
-
})
|
442
|
-
break
|
443
|
-
case 'line':
|
444
|
-
sciAnnotation = new LineAnnotation({
|
445
|
-
x1: annotation.x1,
|
446
|
-
y1: annotation.y1,
|
447
|
-
x2: annotation.x2,
|
448
|
-
y2: annotation.y2,
|
449
|
-
stroke: convertColor(annotation.stroke, '#FF0000'),
|
450
|
-
strokeThickness: annotation.strokeThickness,
|
451
|
-
xCoordinateMode: (annotation.xCoordinateMode || ECoordinateMode.DataValue) as ECoordinateMode,
|
452
|
-
yCoordinateMode: (annotation.yCoordinateMode || ECoordinateMode.DataValue) as ECoordinateMode
|
453
|
-
})
|
454
|
-
break
|
455
|
-
case 'box':
|
456
|
-
sciAnnotation = new BoxAnnotation({
|
457
|
-
x1: annotation.x1,
|
458
|
-
y1: annotation.y1,
|
459
|
-
x2: annotation.x2,
|
460
|
-
y2: annotation.y2,
|
461
|
-
fill: convertColor(annotation.fill, '#FF0000'),
|
462
|
-
stroke: convertColor(annotation.stroke, '#FF0000'),
|
463
|
-
strokeThickness: annotation.strokeThickness,
|
464
|
-
xCoordinateMode: (annotation.xCoordinateMode || ECoordinateMode.DataValue) as ECoordinateMode,
|
465
|
-
yCoordinateMode: (annotation.yCoordinateMode || ECoordinateMode.DataValue) as ECoordinateMode
|
466
|
-
})
|
467
|
-
break
|
468
|
-
case 'horizontalLine':
|
469
|
-
sciAnnotation = new HorizontalLineAnnotation({
|
470
|
-
y1: annotation.y1,
|
471
|
-
stroke: convertColor(annotation.stroke, '#FF0000'),
|
472
|
-
strokeThickness: annotation.strokeThickness,
|
473
|
-
xCoordinateMode: (annotation.xCoordinateMode || ECoordinateMode.DataValue) as ECoordinateMode,
|
474
|
-
yCoordinateMode: (annotation.yCoordinateMode || ECoordinateMode.DataValue) as ECoordinateMode
|
475
|
-
})
|
476
|
-
break
|
477
|
-
case 'verticalLine':
|
478
|
-
sciAnnotation = new VerticalLineAnnotation({
|
479
|
-
x1: annotation.x1,
|
480
|
-
stroke: convertColor(annotation.stroke, '#FF0000'),
|
481
|
-
strokeThickness: annotation.strokeThickness,
|
482
|
-
xCoordinateMode: (annotation.xCoordinateMode || ECoordinateMode.DataValue) as ECoordinateMode,
|
483
|
-
yCoordinateMode: (annotation.yCoordinateMode || ECoordinateMode.DataValue) as ECoordinateMode
|
484
|
-
})
|
485
|
-
break
|
486
|
-
default:
|
487
|
-
break
|
488
|
-
}
|
489
|
-
if (sciAnnotation) {
|
490
|
-
sciChartSurface.annotations.add(sciAnnotation)
|
491
|
-
}
|
492
|
-
})
|
493
|
-
}
|
494
|
-
|
495
|
-
sciChartSurface.chartModifiers.add(
|
496
|
-
new RubberBandXyZoomModifier({ executeOn: EExecuteOn.MouseRightButton, modifierGroup: grouped }),
|
497
|
-
// new ZoomPanModifier({ xyDirection: EXyDirection.XDirection }),
|
498
|
-
new ZoomPanModifier({ xyDirection: EXyDirection.XDirection }),
|
499
|
-
new MouseWheelZoomModifier({ xyDirection: EXyDirection.XDirection }),
|
500
|
-
new ZoomExtentsModifier(),
|
501
|
-
new XAxisDragModifier(),
|
502
|
-
new YAxisDragModifier()
|
503
|
-
)
|
504
|
-
|
505
|
-
if (legend?.display) {
|
506
|
-
const legendModifier = new LegendModifier({
|
507
|
-
showCheckboxes: true,
|
508
|
-
showSeriesMarkers: true,
|
509
|
-
showLegend: true,
|
510
|
-
placement:
|
511
|
-
legend.position == 'top'
|
512
|
-
? ELegendPlacement.TopLeft
|
513
|
-
: legend.position == 'left'
|
514
|
-
? ELegendPlacement.BottomLeft
|
515
|
-
: legend.position == 'bottom'
|
516
|
-
? ELegendPlacement.BottomRight
|
517
|
-
: ELegendPlacement.TopRight
|
518
|
-
})
|
519
|
-
|
520
|
-
sciChartSurface.chartModifiers.add(legendModifier)
|
521
|
-
}
|
522
|
-
|
523
|
-
return { chart, dataSeries: dataSeriesArray }
|
524
|
-
}
|
525
|
-
|
526
|
-
export async function buildSciChartOverview(
|
527
|
-
config: OperatoChart.ChartConfig | undefined | null,
|
528
|
-
container: any,
|
529
|
-
{ fontSize = 14, fontFamily = 'Roboto', fontColor }: { fontSize?: number; fontFamily?: string; fontColor?: string },
|
530
|
-
axisSynchroniser: AxisSynchroniser
|
531
|
-
): Promise<{ chart: any; dataSeries: any[] } | undefined> {
|
532
|
-
if (!config) return
|
533
|
-
|
534
|
-
const { type: chartType, options, data: fromData } = config
|
535
|
-
const { datasets = [] } = fromData || {}
|
536
|
-
var { theme, scales: fromScales } = options || {}
|
537
|
-
|
538
|
-
var baseColor = getBaseColorFromTheme(theme)
|
539
|
-
|
540
|
-
if (theme === 'auto') {
|
541
|
-
theme = getThemeFromBrowser()
|
542
|
-
}
|
543
|
-
|
544
|
-
fontColor = fontColor || baseColor.clone().toString()
|
545
|
-
|
546
|
-
const { xAxes = [], yAxes = [] } = fromScales || {}
|
547
|
-
|
548
|
-
const chart = await SciChartSurface.create(container, {
|
549
|
-
theme: theme == 'dark' ? new SciChartJSDarkv2Theme() : new SciChartJSLightTheme()
|
550
|
-
})
|
551
|
-
const { sciChartSurface, wasmContext } = chart
|
552
|
-
|
553
|
-
xAxes.forEach((axis, index) => {
|
554
|
-
const xAxis = createAxis(wasmContext, axis, index, true, fontColor, fontFamily, fontSize, undefined, {
|
555
|
-
drawMajorTickLines: false,
|
556
|
-
drawMinorTickLines: false,
|
557
|
-
drawMajorGridLines: false,
|
558
|
-
drawMinorGridLines: false
|
559
|
-
})
|
560
|
-
sciChartSurface.xAxes.add(xAxis)
|
561
|
-
})
|
562
|
-
|
563
|
-
getDefaultYAxis(wasmContext, sciChartSurface)
|
564
|
-
|
565
|
-
// const dataSeriesArray = datasets.map((dataset, index) => {
|
566
|
-
// const yAxisId = `yAxis${index}`
|
567
|
-
// const dataSeries = new XyDataSeries(wasmContext, {
|
568
|
-
// dataSeriesName: dataset.label,
|
569
|
-
// containsNaN: false
|
570
|
-
// })
|
571
|
-
|
572
|
-
// const yAxis = new NumericAxis(wasmContext, {
|
573
|
-
// id: yAxisId,
|
574
|
-
// autoRange: EAutoRange.Always,
|
575
|
-
// drawLabels: false,
|
576
|
-
// drawMajorTickLines: false,
|
577
|
-
// drawMinorTickLines: false,
|
578
|
-
// drawMajorGridLines: false,
|
579
|
-
// drawMinorGridLines: false
|
580
|
-
// })
|
581
|
-
|
582
|
-
// sciChartSurface.yAxes.add(yAxis)
|
583
|
-
|
584
|
-
// const series = new FastLineRenderableSeries(wasmContext, {
|
585
|
-
// dataSeries,
|
586
|
-
// strokeThickness: 1,
|
587
|
-
// stroke: convertColor(dataset.color, DEFAULT_COLOR),
|
588
|
-
// yAxisId: yAxisId
|
589
|
-
// })
|
590
|
-
|
591
|
-
// sciChartSurface.renderableSeries.add(series)
|
592
|
-
|
593
|
-
// return dataSeries
|
594
|
-
// })
|
595
|
-
|
596
|
-
const rangeSelectionModifier = new OverviewRangeSelectionModifier()
|
597
|
-
rangeSelectionModifier.onSelectedAreaChanged = (selectedRange?: NumberRange) => {
|
598
|
-
if (!selectedRange!.equals(axisSynchroniser.visibleRange)) {
|
599
|
-
axisSynchroniser.publishChange({ visibleRange: selectedRange! })
|
600
|
-
}
|
601
|
-
}
|
602
|
-
|
603
|
-
rangeSelectionModifier.selectedArea = axisSynchroniser.visibleRange
|
604
|
-
sciChartSurface.chartModifiers.add(rangeSelectionModifier)
|
605
|
-
|
606
|
-
axisSynchroniser.visibleRangeChanged.subscribe(({ visibleRange }: any) => {
|
607
|
-
const xAxis = sciChartSurface.xAxes.get(0)
|
608
|
-
const updatedSelectedRange = visibleRange.clip(xAxis.visibleRange)
|
609
|
-
const shouldUpdateSelectedRange = !updatedSelectedRange.equals(rangeSelectionModifier.selectedArea)
|
610
|
-
if (shouldUpdateSelectedRange) {
|
611
|
-
rangeSelectionModifier.selectedArea = updatedSelectedRange
|
612
|
-
}
|
613
|
-
})
|
614
|
-
|
615
|
-
return { chart, dataSeries: [] }
|
616
|
-
}
|
617
|
-
|
618
|
-
function getDefaultYAxis(wasmContext: any, sciChartSurface: any): void {
|
619
|
-
const yAxis = new NumericAxis(wasmContext, {
|
620
|
-
id: 'DefaultAxisId',
|
621
|
-
autoRange: EAutoRange.Always,
|
622
|
-
drawLabels: false,
|
623
|
-
drawMajorTickLines: false,
|
624
|
-
drawMinorTickLines: false,
|
625
|
-
drawMajorGridLines: false,
|
626
|
-
drawMinorGridLines: false
|
627
|
-
})
|
628
|
-
|
629
|
-
sciChartSurface.yAxes.add(yAxis)
|
630
|
-
}
|
package/src/editors/index.ts
DELETED
package/src/groups/index.ts
DELETED
File without changes
|
package/src/index.ts
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* Copyright © HatioLab Inc. All rights reserved.
|
3
|
-
*/
|
4
|
-
|
5
|
-
const NATURE: ComponentNature = {
|
6
|
-
mutable: false,
|
7
|
-
resizable: true,
|
8
|
-
rotatable: true,
|
9
|
-
properties: [
|
10
|
-
{
|
11
|
-
type: 'boolean',
|
12
|
-
label: 'show-overview',
|
13
|
-
name: 'showOverview'
|
14
|
-
},
|
15
|
-
{
|
16
|
-
type: 'scichart',
|
17
|
-
label: '',
|
18
|
-
name: 'chart'
|
19
|
-
}
|
20
|
-
],
|
21
|
-
'value-property': 'visibleSeries',
|
22
|
-
help: 'scene/component/scichart-multiple-timeseries'
|
23
|
-
}
|
24
|
-
|
25
|
-
import './charts/ox-scichart-multiple'
|
26
|
-
|
27
|
-
import { Component, HTMLOverlayContainer, Properties, ComponentNature, error } from '@hatiolab/things-scene'
|
28
|
-
|
29
|
-
import { OxSciChartMultiple } from './charts/ox-scichart-multiple'
|
30
|
-
|
31
|
-
export default class ScichartMultipleTimeseries extends HTMLOverlayContainer {
|
32
|
-
static get nature() {
|
33
|
-
return NATURE
|
34
|
-
}
|
35
|
-
|
36
|
-
dispose() {
|
37
|
-
super.dispose()
|
38
|
-
;(this.element as OxSciChartMultiple)?.dispose()
|
39
|
-
}
|
40
|
-
|
41
|
-
setElementProperties(scichart: OxSciChartMultiple) {
|
42
|
-
const { data, chart, showOverview, visibleSeries } = this.state
|
43
|
-
|
44
|
-
scichart.config = chart
|
45
|
-
scichart.data = data
|
46
|
-
scichart.showOverview = showOverview
|
47
|
-
scichart.visibleSeries = visibleSeries || []
|
48
|
-
}
|
49
|
-
|
50
|
-
get tagName() {
|
51
|
-
return 'ox-scichart-multiple'
|
52
|
-
}
|
53
|
-
|
54
|
-
get visibleSeries() {
|
55
|
-
const { visibleSeries } = this.state
|
56
|
-
return visibleSeries || []
|
57
|
-
}
|
58
|
-
|
59
|
-
set visibleSeries(visibleSeries: string[]) {
|
60
|
-
this.setState('visibleSeries', visibleSeries)
|
61
|
-
;(this.element as OxSciChartMultiple).visibleSeries = visibleSeries
|
62
|
-
}
|
63
|
-
|
64
|
-
async onchangeData(after: Properties, before: Properties): Promise<void> {
|
65
|
-
;(this.element as OxSciChartMultiple).data = this.data
|
66
|
-
}
|
67
|
-
}
|
68
|
-
|
69
|
-
Component.register('scichart-multiple-timeseries', ScichartMultipleTimeseries)
|