@operato/chart 7.0.0 → 7.0.2
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 +21 -0
- package/dist/src/chartjs/config-converter.js +7 -1
- package/dist/src/chartjs/config-converter.js.map +1 -1
- package/dist/src/editors/configurer.d.ts +2 -2
- package/dist/src/editors/configurer.js +0 -1
- package/dist/src/editors/configurer.js.map +1 -1
- package/dist/src/editors/input-chart-abstract.js +3 -2
- package/dist/src/editors/input-chart-abstract.js.map +1 -1
- package/dist/src/progress/ox-progress-circle.d.ts +41 -0
- package/dist/src/progress/ox-progress-circle.js +169 -0
- package/dist/src/progress/ox-progress-circle.js.map +1 -0
- package/dist/src/scichart/ox-scichart.d.ts +4 -2
- package/dist/src/scichart/ox-scichart.js +77 -23
- package/dist/src/scichart/ox-scichart.js.map +1 -1
- package/dist/src/scichart/scichart-builder.d.ts +1 -1
- package/dist/src/scichart/scichart-builder.js +216 -22
- package/dist/src/scichart/scichart-builder.js.map +1 -1
- package/dist/stories/common.d.ts +1 -1
- package/dist/stories/common.js +31 -9
- package/dist/stories/common.js.map +1 -1
- package/dist/stories/ox-input-chart-bar.stories.js +32 -47
- package/dist/stories/ox-input-chart-bar.stories.js.map +1 -1
- package/dist/stories/ox-input-chart-doughnut.stories.js +1 -1
- package/dist/stories/ox-input-chart-doughnut.stories.js.map +1 -1
- package/dist/stories/ox-input-chart-hbar.stories.js +1 -1
- package/dist/stories/ox-input-chart-hbar.stories.js.map +1 -1
- package/dist/stories/ox-input-chart-line.stories.js +1 -1
- package/dist/stories/ox-input-chart-line.stories.js.map +1 -1
- package/dist/stories/ox-input-chart-pie.stories.js +1 -1
- package/dist/stories/ox-input-chart-pie.stories.js.map +1 -1
- package/dist/stories/ox-input-chart-polar-area.stories.js +1 -1
- package/dist/stories/ox-input-chart-polar-area.stories.js.map +1 -1
- package/dist/stories/ox-input-chart-radar.stories.js +1 -1
- package/dist/stories/ox-input-chart-radar.stories.js.map +1 -1
- package/dist/stories/ox-input-chart-timeseries.stories.js +77 -53
- package/dist/stories/ox-input-chart-timeseries.stories.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/chartjs/config-converter.ts +12 -4
- package/src/editors/configurer.ts +0 -1
- package/src/editors/input-chart-abstract.ts +3 -2
- package/src/progress/ox-progress-circle.ts +133 -0
- package/src/scichart/custom-point-markers.ts.xxx +178 -0
- package/src/scichart/ox-scichart.ts +83 -32
- package/src/scichart/scichart-builder.ts +272 -34
- package/src/types.d.ts +14 -2
- package/stories/common.ts +36 -9
- package/stories/ox-input-chart-bar.stories.ts +31 -45
- package/stories/ox-input-chart-doughnut.stories.ts +1 -1
- package/stories/ox-input-chart-hbar.stories.ts +1 -1
- package/stories/ox-input-chart-line.stories.ts +1 -1
- package/stories/ox-input-chart-pie.stories.ts +1 -1
- package/stories/ox-input-chart-polar-area.stories.ts +1 -1
- package/stories/ox-input-chart-radar.stories.ts +1 -1
- package/stories/ox-input-chart-timeseries.stories.ts +76 -51
|
@@ -1,87 +1,325 @@
|
|
|
1
|
+
import { TinyColor } from '@ctrl/tinycolor'
|
|
2
|
+
import { format as formatText } from '../utils/text-formatter'
|
|
3
|
+
|
|
4
|
+
function getBaseColorFromTheme(theme?: 'light' | 'dark' | 'auto') {
|
|
5
|
+
return new TinyColor(theme == 'dark' ? '#fff' : '#000')
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
function getThemeFromBrowser() {
|
|
9
|
+
return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
|
|
10
|
+
}
|
|
11
|
+
|
|
1
12
|
export async function buildSciChart(
|
|
2
13
|
config: OperatoChart.ChartConfig | undefined | null,
|
|
3
14
|
container: any,
|
|
4
15
|
{ fontSize, fontFamily, fontColor }: { fontSize?: number; fontFamily?: string; fontColor?: string }
|
|
5
|
-
): Promise<{ chart: any; dataSeries: any } | undefined> {
|
|
16
|
+
): Promise<{ chart: any; dataSeries: any[] } | undefined> {
|
|
6
17
|
if (!config) {
|
|
7
18
|
return
|
|
8
19
|
}
|
|
9
20
|
|
|
10
21
|
const {
|
|
11
22
|
SciChartSurface,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
SciChartJsNavyTheme,
|
|
23
|
+
SciChartJSLightTheme,
|
|
24
|
+
SciChartJSDarkv2Theme,
|
|
15
25
|
XyDataSeries,
|
|
16
26
|
FastLineRenderableSeries,
|
|
17
|
-
|
|
27
|
+
SplineLineRenderableSeries,
|
|
28
|
+
FastColumnRenderableSeries,
|
|
29
|
+
StackedColumnRenderableSeries,
|
|
30
|
+
StackedMountainRenderableSeries,
|
|
31
|
+
StackedColumnCollection,
|
|
32
|
+
StackedMountainCollection,
|
|
33
|
+
NumericAxis,
|
|
34
|
+
DateTimeNumericAxis,
|
|
18
35
|
EAutoRange,
|
|
19
36
|
EAxisAlignment,
|
|
20
|
-
|
|
21
|
-
|
|
37
|
+
NumberRange,
|
|
38
|
+
MouseWheelZoomModifier,
|
|
39
|
+
RubberBandXyZoomModifier,
|
|
40
|
+
ZoomExtentsModifier,
|
|
41
|
+
RolloverModifier,
|
|
42
|
+
SmartDateLabelProvider,
|
|
43
|
+
EllipsePointMarker,
|
|
44
|
+
SquarePointMarker,
|
|
45
|
+
TrianglePointMarker,
|
|
46
|
+
CrossPointMarker,
|
|
47
|
+
XPointMarker,
|
|
48
|
+
WaveAnimation,
|
|
49
|
+
LegendModifier
|
|
22
50
|
} = SciChart
|
|
23
51
|
|
|
24
52
|
const { type: chartType, options, data: fromData } = config
|
|
25
|
-
const {
|
|
53
|
+
const { datasets = [] } = fromData || {}
|
|
54
|
+
var {
|
|
26
55
|
theme,
|
|
27
|
-
animation,
|
|
28
56
|
tooltip,
|
|
29
|
-
|
|
57
|
+
animation,
|
|
30
58
|
legend,
|
|
31
59
|
scales: fromScales,
|
|
32
60
|
xGridLine,
|
|
33
61
|
yGridLine,
|
|
34
62
|
y2ndGridLine,
|
|
35
|
-
|
|
63
|
+
stacked
|
|
36
64
|
} = options || {}
|
|
37
|
-
|
|
65
|
+
|
|
66
|
+
var baseColor = getBaseColorFromTheme(theme)
|
|
67
|
+
|
|
68
|
+
if (theme === 'auto') {
|
|
69
|
+
theme = getThemeFromBrowser()
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
fontColor = fontColor || baseColor.clone().toString()
|
|
38
73
|
|
|
39
74
|
const { xAxes = [], yAxes = [] } = fromScales || {}
|
|
40
|
-
const toScales = {} as any
|
|
41
75
|
|
|
42
76
|
const chart = await SciChartSurface.create(container, {
|
|
43
|
-
theme: new
|
|
77
|
+
theme: theme == 'dark' ? new SciChartJSDarkv2Theme() : new SciChartJSLightTheme()
|
|
44
78
|
})
|
|
45
79
|
const { sciChartSurface, wasmContext } = chart
|
|
46
80
|
|
|
81
|
+
// X 축 설정
|
|
47
82
|
xAxes.forEach((axis, index) => {
|
|
48
|
-
const { axisTitle,
|
|
49
|
-
const {
|
|
50
|
-
|
|
83
|
+
const { axisTitle, ticks } = axis
|
|
84
|
+
const {
|
|
85
|
+
autoMax,
|
|
86
|
+
autoMin,
|
|
87
|
+
min,
|
|
88
|
+
max,
|
|
89
|
+
stepSize,
|
|
90
|
+
beginAtZero,
|
|
91
|
+
color = fontColor,
|
|
92
|
+
textStrokeColor = fontColor,
|
|
93
|
+
display = !!axisTitle
|
|
94
|
+
} = ticks || {}
|
|
51
95
|
|
|
52
96
|
const xAxis = new DateTimeNumericAxis(wasmContext, {
|
|
53
97
|
axisTitle,
|
|
54
|
-
autoRange: EAutoRange.Always,
|
|
55
|
-
axisAlignment: EAxisAlignment.Bottom
|
|
56
|
-
|
|
57
|
-
|
|
98
|
+
autoRange: autoMin || autoMax ? EAutoRange.Always : undefined,
|
|
99
|
+
axisAlignment: EAxisAlignment.Bottom,
|
|
100
|
+
visibleRange: min !== undefined && max !== undefined ? new NumberRange(min, max) : undefined,
|
|
101
|
+
majorDelta: stepSize,
|
|
102
|
+
growBy: beginAtZero ? new NumberRange(0.1, 0.1) : undefined,
|
|
103
|
+
labelStyle: {
|
|
104
|
+
fontFamily,
|
|
105
|
+
fontSize,
|
|
106
|
+
color
|
|
107
|
+
},
|
|
108
|
+
axisTitleStyle: {
|
|
109
|
+
fontFamily,
|
|
110
|
+
fontSize,
|
|
111
|
+
color: textStrokeColor
|
|
112
|
+
},
|
|
113
|
+
labelProvider: new SmartDateLabelProvider()
|
|
58
114
|
})
|
|
59
115
|
|
|
60
116
|
sciChartSurface.xAxes.add(xAxis)
|
|
61
117
|
})
|
|
62
118
|
|
|
119
|
+
// Y 축 설정
|
|
63
120
|
yAxes.forEach((axis, index) => {
|
|
64
|
-
const { axisTitle,
|
|
65
|
-
const { autoMax, autoMin } = ticks || {}
|
|
66
|
-
|
|
67
|
-
const id = yAxes.length > 1 ? `right` : 'left'
|
|
121
|
+
const { axisTitle, ticks } = axis
|
|
122
|
+
const { autoMax, autoMin, min, max, stepSize, beginAtZero } = ticks || {}
|
|
68
123
|
|
|
69
124
|
const yAxis = new NumericAxis(wasmContext, {
|
|
125
|
+
id: `yAxis${index}`,
|
|
70
126
|
axisTitle,
|
|
71
|
-
autoRange: EAutoRange.Always,
|
|
72
|
-
axisAlignment:
|
|
127
|
+
autoRange: autoMin || autoMax ? EAutoRange.Always : undefined,
|
|
128
|
+
axisAlignment: index === 0 ? EAxisAlignment.Left : EAxisAlignment.Right,
|
|
129
|
+
visibleRange: min !== undefined && max !== undefined ? new NumberRange(min, max) : undefined,
|
|
130
|
+
majorDelta: stepSize,
|
|
131
|
+
growBy: beginAtZero ? new NumberRange(0.1, 0.1) : undefined,
|
|
132
|
+
labelStyle: {
|
|
133
|
+
fontFamily,
|
|
134
|
+
fontSize,
|
|
135
|
+
color: fontColor
|
|
136
|
+
},
|
|
137
|
+
axisTitleStyle: {
|
|
138
|
+
fontFamily,
|
|
139
|
+
fontSize,
|
|
140
|
+
color: fontColor
|
|
141
|
+
}
|
|
73
142
|
})
|
|
143
|
+
|
|
74
144
|
sciChartSurface.yAxes.add(yAxis)
|
|
75
145
|
})
|
|
76
146
|
|
|
77
|
-
|
|
147
|
+
// 시리즈 설정
|
|
148
|
+
const dataSeriesArray = datasets.map((dataset, index) => {
|
|
149
|
+
const dataSeries = new XyDataSeries(wasmContext, {
|
|
150
|
+
dataSeriesName: dataset.label,
|
|
151
|
+
containsNaN: false
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
const yAxisId = dataset.yAxisID || 'yAxis0'
|
|
155
|
+
const stackGroupId = dataset.stack || `__stack${index}__`
|
|
156
|
+
|
|
157
|
+
let series: any
|
|
158
|
+
if (dataset.type === 'bar') {
|
|
159
|
+
if (stacked) {
|
|
160
|
+
series = new StackedColumnRenderableSeries(wasmContext, {
|
|
161
|
+
dataSeries,
|
|
162
|
+
strokeThickness: dataset.borderWidth || 2,
|
|
163
|
+
fill: dataset.backgroundColor || '#FF6600',
|
|
164
|
+
yAxisId,
|
|
165
|
+
stackedGroupId: stackGroupId
|
|
166
|
+
})
|
|
167
|
+
} else {
|
|
168
|
+
series = new FastColumnRenderableSeries(wasmContext, {
|
|
169
|
+
dataSeries,
|
|
170
|
+
strokeThickness: dataset.borderWidth || 2,
|
|
171
|
+
fill: dataset.backgroundColor || '#FF6600',
|
|
172
|
+
animation: animation && new WaveAnimation({ duration: 1000, fadeEffect: true }),
|
|
173
|
+
yAxisId
|
|
174
|
+
})
|
|
175
|
+
}
|
|
176
|
+
} else {
|
|
177
|
+
const { pointStyle, lineTension } = dataset
|
|
178
|
+
let pointMarker
|
|
179
|
+
|
|
180
|
+
switch (pointStyle) {
|
|
181
|
+
case 'circle':
|
|
182
|
+
pointMarker = new EllipsePointMarker(wasmContext, {
|
|
183
|
+
width: 10,
|
|
184
|
+
height: 10,
|
|
185
|
+
strokeThickness: 2,
|
|
186
|
+
fill: dataset.color || '#FF6600',
|
|
187
|
+
stroke: '#000000'
|
|
188
|
+
})
|
|
189
|
+
break
|
|
190
|
+
case 'triangle':
|
|
191
|
+
pointMarker = new TrianglePointMarker(wasmContext, {
|
|
192
|
+
width: 10,
|
|
193
|
+
height: 10,
|
|
194
|
+
strokeThickness: 2,
|
|
195
|
+
fill: dataset.color || '#FF6600',
|
|
196
|
+
stroke: '#000000'
|
|
197
|
+
})
|
|
198
|
+
break
|
|
199
|
+
case 'rect':
|
|
200
|
+
pointMarker = new SquarePointMarker(wasmContext, {
|
|
201
|
+
width: 10,
|
|
202
|
+
height: 10,
|
|
203
|
+
strokeThickness: 2,
|
|
204
|
+
fill: dataset.color || '#FF6600',
|
|
205
|
+
stroke: '#000000'
|
|
206
|
+
})
|
|
207
|
+
break
|
|
208
|
+
case 'cross':
|
|
209
|
+
pointMarker = new CrossPointMarker(wasmContext, {
|
|
210
|
+
width: 10,
|
|
211
|
+
height: 10,
|
|
212
|
+
strokeThickness: 2,
|
|
213
|
+
fill: dataset.color || '#FF6600',
|
|
214
|
+
stroke: '#000000'
|
|
215
|
+
})
|
|
216
|
+
break
|
|
217
|
+
case 'crossRot':
|
|
218
|
+
pointMarker = new XPointMarker(wasmContext, {
|
|
219
|
+
width: 10,
|
|
220
|
+
height: 10,
|
|
221
|
+
strokeThickness: 2,
|
|
222
|
+
fill: dataset.color || '#FF6600',
|
|
223
|
+
stroke: '#000000'
|
|
224
|
+
})
|
|
225
|
+
break
|
|
226
|
+
default:
|
|
227
|
+
pointMarker = new EllipsePointMarker(wasmContext, {
|
|
228
|
+
width: 10,
|
|
229
|
+
height: 10,
|
|
230
|
+
strokeThickness: 2,
|
|
231
|
+
fill: dataset.color || '#FF6600',
|
|
232
|
+
stroke: '#000000'
|
|
233
|
+
})
|
|
234
|
+
}
|
|
78
235
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
236
|
+
if (stacked) {
|
|
237
|
+
series = new StackedMountainRenderableSeries(wasmContext, {
|
|
238
|
+
dataSeries,
|
|
239
|
+
strokeThickness: dataset.borderWidth || 2,
|
|
240
|
+
stroke: dataset.color || '#FF6600',
|
|
241
|
+
fill: dataset.backgroundColor || '#FF6600',
|
|
242
|
+
yAxisId,
|
|
243
|
+
stackedGroupId: stackGroupId
|
|
244
|
+
})
|
|
245
|
+
} else {
|
|
246
|
+
series =
|
|
247
|
+
!!lineTension && lineTension > 0
|
|
248
|
+
? new SplineLineRenderableSeries(wasmContext, {
|
|
249
|
+
dataSeries,
|
|
250
|
+
strokeThickness: dataset.borderWidth || 2,
|
|
251
|
+
stroke: dataset.color || '#FF6600',
|
|
252
|
+
pointMarker,
|
|
253
|
+
animation: animation && new WaveAnimation({ duration: 1000, fadeEffect: true }),
|
|
254
|
+
yAxisId
|
|
255
|
+
})
|
|
256
|
+
: new FastLineRenderableSeries(wasmContext, {
|
|
257
|
+
dataSeries,
|
|
258
|
+
strokeThickness: dataset.borderWidth || 2,
|
|
259
|
+
stroke: dataset.color || '#FF6600',
|
|
260
|
+
pointMarker,
|
|
261
|
+
animation: animation && new WaveAnimation({ duration: 1000, fadeEffect: true }),
|
|
262
|
+
yAxisId
|
|
263
|
+
})
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
sciChartSurface.renderableSeries.add(series)
|
|
268
|
+
|
|
269
|
+
if (tooltip) {
|
|
270
|
+
const rolloverModifier = new RolloverModifier({
|
|
271
|
+
showTooltip: true,
|
|
272
|
+
showAxisLabels: true,
|
|
273
|
+
tooltipColor: 'white',
|
|
274
|
+
tooltipBackgroundColor: 'rgba(0, 0, 0, 0.7)',
|
|
275
|
+
rollOverDataSeries: dataSeries
|
|
276
|
+
})
|
|
277
|
+
|
|
278
|
+
sciChartSurface.chartModifiers.add(rolloverModifier)
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return dataSeries
|
|
282
|
+
})
|
|
83
283
|
|
|
84
|
-
|
|
284
|
+
// Stacked collections 추가
|
|
285
|
+
if (stacked) {
|
|
286
|
+
const stackedColumnCollection = new StackedColumnCollection(wasmContext)
|
|
287
|
+
const stackedMountainCollection = new StackedMountainCollection(wasmContext)
|
|
288
|
+
|
|
289
|
+
sciChartSurface.renderableSeries.asArray().forEach((series: any) => {
|
|
290
|
+
if (series instanceof StackedColumnRenderableSeries) {
|
|
291
|
+
stackedColumnCollection.add(series)
|
|
292
|
+
} else if (series instanceof StackedMountainRenderableSeries) {
|
|
293
|
+
stackedMountainCollection.add(series)
|
|
294
|
+
}
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
if (stackedColumnCollection.size() > 0) {
|
|
298
|
+
sciChartSurface.renderableSeries.add(stackedColumnCollection)
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (stackedMountainCollection.size() > 0) {
|
|
302
|
+
sciChartSurface.renderableSeries.add(stackedMountainCollection)
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// 줌인/줌아웃 모디파이어 추가
|
|
307
|
+
sciChartSurface.chartModifiers.add(
|
|
308
|
+
new RubberBandXyZoomModifier(),
|
|
309
|
+
new MouseWheelZoomModifier(),
|
|
310
|
+
new ZoomExtentsModifier()
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
// Legend 설정
|
|
314
|
+
if (legend?.display) {
|
|
315
|
+
const legendModifier = new LegendModifier({
|
|
316
|
+
showCheckboxes: true,
|
|
317
|
+
showSeriesMarkers: true,
|
|
318
|
+
showLegend: true,
|
|
319
|
+
placement: legend.position || 'bottom-right'
|
|
320
|
+
})
|
|
321
|
+
sciChartSurface.chartModifiers.add(legendModifier)
|
|
322
|
+
}
|
|
85
323
|
|
|
86
|
-
return { chart, dataSeries }
|
|
324
|
+
return { chart, dataSeries: dataSeriesArray }
|
|
87
325
|
}
|
package/src/types.d.ts
CHANGED
|
@@ -24,7 +24,17 @@ declare namespace OperatoChart {
|
|
|
24
24
|
stack?: string
|
|
25
25
|
fill?: boolean
|
|
26
26
|
lineTension?: number
|
|
27
|
-
pointStyle?:
|
|
27
|
+
pointStyle?:
|
|
28
|
+
| 'circle'
|
|
29
|
+
| 'triangle'
|
|
30
|
+
| 'rect'
|
|
31
|
+
| 'rectRot'
|
|
32
|
+
| 'cross'
|
|
33
|
+
| 'crossRot'
|
|
34
|
+
| 'star'
|
|
35
|
+
| 'line'
|
|
36
|
+
| 'dash'
|
|
37
|
+
| undefined
|
|
28
38
|
pointRadius?: number
|
|
29
39
|
valuePrefix?: string
|
|
30
40
|
valueSuffix?: string
|
|
@@ -34,7 +44,7 @@ declare namespace OperatoChart {
|
|
|
34
44
|
}
|
|
35
45
|
|
|
36
46
|
export interface ChartOptions {
|
|
37
|
-
theme?: 'dark' | 'light'
|
|
47
|
+
theme?: 'dark' | 'light' | 'auto'
|
|
38
48
|
tooltip?: boolean
|
|
39
49
|
animation?: boolean
|
|
40
50
|
legend?: LegendOptions
|
|
@@ -74,5 +84,7 @@ declare namespace OperatoChart {
|
|
|
74
84
|
max?: number
|
|
75
85
|
stepSize?: number
|
|
76
86
|
beginAtZero?: boolean
|
|
87
|
+
color?: string
|
|
88
|
+
textStrokeColor?: string
|
|
77
89
|
}
|
|
78
90
|
}
|
package/stories/common.ts
CHANGED
|
@@ -46,12 +46,39 @@ export function getDefaultAxisOptions(): OperatoChart.AxisOptions {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export const data = [
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
]
|
|
49
|
+
// export const data = [
|
|
50
|
+
// { timestamp: 2010, count: 10, average: 120 },
|
|
51
|
+
// { timestamp: 2011, count: 20, average: 110 },
|
|
52
|
+
// { timestamp: 2012, count: 15, average: 80 },
|
|
53
|
+
// { timestamp: 2013, count: 25, average: 130 },
|
|
54
|
+
// { timestamp: 2014, count: 22, average: 120 },
|
|
55
|
+
// { timestamp: 2015, count: 30, average: 60 },
|
|
56
|
+
// { timestamp: 2016, count: 28, average: 90 }
|
|
57
|
+
// ]
|
|
58
|
+
// 랜덤한 범위의 숫자를 생성하는 함수
|
|
59
|
+
function getRandomInRange(min: number, max: number) {
|
|
60
|
+
return Math.floor(Math.random() * (max - min + 1)) + min
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 랜덤 데이터를 생성하는 함수
|
|
64
|
+
function generateRandomData(count: number) {
|
|
65
|
+
const randomData = []
|
|
66
|
+
const startTimestamp = Math.floor(Date.now()) // 현재 시간을 Unix 타임스탬프로 설정
|
|
67
|
+
|
|
68
|
+
for (let i = 0; i < count; i++) {
|
|
69
|
+
const timestamp = startTimestamp + i * 360 * 30 * 1000 // 3초씩 증가하는 타임스탬프 설정
|
|
70
|
+
const randomCount = getRandomInRange(5, 35) // count 값을 5에서 35 사이로 랜덤 생성
|
|
71
|
+
const randomAverage = getRandomInRange(50, 150) // average 값을 50에서 150 사이로 랜덤 생성
|
|
72
|
+
|
|
73
|
+
randomData.push({
|
|
74
|
+
timestamp: timestamp,
|
|
75
|
+
count: randomCount,
|
|
76
|
+
average: randomAverage
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return randomData
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// 100개의 랜덤 데이터를 생성
|
|
84
|
+
export const data = generateRandomData(100)
|
|
@@ -24,6 +24,19 @@ interface ArgTypes {
|
|
|
24
24
|
value: OperatoChart.ChartConfig
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
function showCharts(e: Event) {
|
|
28
|
+
const target = e.currentTarget as any
|
|
29
|
+
const config = target.value
|
|
30
|
+
const chartjs = document.querySelector('#chartjs') as HTMLElement
|
|
31
|
+
if (chartjs) {
|
|
32
|
+
;(chartjs as any).config = { ...config }
|
|
33
|
+
}
|
|
34
|
+
const scichart = document.querySelector('#scichart') as HTMLElement
|
|
35
|
+
if (scichart) {
|
|
36
|
+
;(scichart as any).config = config
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
27
40
|
const Template: Story<ArgTypes> = ({ value }: ArgTypes) => html`
|
|
28
41
|
<link
|
|
29
42
|
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL@20..48,100..700,0..1"
|
|
@@ -43,18 +56,21 @@ const Template: Story<ArgTypes> = ({ value }: ArgTypes) => html`
|
|
|
43
56
|
<link href="/themes/spacing.css" rel="stylesheet" />
|
|
44
57
|
|
|
45
58
|
<style>
|
|
46
|
-
.
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
.desc {
|
|
60
|
+
color: var(--md-sys-color-background);
|
|
61
|
+
background-color: var(--md-sys-color-on-background);
|
|
62
|
+
padding: var(--spacing-small);
|
|
63
|
+
}
|
|
49
64
|
|
|
65
|
+
.container {
|
|
50
66
|
display: flex;
|
|
51
67
|
flex-direction: row;
|
|
52
68
|
overflow-y: auto;
|
|
53
69
|
padding: var(--spacing-medium);
|
|
54
|
-
|
|
70
|
+
gap: var(--spacing-medium);
|
|
55
71
|
|
|
56
|
-
|
|
57
|
-
background-color:
|
|
72
|
+
color: var(--md-sys-color-on-background);
|
|
73
|
+
background-color: var(--md-sys-color-background);
|
|
58
74
|
}
|
|
59
75
|
|
|
60
76
|
#editor {
|
|
@@ -66,7 +82,7 @@ const Template: Story<ArgTypes> = ({ value }: ArgTypes) => html`
|
|
|
66
82
|
|
|
67
83
|
display: flex;
|
|
68
84
|
flex-direction: column;
|
|
69
|
-
|
|
85
|
+
gap: var(--spacing-medium);
|
|
70
86
|
}
|
|
71
87
|
|
|
72
88
|
#chartjs {
|
|
@@ -78,40 +94,10 @@ const Template: Story<ArgTypes> = ({ value }: ArgTypes) => html`
|
|
|
78
94
|
}
|
|
79
95
|
</style>
|
|
80
96
|
|
|
81
|
-
<div
|
|
82
|
-
Type 'count' or 'average' for series dataKey, type 'year' for axis's dataKey
|
|
83
|
-
</div>
|
|
97
|
+
<div class="desc">Type 'count' or 'average' for series dataKey, type 'timestamp' for axis's dataKey</div>
|
|
84
98
|
|
|
85
99
|
<div class="container">
|
|
86
|
-
<ox-input-chart-mixed
|
|
87
|
-
chart-type="bar"
|
|
88
|
-
id="editor"
|
|
89
|
-
.value=${value}
|
|
90
|
-
@change=${(e: CustomEvent) => {
|
|
91
|
-
const target = e.currentTarget as any
|
|
92
|
-
const config = target.value
|
|
93
|
-
const chartjs = document.querySelector('#chartjs') as HTMLElement
|
|
94
|
-
if (chartjs) {
|
|
95
|
-
;(chartjs as any).config = { ...config }
|
|
96
|
-
}
|
|
97
|
-
const scichart = document.querySelector('#scichart') as HTMLElement
|
|
98
|
-
if (scichart) {
|
|
99
|
-
;(scichart as any).config = config
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const container = document.querySelector('.container') as HTMLElement
|
|
103
|
-
if (container) {
|
|
104
|
-
const theme = config.options.theme
|
|
105
|
-
if (theme == 'dark') {
|
|
106
|
-
container.classList.remove('light')
|
|
107
|
-
container.classList.add('dark')
|
|
108
|
-
} else {
|
|
109
|
-
container.classList.remove('dark')
|
|
110
|
-
container.classList.add('light')
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}}
|
|
114
|
-
></ox-input-chart-mixed>
|
|
100
|
+
<ox-input-chart-mixed chart-type="bar" id="editor" .value=${value} @change=${showCharts}></ox-input-chart-mixed>
|
|
115
101
|
<div id="charts">
|
|
116
102
|
<ox-chart-js id="chartjs" .data=${data}></ox-chart-js>
|
|
117
103
|
<ox-scichart id="scichart"></ox-scichart>
|
|
@@ -135,7 +121,7 @@ WithData.args = {
|
|
|
135
121
|
{
|
|
136
122
|
label: 'Bar Series',
|
|
137
123
|
type: 'bar',
|
|
138
|
-
|
|
124
|
+
dataKey: 'count',
|
|
139
125
|
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
|
140
126
|
borderColor: 'rgba(255, 99, 132, 1)',
|
|
141
127
|
borderWidth: 1
|
|
@@ -143,7 +129,7 @@ WithData.args = {
|
|
|
143
129
|
{
|
|
144
130
|
label: 'Line Series',
|
|
145
131
|
type: 'line',
|
|
146
|
-
|
|
132
|
+
dataKey: 'average',
|
|
147
133
|
borderColor: 'rgba(54, 162, 235, 1)',
|
|
148
134
|
borderWidth: 1,
|
|
149
135
|
fill: false,
|
|
@@ -152,7 +138,7 @@ WithData.args = {
|
|
|
152
138
|
pointRadius: 3
|
|
153
139
|
}
|
|
154
140
|
],
|
|
155
|
-
labelDataKey: '
|
|
141
|
+
labelDataKey: 'timestamp'
|
|
156
142
|
},
|
|
157
143
|
options: {
|
|
158
144
|
scales: {
|
|
@@ -177,7 +163,7 @@ MultiAxis.args = {
|
|
|
177
163
|
{
|
|
178
164
|
label: 'Bar Series',
|
|
179
165
|
type: 'bar',
|
|
180
|
-
|
|
166
|
+
dataKey: 'count',
|
|
181
167
|
backgroundColor: 'rgba(255, 99, 132, 0.2)',
|
|
182
168
|
borderColor: 'rgba(255, 99, 132, 1)',
|
|
183
169
|
borderWidth: 1,
|
|
@@ -186,7 +172,7 @@ MultiAxis.args = {
|
|
|
186
172
|
{
|
|
187
173
|
label: 'Line Series',
|
|
188
174
|
type: 'line',
|
|
189
|
-
|
|
175
|
+
dataKey: 'average',
|
|
190
176
|
borderColor: 'rgba(54, 162, 235, 1)',
|
|
191
177
|
borderWidth: 1,
|
|
192
178
|
fill: false,
|
|
@@ -196,7 +182,7 @@ MultiAxis.args = {
|
|
|
196
182
|
yAxisID: 'right'
|
|
197
183
|
}
|
|
198
184
|
],
|
|
199
|
-
labelDataKey: '
|
|
185
|
+
labelDataKey: 'timestamp'
|
|
200
186
|
}
|
|
201
187
|
}
|
|
202
188
|
}
|
|
@@ -68,7 +68,7 @@ const Template: Story<ArgTypes> = ({ value, currentSeriesIndex }: ArgTypes) => h
|
|
|
68
68
|
</style>
|
|
69
69
|
|
|
70
70
|
<div style="background-color: black; color: white;">
|
|
71
|
-
Type 'count' or 'average' for series dataKey, type '
|
|
71
|
+
Type 'count' or 'average' for series dataKey, type 'timestamp' for axis's dataKey
|
|
72
72
|
</div>
|
|
73
73
|
|
|
74
74
|
<div class="container light">
|
|
@@ -79,7 +79,7 @@ const Template: Story<ArgTypes> = ({ value }: ArgTypes) => html`
|
|
|
79
79
|
</style>
|
|
80
80
|
|
|
81
81
|
<div style="background-color: black; color: white;">
|
|
82
|
-
Type 'count' or 'average' for series dataKey, type '
|
|
82
|
+
Type 'count' or 'average' for series dataKey, type 'timestamp' for axis's dataKey
|
|
83
83
|
</div>
|
|
84
84
|
<div class="container light">
|
|
85
85
|
<ox-input-chart-hbar
|
|
@@ -79,7 +79,7 @@ const Template: Story<ArgTypes> = ({ value }: ArgTypes) => html`
|
|
|
79
79
|
</style>
|
|
80
80
|
|
|
81
81
|
<div style="background-color: black; color: white;">
|
|
82
|
-
Type 'count' or 'average' for series dataKey, type '
|
|
82
|
+
Type 'count' or 'average' for series dataKey, type 'timestamp' for axis's dataKey
|
|
83
83
|
</div>
|
|
84
84
|
|
|
85
85
|
<div class="container light">
|
|
@@ -68,7 +68,7 @@ const Template: Story<ArgTypes> = ({ value, currentSeriesIndex }: ArgTypes) => h
|
|
|
68
68
|
</style>
|
|
69
69
|
|
|
70
70
|
<div style="background-color: black; color: white;">
|
|
71
|
-
Type 'count' or 'average' for series dataKey, type '
|
|
71
|
+
Type 'count' or 'average' for series dataKey, type 'timestamp' for axis's dataKey
|
|
72
72
|
</div>
|
|
73
73
|
|
|
74
74
|
<div class="container light">
|
|
@@ -68,7 +68,7 @@ const Template: Story<ArgTypes> = ({ value, currentSeriesIndex }: ArgTypes) => h
|
|
|
68
68
|
</style>
|
|
69
69
|
|
|
70
70
|
<div style="background-color: black; color: white;">
|
|
71
|
-
Type 'count' or 'average' for series dataKey, type '
|
|
71
|
+
Type 'count' or 'average' for series dataKey, type 'timestamp' for axis's dataKey
|
|
72
72
|
</div>
|
|
73
73
|
|
|
74
74
|
<div class="container light">
|
|
@@ -68,7 +68,7 @@ const Template: Story<ArgTypes> = ({ value, currentSeriesIndex }: ArgTypes) => h
|
|
|
68
68
|
</style>
|
|
69
69
|
|
|
70
70
|
<div style="background-color: black; color: white;">
|
|
71
|
-
Type 'count' or 'average' for series dataKey, type '
|
|
71
|
+
Type 'count' or 'average' for series dataKey, type 'timestamp' for axis's dataKey
|
|
72
72
|
</div>
|
|
73
73
|
|
|
74
74
|
<div class="container light">
|