@operato/chart 7.0.29 → 7.0.31
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 +18 -0
- package/dist/src/editors/input-chart-abstract.js +29 -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 +45 -9
- 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 +4 -4
- package/src/editors/input-chart-abstract.ts +29 -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 +49 -9
- 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,6 +71,20 @@ 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 {
|
|
@@ -111,6 +131,15 @@ export async function buildSciChart(
|
|
|
111
131
|
display = !!axisTitle
|
|
112
132
|
} = ticks || {}
|
|
113
133
|
|
|
134
|
+
const labelProvider = new SmartDateLabelProvider({
|
|
135
|
+
labelFormat: ENumericFormat.Date_HHMMSS,
|
|
136
|
+
showWiderDateOnFirstLabel: true,
|
|
137
|
+
showYearOnWiderDate: true,
|
|
138
|
+
dateOffset: getLocalTimeOffset()
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
labelProvider.cursorNumericFormat = ENumericFormat.Date_DDMMHHMM
|
|
142
|
+
|
|
114
143
|
const xAxis = new DateTimeNumericAxis(wasmContext, {
|
|
115
144
|
axisTitle,
|
|
116
145
|
autoRange: autoMin || autoMax ? EAutoRange.Always : undefined,
|
|
@@ -128,7 +157,7 @@ export async function buildSciChart(
|
|
|
128
157
|
fontSize,
|
|
129
158
|
color: textStrokeColor
|
|
130
159
|
},
|
|
131
|
-
labelProvider
|
|
160
|
+
labelProvider
|
|
132
161
|
})
|
|
133
162
|
|
|
134
163
|
sciChartSurface.xAxes.add(xAxis)
|
|
@@ -325,7 +354,7 @@ export async function buildSciChart(
|
|
|
325
354
|
|
|
326
355
|
if (annotations) {
|
|
327
356
|
annotations.forEach(annotation => {
|
|
328
|
-
let sciAnnotation
|
|
357
|
+
let sciAnnotation
|
|
329
358
|
let horizontalAnchorPoint =
|
|
330
359
|
annotation.horizontalAnchorPoint == 'Right'
|
|
331
360
|
? EHorizontalAnchorPoint.Right
|
|
@@ -349,7 +378,9 @@ export async function buildSciChart(
|
|
|
349
378
|
verticalAnchorPoint,
|
|
350
379
|
fontSize: annotation.fontSize,
|
|
351
380
|
fontFamily: annotation.fontFamily,
|
|
352
|
-
textColor: convertColor(annotation.stroke, fontColor)
|
|
381
|
+
textColor: convertColor(annotation.stroke, fontColor),
|
|
382
|
+
xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
|
|
383
|
+
yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
|
|
353
384
|
})
|
|
354
385
|
break
|
|
355
386
|
case 'line':
|
|
@@ -360,8 +391,8 @@ export async function buildSciChart(
|
|
|
360
391
|
y2: annotation.y2,
|
|
361
392
|
stroke: convertColor(annotation.stroke, '#FF0000'),
|
|
362
393
|
strokeThickness: annotation.strokeThickness,
|
|
363
|
-
xCoordinateMode: ECoordinateMode.
|
|
364
|
-
yCoordinateMode: ECoordinateMode.DataValue
|
|
394
|
+
xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
|
|
395
|
+
yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
|
|
365
396
|
})
|
|
366
397
|
break
|
|
367
398
|
case 'box':
|
|
@@ -372,28 +403,37 @@ export async function buildSciChart(
|
|
|
372
403
|
y2: annotation.y2,
|
|
373
404
|
fill: convertColor(annotation.fill, '#FF0000'),
|
|
374
405
|
stroke: convertColor(annotation.stroke, '#FF0000'),
|
|
375
|
-
strokeThickness: annotation.strokeThickness
|
|
406
|
+
strokeThickness: annotation.strokeThickness,
|
|
407
|
+
xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
|
|
408
|
+
yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
|
|
376
409
|
})
|
|
377
410
|
break
|
|
378
411
|
case 'horizontalLine':
|
|
379
412
|
sciAnnotation = new HorizontalLineAnnotation({
|
|
380
413
|
y1: annotation.y1,
|
|
381
414
|
stroke: convertColor(annotation.stroke, '#FF0000'),
|
|
382
|
-
strokeThickness: annotation.strokeThickness
|
|
415
|
+
strokeThickness: annotation.strokeThickness,
|
|
416
|
+
xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
|
|
417
|
+
yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
|
|
383
418
|
})
|
|
384
419
|
break
|
|
385
420
|
case 'verticalLine':
|
|
386
421
|
sciAnnotation = new VerticalLineAnnotation({
|
|
387
422
|
x1: annotation.x1,
|
|
388
423
|
stroke: convertColor(annotation.stroke, '#FF0000'),
|
|
389
|
-
strokeThickness: annotation.strokeThickness
|
|
424
|
+
strokeThickness: annotation.strokeThickness,
|
|
425
|
+
xCoordinateMode: annotation.xCoordinateMode || ECoordinateMode.DataValue,
|
|
426
|
+
yCoordinateMode: annotation.yCoordinateMode || ECoordinateMode.DataValue
|
|
390
427
|
})
|
|
391
428
|
break
|
|
392
429
|
default:
|
|
430
|
+
console.error('Unknown annotation type:', annotation.type)
|
|
393
431
|
break
|
|
394
432
|
}
|
|
395
433
|
if (sciAnnotation) {
|
|
396
434
|
sciChartSurface.annotations.add(sciAnnotation)
|
|
435
|
+
} else {
|
|
436
|
+
console.error('Failed to create annotation:', annotation)
|
|
397
437
|
}
|
|
398
438
|
})
|
|
399
439
|
}
|
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
|
}
|