@operato/chart 7.0.12 → 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 +9 -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 +65 -5
  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 +74 -4
  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
@@ -6,11 +6,11 @@ import { html } from 'lit'
6
6
  import { customElement } from 'lit/decorators.js'
7
7
  import { ifDefined } from 'lit/directives/if-defined.js'
8
8
 
9
- import { InputChartMultiSeriesAbstract } from './input-chart-multi-series-abstract'
9
+ import { InputChartAbstract } from './input-chart-abstract'
10
10
 
11
11
  @customElement('ox-input-chart-hbar')
12
- export class OxInputChartHBar extends InputChartMultiSeriesAbstract {
13
- static styles = [...InputChartMultiSeriesAbstract.styles]
12
+ export class OxInputChartHBar extends InputChartAbstract {
13
+ static styles = InputChartAbstract.styles
14
14
 
15
15
  subTemplate() {
16
16
  const configurer = this.configurer
@@ -149,17 +149,17 @@ export class OxInputChartHBar extends InputChartMultiSeriesAbstract {
149
149
 
150
150
  return html`
151
151
  <div id="series-properties-container" fullwidth>
152
- <div id="tab-header">
152
+ <div id="series-tab-header">
153
153
  <md-icon
154
- id="tab-nav-left-button"
154
+ id="series-tab-nav-left-button"
155
155
  @tap=${(e: Event) => {
156
- this._onTabScrollNavLeft(e)
156
+ this._onTabScrollNavLeft(e, 'series')
157
157
  }}
158
158
  disabled
159
159
  >chevron_left</md-icon
160
160
  >
161
161
  <div
162
- id="tabs"
162
+ id="series-tabs"
163
163
  @change=${(e: Event) => {
164
164
  configurer.currentSeriesIndex = (e.target as any).activeTabIndex
165
165
  }}
@@ -181,16 +181,16 @@ export class OxInputChartHBar extends InputChartMultiSeriesAbstract {
181
181
  >
182
182
  ${index + 1}
183
183
  ${!configurer.datasets || (configurer.datasets.length != 1 && configurer.currentSeriesIndex == index)
184
- ? html` <md-icon @tap="${(e: Event) => this.onTapRemoveCurrentTab(index)}"> close </md-icon> `
184
+ ? html` <md-icon @tap=${(e: Event) => this.onTapRemoveCurrentTab(index)}> close </md-icon> `
185
185
  : html``}
186
186
  </div>
187
187
  `
188
188
  )}
189
189
  </div>
190
190
  <md-icon
191
- id="tab-nav-right-button"
191
+ id="series-tab-nav-right-button"
192
192
  @click=${(e: Event) => {
193
- this._onTabScrollNavRight(e)
193
+ this._onTabScrollNavRight(e, 'series')
194
194
  }}
195
195
  disabled
196
196
  >chevron_right</md-icon
@@ -4,11 +4,11 @@ import { html } from 'lit'
4
4
  import { customElement } from 'lit/decorators.js'
5
5
  import { ifDefined } from 'lit/directives/if-defined.js'
6
6
 
7
- import { InputChartMultiSeriesAbstract } from './input-chart-multi-series-abstract'
7
+ import { InputChartAbstract } from './input-chart-abstract'
8
8
 
9
9
  @customElement('ox-input-chart-mixed')
10
- export class OxInputChartMixed extends InputChartMultiSeriesAbstract {
11
- static styles = InputChartMultiSeriesAbstract.styles
10
+ export class OxInputChartMixed extends InputChartAbstract {
11
+ static styles = InputChartAbstract.styles
12
12
 
13
13
  subTemplate() {
14
14
  const configurer = this.configurer
@@ -4,11 +4,11 @@ import { html } from 'lit'
4
4
  import { customElement } from 'lit/decorators.js'
5
5
  import { ifDefined } from 'lit/directives/if-defined.js'
6
6
 
7
- import { InputChartMultiSeriesAbstract } from './input-chart-multi-series-abstract'
7
+ import { InputChartAbstract } from './input-chart-abstract'
8
8
 
9
9
  @customElement('ox-input-chart-radar')
10
- export default class OxInputChartRadar extends InputChartMultiSeriesAbstract {
11
- static styles = InputChartMultiSeriesAbstract.styles
10
+ export default class OxInputChartRadar extends InputChartAbstract {
11
+ static styles = InputChartAbstract.styles
12
12
 
13
13
  subTemplate() {
14
14
  const configurer = this.configurer
@@ -4,11 +4,11 @@ import { html } from 'lit'
4
4
  import { customElement } from 'lit/decorators.js'
5
5
  import { ifDefined } from 'lit/directives/if-defined.js'
6
6
 
7
- import { InputChartMultiSeriesAbstract } from './input-chart-multi-series-abstract'
7
+ import { InputChartAbstract } from './input-chart-abstract'
8
8
 
9
9
  @customElement('ox-input-chart-timeseries')
10
- export class OxInputChartTimeseries extends InputChartMultiSeriesAbstract {
11
- static styles = InputChartMultiSeriesAbstract.styles
10
+ export class OxInputChartTimeseries extends InputChartAbstract {
11
+ static styles = InputChartAbstract.styles
12
12
 
13
13
  subTemplate() {
14
14
  const configurer = this.configurer
@@ -18,9 +18,11 @@ export class OxInputChartTimeseries extends InputChartMultiSeriesAbstract {
18
18
  <label for="multi-axis"> <ox-i18n msgid="label.multi-axis">Multi Axis</ox-i18n> </label>
19
19
 
20
20
  <legend><ox-i18n msgid="label.series">Series</ox-i18n></legend>
21
-
22
21
  <div fullwidth>${this.multiSeriesTabTemplate()}</div>
23
22
 
23
+ <legend><ox-i18n msgid="label.chart-annotation">Annotations</ox-i18n></legend>
24
+ <div fullwidth>${this.annotationsTabTemplate()}</div>
25
+
24
26
  <legend><ox-i18n msgid="label.x-axes">X Axes</ox-i18n></legend>
25
27
 
26
28
  <label for="series-data-key"> <ox-i18n msgid="label.data-key">Data Key</ox-i18n> </label>
@@ -39,6 +39,7 @@ export async function buildSciChart(
39
39
  DateTimeNumericAxis,
40
40
  EAutoRange,
41
41
  EAxisAlignment,
42
+ ECoordinateMode,
42
43
  NumberRange,
43
44
  MouseWheelZoomModifier,
44
45
  RubberBandXyZoomModifier,
@@ -54,7 +55,12 @@ export async function buildSciChart(
54
55
  WaveAnimation,
55
56
  LegendModifier,
56
57
  XAxisDragModifier,
57
- YAxisDragModifier
58
+ YAxisDragModifier,
59
+ TextAnnotation,
60
+ LineAnnotation,
61
+ BoxAnnotation,
62
+ HorizontalLineAnnotation,
63
+ VerticalLineAnnotation
58
64
  } = SciChart
59
65
 
60
66
  const { type: chartType, options, data: fromData } = config
@@ -68,7 +74,9 @@ export async function buildSciChart(
68
74
  xGridLine,
69
75
  yGridLine,
70
76
  y2ndGridLine,
71
- stacked
77
+ stacked,
78
+ multiAxis,
79
+ annotations
72
80
  } = options || {}
73
81
 
74
82
  var baseColor = getBaseColorFromTheme(theme)
@@ -125,7 +133,7 @@ export async function buildSciChart(
125
133
  })
126
134
 
127
135
  // Y 축 설정
128
- yAxes.forEach((axis, index) => {
136
+ ;(multiAxis ? yAxes : [yAxes[0]]).forEach((axis, index) => {
129
137
  const { axisTitle, ticks } = axis
130
138
  const { autoMax, autoMin, min, max, stepSize, beginAtZero } = ticks || {}
131
139
 
@@ -159,7 +167,7 @@ export async function buildSciChart(
159
167
  containsNaN: false
160
168
  })
161
169
 
162
- const yAxisId = dataset.yAxisID == 'right' ? 'yAxis1' : undefined
170
+ const yAxisId = dataset.yAxisID == 'right' && multiAxis ? 'yAxis1' : undefined
163
171
  const stackGroupId = dataset.stack || `__stack${index}__`
164
172
 
165
173
  let series: any
@@ -313,6 +321,68 @@ export async function buildSciChart(
313
321
  }
314
322
  }
315
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
+
316
386
  // 줌인/줌아웃 모디파이어 추가
317
387
  sciChartSurface.chartModifiers.add(
318
388
  // new RubberBandXyZoomModifier(),
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
- }