@operato/chart 7.0.11 → 7.0.13

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.
Files changed (42) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/src/editors/configurer.d.ts +10 -1
  3. package/dist/src/editors/configurer.js +62 -2
  4. package/dist/src/editors/configurer.js.map +1 -1
  5. package/dist/src/editors/input-chart-abstract.d.ts +18 -0
  6. package/dist/src/editors/input-chart-abstract.js +438 -1
  7. package/dist/src/editors/input-chart-abstract.js.map +1 -1
  8. package/dist/src/editors/input-chart-styles.js +18 -9
  9. package/dist/src/editors/input-chart-styles.js.map +1 -1
  10. package/dist/src/editors/ox-input-chart-hbar.d.ts +2 -2
  11. package/dist/src/editors/ox-input-chart-hbar.js +10 -10
  12. package/dist/src/editors/ox-input-chart-hbar.js.map +1 -1
  13. package/dist/src/editors/ox-input-chart-mixed.d.ts +2 -2
  14. package/dist/src/editors/ox-input-chart-mixed.js +3 -3
  15. package/dist/src/editors/ox-input-chart-mixed.js.map +1 -1
  16. package/dist/src/editors/ox-input-chart-radar.d.ts +2 -2
  17. package/dist/src/editors/ox-input-chart-radar.js +3 -3
  18. package/dist/src/editors/ox-input-chart-radar.js.map +1 -1
  19. package/dist/src/editors/ox-input-chart-timeseries.d.ts +2 -2
  20. package/dist/src/editors/ox-input-chart-timeseries.js +6 -4
  21. package/dist/src/editors/ox-input-chart-timeseries.js.map +1 -1
  22. package/dist/src/scichart/scichart-builder.js +97 -31
  23. package/dist/src/scichart/scichart-builder.js.map +1 -1
  24. package/dist/stories/ox-input-chart-timeseries.stories.js +0 -4
  25. package/dist/stories/ox-input-chart-timeseries.stories.js.map +1 -1
  26. package/dist/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +2 -2
  28. package/src/editors/configurer.ts +73 -2
  29. package/src/editors/input-chart-abstract.ts +459 -2
  30. package/src/editors/input-chart-styles.ts +18 -9
  31. package/src/editors/ox-input-chart-hbar.ts +10 -10
  32. package/src/editors/ox-input-chart-mixed.ts +3 -3
  33. package/src/editors/ox-input-chart-radar.ts +3 -3
  34. package/src/editors/ox-input-chart-timeseries.ts +6 -4
  35. package/src/scichart/scichart-builder.ts +112 -31
  36. package/src/types.d.ts +19 -0
  37. package/stories/ox-input-chart-timeseries.stories.ts +0 -4
  38. package/translations/ko.json +7 -0
  39. package/dist/src/editors/input-chart-multi-series-abstract.d.ts +0 -17
  40. package/dist/src/editors/input-chart-multi-series-abstract.js +0 -419
  41. package/dist/src/editors/input-chart-multi-series-abstract.js.map +0 -1
  42. package/src/editors/input-chart-multi-series-abstract.ts +0 -430
@@ -9,6 +9,11 @@ function getThemeFromBrowser() {
9
9
  return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
10
10
  }
11
11
 
