@operato/chart 7.0.30 → 7.0.32
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 +19 -0
- package/dist/src/editors/input-chart-abstract.d.ts +1 -0
- package/dist/src/editors/input-chart-abstract.js +36 -1
- package/dist/src/editors/input-chart-abstract.js.map +1 -1
- package/dist/src/editors/ox-input-chart-timeseries.d.ts +1 -0
- package/dist/src/editors/ox-input-chart-timeseries.js +39 -6
- package/dist/src/editors/ox-input-chart-timeseries.js.map +1 -1
- package/dist/src/scichart/ox-scichart.d.ts +3 -0
- package/dist/src/scichart/ox-scichart.js +1 -0
- package/dist/src/scichart/ox-scichart.js.map +1 -1
- package/dist/src/scichart/scichart-builder.js +49 -10
- package/dist/src/scichart/scichart-builder.js.map +1 -1
- package/dist/stories/ox-input-chart-timeseries.stories.js +52 -1
- package/dist/stories/ox-input-chart-timeseries.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/editors/input-chart-abstract.ts +37 -1
- package/src/editors/ox-input-chart-timeseries.ts +34 -6
- package/src/scichart/ox-scichart.ts +2 -0
- package/src/scichart/scichart-builder.ts +61 -18
- package/src/types.d.ts +5 -3
- package/stories/ox-input-chart-timeseries.stories.ts +52 -1
|
@@ -14,10 +14,15 @@ function convertColor(color: string | string[] | undefined, defaultColor?: strin
|
|
|
14
14
|
return tinyColor.toHex8String() || defaultColor
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
function getLocalTimeOffset() {
|
|
18
|
+
const now = new Date()
|
|
19
|
+
return now.getTimezoneOffset() * -60
|
|
20
|
+
}
|
|
21
|
+
|
|
17
22
|
export async function buildSciChart(
|
|
18
23
|
config: OperatoChart.ChartConfig | undefined | null,
|
|
19
24
|
container: any,
|
|
20
|
-
{ fontSize, fontFamily, fontColor }: { fontSize?: number; fontFamily?: string; fontColor?: string }
|
|
25
|
+
{ fontSize = 14, fontFamily = 'Roboto', fontColor }: { fontSize?: number; fontFamily?: string; fontColor?: string }
|
|
21
26
|
): Promise<{ chart: any; dataSeries: any[] } | undefined> {
|
|
22
27
|
if (!config) {
|
|
23
28
|
return
|
|
@@ -37,6 +42,7 @@ export async function buildSciChart(
|
|
|
37
42
|
StackedMountainCollection,
|
|
38
43
|
NumericAxis,
|
|
39
44
|
DateTimeNumericAxis,
|
|
45
|
+
ENumericFormat,
|
|
40
46
|
EAutoRange,
|
|
41
47
|
EAxisAlignment,
|
|
42
48
|
ECoordinateMode,
|
|
@@ -65,20 +71,37 @@ export async function buildSciChart(
|
|
|
65
71
|
VerticalLineAnnotation
|
|
66
72
|
} = SciChart
|
|
67
73
|
|
|
74
|
+
class LocalTimeLabelProvider extends SmartDateLabelProvider {
|
|
75
|
+
formatLabel(value: number): string {
|
|
76
|
+
const date = new Date(value)
|
|
77
|
+
return new Intl.DateTimeFormat('default', {
|
|
78
|
+
year: 'numeric',
|
|
79
|
+
month: '2-digit',
|
|
80
|
+
day: '2-digit',
|
|
81
|
+
hour: '2-digit',
|
|
82
|
+
minute: '2-digit',
|
|
83
|
+
second: '2-digit'
|
|
84
|
+
}).format(date)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
68
88
|
const { type: chartType, options, data: fromData } = config
|
|
69
89
|
const { datasets = [] } = fromData || {}
|
|
70
90
|
var {
|
|
71
91
|
theme,
|
|
72
|
-
tooltip,
|
|
73
|
-
animation,
|
|
74
|
-
legend
|
|
92
|
+
tooltip = true,
|
|
93
|
+
animation = true,
|
|
94
|
+
legend = {
|
|
95
|
+
display: true,
|
|
96
|
+
position: 'top'
|
|
97
|
+
},
|
|
75
98
|
scales: fromScales,
|
|
76
|
-
xGridLine,
|
|
77
|
-
yGridLine,
|
|
78
|
-
y2ndGridLine,
|
|
79
|
-
stacked,
|
|
80
|
-
multiAxis,
|
|
81
|
-
annotations
|
|
99
|
+
xGridLine = true,
|
|
100
|
+
yGridLine = true,
|
|
101
|
+
y2ndGridLine = false,
|
|
102
|
+
stacked = false,
|
|
103
|
+
multiAxis = false,
|
|
104
|
+
annotations = []
|
|
82
105
|
} = options || {}
|
|
83
106
|
|
|
84
107
|
var baseColor = getBaseColorFromTheme(theme)
|
|
@@ -111,6 +134,15 @@ export async function buildSciChart(
|
|
|
111
134
|
display = !!axisTitle
|
|
112
135
|
} = ticks || {}
|
|
113
136
|
|
|
137
|
+
const labelProvider = new SmartDateLabelProvider({
|
|
138
|
+
labelFormat: ENumericFormat.Date_HHMMSS,
|
|
139
|
+
showWiderDateOnFirstLabel: true,
|
|
140
|
+
showYearOnWiderDate: true,
|
|
141
|
+
dateOffset: getLocalTimeOffset()
|
|
142
|
+
})
|
|
143
|
+
|
|
144
|
+
labelProvider.cursorNumericFormat = ENumericFormat.Date_DDMMHHMM
|
|
145
|
+
|
|
114
146
|
const xAxis = new DateTimeNumericAxis(wasmContext, {
|
|
115
147
|
axisTitle,
|
|
116
148
|
autoRange: autoMin || autoMax ? EAutoRange.Always : undefined,
|
|
@@ -128,7 +160,7 @@ export async function buildSciChart(
|
|
|
128
160
|
fontSize,
|
|
129
161
|
color: textStrokeColor
|
|
130
162
|
},
|
|
131
|
-
labelProvider
|
|
163
|
+
labelProvider
|
|
132
164
|
})
|
|
133
165
|
|
|
134
166
|
sciChartSurface.xAxes.add(xAxis)
|
|
@@ -325,7 +357,7 @@ export async function buildSciChart(
|
|
|
325
357
|
|
|
326
358
|
if (annotations) {
|
|
327
359
|
annotations.forEach(annotation => {
|
|
328
|
-
let sciAnnotation
|
|
360
|
+
let sciAnnotation
|
|
329
361
|
let horizontalAnchorPoint =
|
|
330
362
|
annotation.horizontalAnchorPoint == 'Right'
|
|
331
363
|
? EHorizontalAnchorPoint.Right
|
|
@@ -349,7 +381,9 @@ export async function buildSciChart(
|
|
|
349
381
|
verticalAnchorPoint,
|
|
350
382
|
fontSize: annotation.fontSize,
|
|
351
383
|
fontFamily: annotation.fontFamily,
|
|
352
|
-
textColor: convertColor(annotation.stroke, fontColor)
|
|
384
|
+
textColor: convertColor(annotation.stroke, fontColor),
|
|
385
|
+
xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
|
|
386
|
+
yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
|
|
353
387
|
})
|
|
354
388
|
break
|
|
355
389
|
case 'line':
|
|
@@ -360,8 +394,8 @@ export async function buildSciChart(
|
|
|
360
394
|
y2: annotation.y2,
|
|
361
395
|
stroke: convertColor(annotation.stroke, '#FF0000'),
|
|
362
396
|
strokeThickness: annotation.strokeThickness,
|
|
363
|
-
xCoordinateMode: ECoordinateMode.
|
|
364
|
-
yCoordinateMode: ECoordinateMode.DataValue
|
|
397
|
+
xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
|
|
398
|
+
yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
|
|
365
399
|
})
|
|
366
400
|
break
|
|
367
401
|
case 'box':
|
|
@@ -372,28 +406,37 @@ export async function buildSciChart(
|
|
|
372
406
|
y2: annotation.y2,
|
|
373
407
|
fill: convertColor(annotation.fill, '#FF0000'),
|
|
374
408
|
stroke: convertColor(annotation.stroke, '#FF0000'),
|
|
375
|
-
strokeThickness: annotation.strokeThickness
|
|
409
|
+
strokeThickness: annotation.strokeThickness,
|
|
410
|
+
xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
|
|
411
|
+
yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
|
|
376
412
|
})
|
|
377
413
|
break
|
|
378
414
|
case 'horizontalLine':
|
|
379
415
|
sciAnnotation = new HorizontalLineAnnotation({
|
|
380
416
|
y1: annotation.y1,
|
|
381
417
|
stroke: convertColor(annotation.stroke, '#FF0000'),
|
|
382
|
-
strokeThickness: annotation.strokeThickness
|
|
418
|
+
strokeThickness: annotation.strokeThickness,
|
|
419
|
+
xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
|
|
420
|
+
yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
|
|
383
421
|
})
|
|
384
422
|
break
|
|
385
423
|
case 'verticalLine':
|
|
386
424
|
sciAnnotation = new VerticalLineAnnotation({
|
|
387
425
|
x1: annotation.x1,
|
|
388
426
|
stroke: convertColor(annotation.stroke, '#FF0000'),
|
|
389
|
-
strokeThickness: annotation.strokeThickness
|
|
427
|
+
strokeThickness: annotation.strokeThickness,
|
|
428
|
+
xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
|
|
429
|
+
yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
|
|
390
430
|
})
|
|
391
431
|
break
|
|
392
432
|
default:
|
|
433
|
+
console.error('Unknown annotation type:', annotation.type)
|
|
393
434
|
break
|
|
394
435
|
}
|
|
395
436
|
if (sciAnnotation) {
|
|
396
437
|
sciChartSurface.annotations.add(sciAnnotation)
|
|
438
|
+
} else {
|
|
439
|
+
console.error('Failed to create annotation:', annotation)
|
|
397
440
|
}
|
|
398
441
|
})
|
|
399
442
|
}
|
package/src/types.d.ts
CHANGED
|
@@ -95,8 +95,8 @@ declare namespace OperatoChart {
|
|
|
95
95
|
|
|
96
96
|
export interface Annotation {
|
|
97
97
|
type: AnnotationType
|
|
98
|
-
x1
|
|
99
|
-
y1
|
|
98
|
+
x1?: number
|
|
99
|
+
y1?: number
|
|
100
100
|
x2?: number
|
|
101
101
|
y2?: number
|
|
102
102
|
stroke?: string
|
|
@@ -105,8 +105,10 @@ declare namespace OperatoChart {
|
|
|
105
105
|
text?: string
|
|
106
106
|
horizontalAnchorPoint?: 'Left' | 'Center' | 'Right'
|
|
107
107
|
verticalAnchorPoint?: 'Top' | 'Center' | 'Bottom'
|
|
108
|
+
xCoordinateMode?: 'DataValue' | 'Pixel' | 'Relative'
|
|
109
|
+
yCoordinateMode?: 'DataValue' | 'Pixel' | 'Relative'
|
|
108
110
|
[key: string]: any
|
|
109
111
|
}
|
|
110
112
|
|
|
111
|
-
export type AnnotationType = 'line' | 'text' | 'box' | 'horizontalLine' | 'verticalLine' |
|
|
113
|
+
export type AnnotationType = 'line' | 'text' | 'box' | 'horizontalLine' | 'verticalLine' | undefined
|
|
112
114
|
}
|
|
@@ -211,7 +211,58 @@ MultiAxis.args = {
|
|
|
211
211
|
]
|
|
212
212
|
},
|
|
213
213
|
multiAxis: true,
|
|
214
|
-
legend: { display: true }
|
|
214
|
+
legend: { display: true },
|
|
215
|
+
annotations: [
|
|
216
|
+
{
|
|
217
|
+
type: 'line',
|
|
218
|
+
x1: 0,
|
|
219
|
+
y1: -10,
|
|
220
|
+
x2: 1,
|
|
221
|
+
y2: 10,
|
|
222
|
+
stroke: 'red',
|
|
223
|
+
strokeThickness: 5,
|
|
224
|
+
xCoordinateMode: 'Relative',
|
|
225
|
+
yCoordinateMode: 'DataValue'
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
type: 'text',
|
|
229
|
+
x1: 0.5,
|
|
230
|
+
y1: 0,
|
|
231
|
+
text: 'Hello',
|
|
232
|
+
fontSize: 50,
|
|
233
|
+
stroke: 'blue',
|
|
234
|
+
xCoordinateMode: 'Relative',
|
|
235
|
+
yCoordinateMode: 'DataValue'
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
type: 'box',
|
|
239
|
+
x1: 0.2,
|
|
240
|
+
y1: 10,
|
|
241
|
+
x2: 0.5,
|
|
242
|
+
y2: 20,
|
|
243
|
+
fill: 'green',
|
|
244
|
+
stroke: 'blue',
|
|
245
|
+
strokeThickness: 10,
|
|
246
|
+
xCoordinateMode: 'Relative',
|
|
247
|
+
yCoordinateMode: 'DataValue'
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
type: 'horizontalLine',
|
|
251
|
+
y1: 20,
|
|
252
|
+
stroke: 'purple',
|
|
253
|
+
strokeThickness: 5,
|
|
254
|
+
xCoordinateMode: 'Relative',
|
|
255
|
+
yCoordinateMode: 'DataValue'
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
type: 'verticalLine',
|
|
259
|
+
x1: 0.8,
|
|
260
|
+
stroke: 'orange',
|
|
261
|
+
strokeThickness: 5,
|
|
262
|
+
xCoordinateMode: 'Relative',
|
|
263
|
+
yCoordinateMode: 'DataValue'
|
|
264
|
+
}
|
|
265
|
+
]
|
|
215
266
|
}
|
|
216
267
|
}
|
|
217
268
|
}
|