@operato/chart 8.0.0-beta.0 → 8.0.0-beta.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 +18 -0
- package/package.json +6 -6
- package/.editorconfig +0 -29
- package/.storybook/main.js +0 -3
- package/.storybook/preview.js +0 -52
- package/.storybook/server.mjs +0 -8
- package/demo/index.html +0 -33
- package/src/chartjs/config-converter.ts +0 -341
- package/src/chartjs/ox-chart-js.ts +0 -207
- package/src/editors/configurer.ts +0 -336
- package/src/editors/index.ts +0 -8
- package/src/editors/input-chart-abstract.ts +0 -202
- package/src/editors/input-chart-styles.ts +0 -206
- package/src/editors/ox-input-chart-hbar.ts +0 -157
- package/src/editors/ox-input-chart-mixed.ts +0 -241
- package/src/editors/ox-input-chart-pie.ts +0 -69
- package/src/editors/ox-input-chart-radar.ts +0 -56
- package/src/editors/ox-input-chart-timeseries.ts +0 -279
- package/src/editors/ox-property-editor-chart.ts +0 -72
- package/src/editors/templates/annotations.ts +0 -295
- package/src/editors/templates/display-value.ts +0 -111
- package/src/editors/templates/series.ts +0 -316
- package/src/global.d.ts +0 -1
- package/src/index.ts +0 -0
- package/src/progress/ox-progress-circle.ts +0 -133
- package/src/scichart/ox-scichart.ts +0 -151
- package/src/scichart/scichart-builder.ts +0 -508
- package/src/types.d.ts +0 -124
- package/stories/common.ts +0 -87
- package/stories/ox-input-chart-bar.stories.ts +0 -188
- package/stories/ox-input-chart-doughnut.stories.ts +0 -130
- package/stories/ox-input-chart-hbar.stories.ts +0 -188
- package/stories/ox-input-chart-line.stories.ts +0 -198
- package/stories/ox-input-chart-pie.stories.ts +0 -130
- package/stories/ox-input-chart-polar-area.stories.ts +0 -130
- package/stories/ox-input-chart-radar.stories.ts +0 -141
- package/stories/ox-input-chart-timeseries.stories.ts +0 -268
- package/tsconfig.json +0 -25
- package/web-dev-server.config.mjs +0 -27
- package/web-test-runner.config.mjs +0 -41
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import ChartDataLabels from 'chartjs-plugin-datalabels'
|
|
2
|
-
|
|
3
|
-
import { LitElement, html, css } from 'lit'
|
|
4
|
-
import { property, query, state, customElement } from 'lit/decorators.js'
|
|
5
|
-
import { Chart, ChartConfiguration } from 'chart.js/auto'
|
|
6
|
-
import { format as formatText } from '@operato/utils/format.js'
|
|
7
|
-
import { convertConfigure } from './config-converter'
|
|
8
|
-
|
|
9
|
-
Chart.register(ChartDataLabels)
|
|
10
|
-
|
|
11
|
-
@customElement('ox-chart-js')
|
|
12
|
-
export class OxChartJs extends LitElement {
|
|
13
|
-
@property({ type: Object }) config: OperatoChart.ChartConfig | null = null
|
|
14
|
-
@property({ type: Array }) data: { [key: string]: any }[] = []
|
|
15
|
-
@property({ type: Number }) width!: number
|
|
16
|
-
@property({ type: Number }) height!: number
|
|
17
|
-
|
|
18
|
-
private chart: Chart | null = null
|
|
19
|
-
private chartjsConfig: ChartConfiguration | null = null
|
|
20
|
-
|
|
21
|
-
@query('canvas') canvas!: HTMLCanvasElement
|
|
22
|
-
|
|
23
|
-
static styles = css`
|
|
24
|
-
:host {
|
|
25
|
-
display: block;
|
|
26
|
-
|
|
27
|
-
background-color: var(--ox-chart-background-color, var(--md-sys-color-surface));
|
|
28
|
-
color: var(--ox-chart-color, var(--md-sys-color-on-surface));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
canvas {
|
|
32
|
-
width: 100%;
|
|
33
|
-
height: 100%;
|
|
34
|
-
}
|
|
35
|
-
`
|
|
36
|
-
|
|
37
|
-
disconnectedCallback(): void {
|
|
38
|
-
super.disconnectedCallback()
|
|
39
|
-
if (this.chart) {
|
|
40
|
-
this.chart.destroy()
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
updated(changedProperties: Map<string | number | symbol, unknown>) {
|
|
45
|
-
var needUpdateData = false
|
|
46
|
-
|
|
47
|
-
if (changedProperties.has('width') || changedProperties.has('height')) {
|
|
48
|
-
this.updateChartSize()
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
if (changedProperties.has('config') && this.config) {
|
|
52
|
-
this.chartjsConfig = convertConfigure(this.config, {}) as any
|
|
53
|
-
|
|
54
|
-
this.attachPluginOptions(this.chartjsConfig!.options as any)
|
|
55
|
-
|
|
56
|
-
this.chart && this.chart.destroy()
|
|
57
|
-
this.chart = new Chart(this.canvas, this.chartjsConfig!)
|
|
58
|
-
|
|
59
|
-
needUpdateData = true
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (changedProperties.has('data')) {
|
|
63
|
-
needUpdateData = true
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (needUpdateData) {
|
|
67
|
-
this.updateData()
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
updateData() {
|
|
72
|
-
if (!this.chart) {
|
|
73
|
-
return
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
var data = this.data
|
|
77
|
-
|
|
78
|
-
if (this.data[0]?.hasOwnProperty('__field1')) {
|
|
79
|
-
/* DEPRECATED 이 케이스는 앞으로 지원하지 않는 것이 좋다. 하위 호환성 때문에 제공함. 사용빈도 낮음. */
|
|
80
|
-
data = toObjectArrayValue(this.data) as { [key: string]: any }[]
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const labelDataKey = this.config!.data.labelDataKey || ''
|
|
84
|
-
|
|
85
|
-
labelDataKey && (this.chart!.config.data!.labels = data.map((data: any) => data[labelDataKey]))
|
|
86
|
-
|
|
87
|
-
const datasets = this.chart!.config.data.datasets
|
|
88
|
-
for (let key in datasets) {
|
|
89
|
-
const dataset = datasets[Number(key)]
|
|
90
|
-
const dataKey = (dataset as any).dataKey
|
|
91
|
-
dataKey && (dataset.data = data.map(d => d[dataKey]) as any)
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
this.chart.update()
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
updateChartSize() {
|
|
98
|
-
const width = Math.floor(this.width)
|
|
99
|
-
const height = Math.floor(this.height)
|
|
100
|
-
|
|
101
|
-
this.canvas.style.width = `${width}px`
|
|
102
|
-
this.canvas.style.height = `${height}px`
|
|
103
|
-
|
|
104
|
-
const _ = () => {
|
|
105
|
-
if (this.canvas.offsetWidth == 0 || this.canvas.offsetHeight == 0) {
|
|
106
|
-
requestAnimationFrame(_)
|
|
107
|
-
} else {
|
|
108
|
-
/*
|
|
109
|
-
주의 : chart.resize() 내에서 pixel ratio를 감안해서, canvas 의 width, height를 설정하기때문에,
|
|
110
|
-
별도 처리가 필요하지 않다.
|
|
111
|
-
*/
|
|
112
|
-
this.chart!.resize()
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
requestAnimationFrame(_)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
render() {
|
|
120
|
-
return html`<canvas></canvas>`
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
attachPluginOptions(options: OperatoChart.ChartOptions) {
|
|
124
|
-
if (!options.plugins) {
|
|
125
|
-
options.plugins = {}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
this.attachDatalabelPluginOptions(options.plugins)
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
attachDatalabelPluginOptions(pluginOptions: any) {
|
|
132
|
-
pluginOptions.datalabels = {
|
|
133
|
-
...pluginOptions.datalabels,
|
|
134
|
-
display: function (context: any) {
|
|
135
|
-
return !!context.dataset.displayValue
|
|
136
|
-
},
|
|
137
|
-
anchor: function (context: any) {
|
|
138
|
-
return context.dataset.dataLabelAnchor || 'center'
|
|
139
|
-
},
|
|
140
|
-
offset: function (context: any) {
|
|
141
|
-
return context.dataset.dataLabelOffset || 0
|
|
142
|
-
},
|
|
143
|
-
align: function (context: any) {
|
|
144
|
-
return context.dataset.dataLabelAnchor || 'center'
|
|
145
|
-
},
|
|
146
|
-
rotation: function (context: any) {
|
|
147
|
-
return context.dataset.dataLabelRotation || 0
|
|
148
|
-
},
|
|
149
|
-
color: function (context: any) {
|
|
150
|
-
return context.dataset?.defaultFontColor || '#000'
|
|
151
|
-
},
|
|
152
|
-
font: function (context: any) {
|
|
153
|
-
return {
|
|
154
|
-
size: context.dataset?.defaultFontSize,
|
|
155
|
-
family: context.chart.options?.defaultFontFamily
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
clamp: true,
|
|
159
|
-
formatter: function (value: string, context: any) {
|
|
160
|
-
var prefix = context.dataset.valuePrefix || ''
|
|
161
|
-
var suffix = context.dataset.valueSuffix || ''
|
|
162
|
-
var format = context.dataset.valueFormat || ''
|
|
163
|
-
|
|
164
|
-
if (value === undefined) {
|
|
165
|
-
return value
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
var stringValue = format ? formatText(format, Number(value)) : Number(value).toLocaleString()
|
|
169
|
-
return prefix + stringValue + suffix
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
function toObjectArrayValue(array: any[]): any[] | null {
|
|
176
|
-
if (!array || array.length === 0) {
|
|
177
|
-
return null
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
let indexKeyMap: any = {}
|
|
181
|
-
let value = []
|
|
182
|
-
|
|
183
|
-
for (let key in array[0]) {
|
|
184
|
-
indexKeyMap[key] = array[0][key]
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
for (var i = 1; i < array.length; i++) {
|
|
188
|
-
let object: any = {}
|
|
189
|
-
let thisObject = array[i]
|
|
190
|
-
|
|
191
|
-
for (let key in indexKeyMap) {
|
|
192
|
-
let k = indexKeyMap[key]
|
|
193
|
-
let v = thisObject[key]
|
|
194
|
-
object[k] = v
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
value.push(object)
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return value
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
declare global {
|
|
204
|
-
interface HTMLElementTagNameMap {
|
|
205
|
-
'ox-chart-js': OxChartJs
|
|
206
|
-
}
|
|
207
|
-
}
|
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
export class Configurer {
|
|
2
|
-
public value: OperatoChart.ChartConfig
|
|
3
|
-
public currentSeriesIndex: number = 0
|
|
4
|
-
public currentAnnotationIndex: number = -1
|
|
5
|
-
public initializer: () => OperatoChart.ChartConfig
|
|
6
|
-
|
|
7
|
-
constructor(value: OperatoChart.ChartConfig | null, initializer: () => OperatoChart.ChartConfig) {
|
|
8
|
-
this.initializer = initializer
|
|
9
|
-
this.value = value || initializer.call(this)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
updateValue(value?: OperatoChart.ChartConfig) {
|
|
13
|
-
this.value = value || { ...this.value }
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
setCurrentSeriesIndex(currentSeriesIndex: number) {
|
|
17
|
-
this.currentSeriesIndex = currentSeriesIndex
|
|
18
|
-
this.series = this.datasets[this.currentSeriesIndex]!
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
setCurrentAnnotationIndex(currentAnnotationIndex: number) {
|
|
22
|
-
this.currentAnnotationIndex = currentAnnotationIndex
|
|
23
|
-
if (currentAnnotationIndex >= 0 && currentAnnotationIndex < this.annotations.length) {
|
|
24
|
-
this.annotation = this.annotations[currentAnnotationIndex]
|
|
25
|
-
} else {
|
|
26
|
-
this.currentAnnotationIndex = -1
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get series() {
|
|
31
|
-
return this.datasets[this.currentSeriesIndex]! || {}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
set series(series) {
|
|
35
|
-
if (!this.data) {
|
|
36
|
-
this.config.data = { datasets: [series] }
|
|
37
|
-
} else {
|
|
38
|
-
this.datasets[this.currentSeriesIndex] = series
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
get annotation() {
|
|
43
|
-
return this.annotations[this.currentAnnotationIndex]! || {}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
set annotation(annotation) {
|
|
47
|
-
if (!this.annotations) {
|
|
48
|
-
this.annotations = [annotation]
|
|
49
|
-
} else {
|
|
50
|
-
this.annotations[this.currentAnnotationIndex] = annotation
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
get config() {
|
|
55
|
-
if (!this.value) {
|
|
56
|
-
this.value = this.initializer.call(this)
|
|
57
|
-
}
|
|
58
|
-
return this.value
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
get data() {
|
|
62
|
-
return this.config.data
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
set data(data) {
|
|
66
|
-
this.config.data = data
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
get datasets() {
|
|
70
|
-
if (!this.data.datasets) {
|
|
71
|
-
this.data.datasets = []
|
|
72
|
-
}
|
|
73
|
-
return this.data.datasets
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
set datasets(datasets) {
|
|
77
|
-
this.data.datasets = datasets
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
set dataKey(key) {
|
|
81
|
-
if (this.series) {
|
|
82
|
-
this.series!.dataKey = key
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
get dataKey() {
|
|
87
|
-
return this.series.dataKey
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
get legend() {
|
|
91
|
-
!this.config.options && (this.config.options = {})
|
|
92
|
-
return this.config.options.legend
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
set legend(legend) {
|
|
96
|
-
if (!this.config.options) {
|
|
97
|
-
this.config.options = {}
|
|
98
|
-
}
|
|
99
|
-
this.config.options.legend = legend
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
get theme() {
|
|
103
|
-
return this.config.options && this.config.options.theme
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
set theme(theme) {
|
|
107
|
-
!this.config.options && (this.config.options = {})
|
|
108
|
-
this.config.options.theme = theme
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
get tooltip() {
|
|
112
|
-
return !this.config.options || this.config.options.tooltip !== false
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
set tooltip(tooltip) {
|
|
116
|
-
if (!this.config.options) {
|
|
117
|
-
this.config.options = {}
|
|
118
|
-
}
|
|
119
|
-
this.config.options.tooltip = tooltip
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
get animation() {
|
|
123
|
-
return !this.config.options || this.config.options.animation !== false
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
set animation(animation) {
|
|
127
|
-
if (!this.config.options) {
|
|
128
|
-
this.config.options = {}
|
|
129
|
-
}
|
|
130
|
-
this.config.options.animation = animation
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
get scales() {
|
|
134
|
-
if (!this.config.options) {
|
|
135
|
-
this.config.options = {}
|
|
136
|
-
}
|
|
137
|
-
return this.config.options.scales
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
set scales(scales) {
|
|
141
|
-
!this.config.options && (this.config.options = {})
|
|
142
|
-
this.config.options.scales = scales
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
get display() {
|
|
146
|
-
return this.legend && this.legend.display
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
set display(display) {
|
|
150
|
-
if (!this.legend) {
|
|
151
|
-
this.legend = {}
|
|
152
|
-
}
|
|
153
|
-
this.legend.display = display
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
get position() {
|
|
157
|
-
if (!this.legend) {
|
|
158
|
-
this.legend = {}
|
|
159
|
-
}
|
|
160
|
-
return this.legend.position
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
set position(position) {
|
|
164
|
-
if (!this.legend) {
|
|
165
|
-
this.legend = {}
|
|
166
|
-
}
|
|
167
|
-
this.legend.position = position
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
get stacked() {
|
|
171
|
-
if (!this.config.options) {
|
|
172
|
-
this.config.options = {}
|
|
173
|
-
}
|
|
174
|
-
return this.config.options.stacked
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
set stacked(stacked) {
|
|
178
|
-
if (!this.config.options) {
|
|
179
|
-
this.config.options = {}
|
|
180
|
-
}
|
|
181
|
-
this.config.options.stacked = stacked
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
get labelDataKey() {
|
|
185
|
-
return this.data && this.data.labelDataKey
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
set labelDataKey(labelDataKey) {
|
|
189
|
-
this.data.labelDataKey = labelDataKey
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
set options(options) {
|
|
193
|
-
this.config.options = options
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
get options() {
|
|
197
|
-
return this.config.options
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
get color() {
|
|
201
|
-
var oldVersionColor = this.series.backgroundColor
|
|
202
|
-
if (this.series.type == 'line') oldVersionColor = this.series.borderColor
|
|
203
|
-
if (this.series.type == 'radar') oldVersionColor = this.series.borderColor
|
|
204
|
-
return this.series.color || oldVersionColor
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
set color(color) {
|
|
208
|
-
this.series.color = color
|
|
209
|
-
delete this.series.backgroundColor
|
|
210
|
-
delete this.series.borderColor
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
get xAxes0() {
|
|
214
|
-
return this.scales!.xAxes![0]
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
set xAxes0(xAxes0) {
|
|
218
|
-
this.scales!.xAxes![0] = xAxes0
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
get yAxes0() {
|
|
222
|
-
return this.scales!.yAxes![0]
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
set yAxes0(yAxes0) {
|
|
226
|
-
this.scales!.yAxes![0] = yAxes0
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
get yAxes1() {
|
|
230
|
-
return this.scales!.yAxes![1]
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
set yAxes1(yAxes1) {
|
|
234
|
-
if (!this.scales!.yAxes![1]) {
|
|
235
|
-
this.scales!.yAxes![1] = {}
|
|
236
|
-
}
|
|
237
|
-
this.scales!.yAxes![1] = yAxes1
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
get multiAxis() {
|
|
241
|
-
return this.config.options!.multiAxis
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
set multiAxis(multiAxis) {
|
|
245
|
-
if (!multiAxis) {
|
|
246
|
-
this.scales!.yAxes = [this.yAxes0]
|
|
247
|
-
} else if (!this.yAxes1) {
|
|
248
|
-
this.yAxes1 = {
|
|
249
|
-
ticks: {}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
this.config.options!.multiAxis = multiAxis
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
get valuePrefix() {
|
|
257
|
-
return this.series.valuePrefix
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
set valuePrefix(valuePrefix: string | undefined) {
|
|
261
|
-
this.series.valuePrefix = valuePrefix
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
get valueSuffix() {
|
|
265
|
-
return this.series.valueSuffix
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
set valueSuffix(valueSuffix: string | undefined) {
|
|
269
|
-
this.series.valueSuffix = valueSuffix
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
get valueFormat() {
|
|
273
|
-
return this.series.valueFormat
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
set valueFormat(valueFormat: string | undefined) {
|
|
277
|
-
this.series.valueFormat = valueFormat
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
get displayValue() {
|
|
281
|
-
return this.series.displayValue
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
set displayValue(displayValue) {
|
|
285
|
-
this.series.displayValue = displayValue
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
get annotations(): OperatoChart.Annotation[] {
|
|
289
|
-
if (!this.config.options) {
|
|
290
|
-
this.config.options = {}
|
|
291
|
-
}
|
|
292
|
-
if (!this.config.options.annotations) {
|
|
293
|
-
this.config.options.annotations = []
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
return this.config.options.annotations!
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
set annotations(annotations) {
|
|
300
|
-
if (!this.config.options) {
|
|
301
|
-
this.config.options = {}
|
|
302
|
-
}
|
|
303
|
-
if (!this.config.options.annotations) {
|
|
304
|
-
this.config.options.annotations = []
|
|
305
|
-
}
|
|
306
|
-
this.config.options.annotations = annotations
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
get currentAnnotation() {
|
|
310
|
-
return this.annotations[this.currentAnnotationIndex]
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
addSeries(series: OperatoChart.Dataset = {}) {
|
|
314
|
-
this.datasets.push(series)
|
|
315
|
-
this.setCurrentSeriesIndex(this.datasets.length - 1)
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
removeSeries(index: number) {
|
|
319
|
-
if (index >= 0 && index < this.datasets.length) {
|
|
320
|
-
this.datasets.splice(index, 1)
|
|
321
|
-
this.setCurrentSeriesIndex(Math.min(this.currentSeriesIndex, this.datasets.length - 1))
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
addAnnotation(annotation: OperatoChart.Annotation = { type: 'line', x1: 0, y1: 0 }) {
|
|
326
|
-
this.annotations.push(annotation)
|
|
327
|
-
this.setCurrentAnnotationIndex(this.annotations.length - 1)
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
removeAnnotation(index: number) {
|
|
331
|
-
if (index >= 0 && index < this.annotations.length) {
|
|
332
|
-
this.annotations.splice(index, 1)
|
|
333
|
-
this.setCurrentAnnotationIndex(Math.min(this.currentAnnotationIndex, this.annotations.length - 1))
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
}
|