12
+ function convertColor(color: string | string[] | undefined, defaultColor?: string) {
13
+ const tinyColor = new TinyColor(color as string)
14
+ return tinyColor.toHex8String() || defaultColor
15
+ }
16
+
12
17
  export async function buildSciChart(
13
18
  config: OperatoChart.ChartConfig | undefined | null,
14
19
  container: any,
@@ -34,9 +39,11 @@ export async function buildSciChart(
34
39
  DateTimeNumericAxis,
35
40
  EAutoRange,
36
41
  EAxisAlignment,
42
+ ECoordinateMode,
37
43
  NumberRange,
38
44
  MouseWheelZoomModifier,
39
45
  RubberBandXyZoomModifier,
46
+ ZoomPanModifier,
40
47
  ZoomExtentsModifier,
41
48
  RolloverModifier,
42
49
  SmartDateLabelProvider,
@@ -46,7 +53,14 @@ export async function buildSciChart(
46
53
  CrossPointMarker,
47
54
  XPointMarker,
48
55
  WaveAnimation,
49
- LegendModifier
56
+ LegendModifier,
57
+ XAxisDragModifier,
58
+ YAxisDragModifier,
59
+ TextAnnotation,
60
+ LineAnnotation,
61
+ BoxAnnotation,
62
+ HorizontalLineAnnotation,
63
+ VerticalLineAnnotation
50
64
  } = SciChart
51
65
 
52
66
  const { type: chartType, options, data: fromData } = config
@@ -60,7 +74,9 @@ export async function buildSciChart(
60
74
  xGridLine,
61
75
  yGridLine,
62
76
  y2ndGridLine,
63
- stacked
77
+ stacked,
78
+ multiAxis,
79
+ annotations
64
80
  } = options || {}
65
81
 
66
82
  var baseColor = getBaseColorFromTheme(theme)
@@ -117,12 +133,12 @@ export async function buildSciChart(
117
133
  })
118
134
 
119
135
  // Y 축 설정
120
- yAxes.forEach((axis, index) => {
136
+ ;(multiAxis ? yAxes : [yAxes[0]]).forEach((axis, index) => {
121
137
  const { axisTitle, ticks } = axis
122
138
  const { autoMax, autoMin, min, max, stepSize, beginAtZero } = ticks || {}
123
139
 
124
140
  const yAxis = new NumericAxis(wasmContext, {
125
- id: `yAxis${index}`,
141
+ id: index == 0 ? undefined : `yAxis${index}`,
126
142
  axisTitle,
127
143
  autoRange: autoMin || autoMax ? EAutoRange.Always : undefined,
128
144
  axisAlignment: index === 0 ? EAxisAlignment.Left : EAxisAlignment.Right,
@@ -151,7 +167,7 @@ export async function buildSciChart(
151
167
  containsNaN: false
152
168
  })
153
169
 
154
- const yAxisId = dataset.yAxisID || 'yAxis0'
170
+ const yAxisId = dataset.yAxisID == 'right' && multiAxis ? 'yAxis1' : undefined
155
171
  const stackGroupId = dataset.stack || `__stack${index}__`
156
172
 
157
173
  let series: any
@@ -160,7 +176,7 @@ export async function buildSciChart(
160
176
  series = new StackedColumnRenderableSeries(wasmContext, {
161
177
  dataSeries,
162
178
  strokeThickness: dataset.borderWidth || 2,
163
- fill: dataset.backgroundColor || '#FF6600',
179
+ fill: convertColor(dataset.backgroundColor, '#FF6600'),
164
180
  yAxisId,
165
181
  stackedGroupId: stackGroupId
166
182
  })
@@ -168,68 +184,68 @@ export async function buildSciChart(
168
184
  series = new FastColumnRenderableSeries(wasmContext, {
169
185
  dataSeries,
170
186
  strokeThickness: dataset.borderWidth || 2,
171
- fill: dataset.backgroundColor || '#FF6600',
187
+ stroke: convertColor(dataset.backgroundColor, '#FF6600'),
172
188
  animation: animation && new WaveAnimation({ duration: 1000, fadeEffect: true }),
173
189
  yAxisId
174
190
  })
175
191
  }
176
192
  } else {
177
- const { pointStyle, lineTension } = dataset
193
+ const { pointStyle, pointRadius = 10, lineTension } = dataset
178
194
  let pointMarker = null // 초기값을 null로 설정
179
195
 
180
196
  if (pointStyle) {
181
197
  switch (pointStyle) {
182
198
  case 'circle':
183
199
  pointMarker = new EllipsePointMarker(wasmContext, {
184
- width: 10,
185
- height: 10,
200
+ width: pointRadius,
201
+ height: pointRadius,
186
202
  strokeThickness: 2,
187
- fill: dataset.color || '#FF6600',
203
+ fill: convertColor(dataset.color, '#FF6600'),
188
204
  stroke: '#000000'
189
205
  })
190
206
  break
191
207
  case 'triangle':
192
208
  pointMarker = new TrianglePointMarker(wasmContext, {
193
- width: 10,
194
- height: 10,
209
+ width: pointRadius,
210
+ height: pointRadius,
195
211
  strokeThickness: 2,
196
- fill: dataset.color || '#FF6600',
212
+ fill: convertColor(dataset.color, '#FF6600'),
197
213
  stroke: '#000000'
198
214
  })
199
215
  break
200
216
  case 'rect':
201
217
  pointMarker = new SquarePointMarker(wasmContext, {
202
- width: 10,
203
- height: 10,
218
+ width: pointRadius,
219
+ height: pointRadius,
204
220
  strokeThickness: 2,
205
- fill: dataset.color || '#FF6600',
221
+ fill: convertColor(dataset.color, '#FF6600'),
206
222
  stroke: '#000000'
207
223
  })
208
224
  break
209
225
  case 'cross':
210
226
  pointMarker = new CrossPointMarker(wasmContext, {
211
- width: 10,
212
- height: 10,
227
+ width: pointRadius,
228
+ height: pointRadius,
213
229
  strokeThickness: 2,
214
- fill: dataset.color || '#FF6600',
230
+ fill: convertColor(dataset.color, '#FF6600'),
215
231
  stroke: '#000000'
216
232
  })
217
233
  break
218
234
  case 'crossRot':
219
235
  pointMarker = new XPointMarker(wasmContext, {
220
- width: 10,
221
- height: 10,
236
+ width: pointRadius,
237
+ height: pointRadius,
222
238
  strokeThickness: 2,
223
- fill: dataset.color || '#FF6600',
239
+ fill: convertColor(dataset.color, '#FF6600'),
224
240
  stroke: '#000000'
225
241
  })
226
242
  break
227
243
  default:
228
244
  pointMarker = new EllipsePointMarker(wasmContext, {
229
- width: 10,
230
- height: 10,
245
+ width: pointRadius,
246
+ height: pointRadius,
231
247
  strokeThickness: 2,
232
- fill: dataset.color || '#FF6600',
248
+ fill: convertColor(dataset.color, '#FF6600'),
233
249
  stroke: '#000000'
234
250
  })
235
251
  }
@@ -239,7 +255,7 @@ export async function buildSciChart(
239
255
  series = new StackedMountainRenderableSeries(wasmContext, {
240
256
  dataSeries,
241
257
  strokeThickness: dataset.borderWidth || 2,
242
- stroke: dataset.color || '#FF6600',
258
+ stroke: convertColor(dataset.color, '#FF6600'),
243
259
  fill: dataset.backgroundColor || '#FF6600',
244
260
  yAxisId,
245
261
  stackedGroupId: stackGroupId
@@ -250,7 +266,7 @@ export async function buildSciChart(
250
266
  ? new SplineLineRenderableSeries(wasmContext, {
251
267
  dataSeries,
252
268
  strokeThickness: dataset.borderWidth || 2,
253
- stroke: dataset.color || '#FF6600',
269
+ stroke: convertColor(dataset.color, '#FF6600'),
254
270
  pointMarker,
255
271
  animation: animation && new WaveAnimation({ duration: 1000, fadeEffect: true }),
256
272
  yAxisId
@@ -258,7 +274,7 @@ export async function buildSciChart(
258
274
  : new FastLineRenderableSeries(wasmContext, {
259
275
  dataSeries,
260
276
  strokeThickness: dataset.borderWidth || 2,
261
- stroke: dataset.color || '#FF6600',
277
+ stroke: convertColor(dataset.color, '#FF6600'),
262
278
  pointMarker,
263
279
  animation: animation && new WaveAnimation({ duration: 1000, fadeEffect: true }),
264
280
  yAxisId
@@ -305,11 +321,76 @@ export async function buildSciChart(
305
321
  }
306
322
  }
307
323
 
324
+ if (annotations) {
325
+ annotations.forEach(annotation => {
326
+ let sciAnnotation: any
327
+ switch (annotation.type) {
328
+ case 'text':
329
+ sciAnnotation = new TextAnnotation({
330
+ x1: annotation.x1,
331
+ y1: annotation.y1,
332
+ text: annotation.text,
333
+ horizontalAnchorPoint: annotation.horizontalAnchorPoint,
334
+ verticalAnchorPoint: annotation.verticalAnchorPoint,
335
+ fontSize: annotation.fontSize,
336
+ fontFamily: annotation.fontFamily,
337
+ textColor: convertColor(annotation.stroke, fontColor)
338
+ })
339
+ break
340
+ case 'line':
341
+ sciAnnotation = new LineAnnotation({
342
+ x1: annotation.x1,
343
+ y1: annotation.y1,
344
+ x2: annotation.x2,
345
+ y2: annotation.y2,
346
+ stroke: convertColor(annotation.stroke, '#FF0000'),
347
+ strokeThickness: annotation.strokeThickness,
348
+ xCoordinateMode: ECoordinateMode.Relative,
349
+ yCoordinateMode: ECoordinateMode.DataValue
350
+ })
351
+ break
352
+ case 'box':
353
+ sciAnnotation = new BoxAnnotation({
354
+ x1: annotation.x1,
355
+ y1: annotation.y1,
356
+ x2: annotation.x2,
357
+ y2: annotation.y2,
358
+ fill: convertColor(annotation.fill, '#FF0000'),
359
+ stroke: convertColor(annotation.stroke, '#FF0000'),
360
+ strokeThickness: annotation.strokeThickness
361
+ })
362
+ break
363
+ case 'horizontalLine':
364
+ sciAnnotation = new HorizontalLineAnnotation({
365
+ y1: annotation.y1,
366
+ stroke: convertColor(annotation.stroke, '#FF0000'),
367
+ strokeThickness: annotation.strokeThickness
368
+ })
369
+ break
370
+ case 'verticalLine':
371
+ sciAnnotation = new VerticalLineAnnotation({
372
+ x1: annotation.x1,
373
+ stroke: convertColor(annotation.stroke, '#FF0000'),
374
+ strokeThickness: annotation.strokeThickness
375
+ })
376
+ break
377
+ default:
378
+ break
379
+ }
380
+ if (sciAnnotation) {
381
+ sciChartSurface.annotations.add(sciAnnotation)
382
+ }
383
+ })
384
+ }
385
+
308
386
  // 줌인/줌아웃 모디파이어 추가
309
387
  sciChartSurface.chartModifiers.add(
310
- new RubberBandXyZoomModifier(),
388
+ // new RubberBandXyZoomModifier(),
389
+ new ZoomPanModifier(),
311
390
  new MouseWheelZoomModifier(),
312
- new ZoomExtentsModifier()
391
+ new ZoomExtentsModifier(),
392
+ new XAxisDragModifier(),
393
+ new YAxisDragModifier()
313
394
  )
314
395
 
315
396
  // Legend 설정
package/src/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  declare namespace OperatoChart {
2
2
  export type ChartType = 'bar' | 'horizontalBar' | 'line' | 'radar' | 'pie' | 'doughnut' | 'polarArea' | undefined
3
+
3
4
  export interface ChartConfig {
4
5
  data: ChartData
5
6
  options?: ChartOptions
@@ -56,6 +57,7 @@ declare namespace OperatoChart {
56
57
  multiAxis?: boolean
57
58
  maintainAspectRatio?: boolean
58
59
  plugins?: { [plugin: string]: any }
60
+ annotations?: Annotation[]
59
61
  }
60
62
 
61
63
  export interface LegendOptions {
@@ -87,4 +89,21 @@ declare namespace OperatoChart {
87
89
  color?: string
88
90
  textStrokeColor?: string
89
91
  }
92
+
93
+ export interface Annotation {
94
+ type: AnnotationType
95
+ x1: number
96
+ y1: number
97
+ x2?: number
98
+ y2?: number
99
+ stroke?: string
100
+ strokeThickness?: number
101
+ fill?: string
102
+ text?: string
103
+ horizontalAnchorPoint?: 'Left' | 'Center' | 'Right'
104
+ verticalAnchorPoint?: 'Top' | 'Center' | 'Bottom'
105
+ [key: string]: any
106
+ }
107
+
108
+ export type AnnotationType = 'line' | 'text' | 'box' | 'horizontalLine' | 'verticalLine' | 'custom' | undefined
90
109
  }
@@ -151,10 +151,6 @@ WithData.args = {
151
151
  {
152
152
  axisTitle: 'count',
153
153
  ticks: { beginAtZero: true }
154
- },
155
- {
156
- axisTitle: 'average',
157
- ticks: { beginAtZero: true }
158
154
  }
159
155
  ]
160
156
  },
@@ -9,6 +9,13 @@
9
9
  "label.chart": "차트",
10
10
  "label.chart-style": "차트 스타일",
11
11
  "label.chart-type": "차트 유형",
12
+ "label.chart-annotation": "어노테이션",
13
+ "label.chart-annotation-type": "어노테이션 타입",
14
+ "label.stroke-style": "선 스타일",
15
+ "label.stroke-thickness": "선 두께",
16
+ "label.annotation-text": "텍스트",
17
+ "label.horizontal-anchor": "수평 기준점",
18
+ "label.vertical-anchor": "수직 기준점",
12
19
  "label.color": "색상",
13
20
  "label.data-key": "데이터 참조",
14
21
  "label.display-tick": "눈금 표시",
@@ -1,17 +0,0 @@
1
- import '@material/web/icon/icon.js';
2
- import '@operato/i18n/ox-i18n.js';
3
- import { MdIcon } from '@material/web/icon/icon.js';
4
- import { InputChartAbstract } from './input-chart-abstract';
5
- export declare class InputChartMultiSeriesAbstract extends InputChartAbstract {
6
- static styles: import("lit").CSSResult[];
7
- tabs: HTMLElement;
8
- tabNavLeftButton: MdIcon;
9
- tabNavRightButton: MdIcon;
10
- get tabContainer(): HTMLElement | null | undefined;
11
- firstUpdated(): void;
12
- subTemplate(): import("lit-html").TemplateResult<1>;
13
- multiSeriesTabTemplate(): import("lit-html").TemplateResult<1>;
14
- _onTabScroll(e: Event): void;
15
- _onTabScrollNavLeft(e: Event): void;
16
- _onTabScrollNavRight(e: Event): void;
17
- }