@operato/chart 7.1.31 → 7.1.33
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/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -9
- 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/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 -490
- 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
- /package/{src → types}/global.d.ts +0 -0
- /package/{src → types}/types.d.ts +0 -0
|
@@ -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
|
-
}
|
package/src/editors/index.ts
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import '@operato/i18n/ox-i18n.js'
|
|
2
|
-
|
|
3
|
-
import { html, PropertyValues } from 'lit'
|
|
4
|
-
import { property } from 'lit/decorators.js'
|
|
5
|
-
|
|
6
|
-
import { random as randomColor, TinyColor } from '@ctrl/tinycolor'
|
|
7
|
-
|
|
8
|
-
import { InputChartStyles } from './input-chart-styles'
|
|
9
|
-
import { Configurer } from './configurer'
|
|
10
|
-
import { OxFormField } from '@operato/input'
|
|
11
|
-
|
|
12
|
-
export class InputChartAbstract extends OxFormField {
|
|
13
|
-
static styles = [InputChartStyles]
|
|
14
|
-
|
|
15
|
-
@property({ type: Object }) value: OperatoChart.ChartConfig | null = null
|
|
16
|
-
@property({ type: String, attribute: 'chart-type' }) chartType?: OperatoChart.ChartType
|
|
17
|
-
|
|
18
|
-
private _configurer?: Configurer
|
|
19
|
-
|
|
20
|
-
get configurer(): Configurer {
|
|
21
|
-
if (!this._configurer) {
|
|
22
|
-
this._configurer = new Configurer(this.value, () => {
|
|
23
|
-
return this.value || this.getDefaultChartConfig(this.chartType, this.getDefaultDatasets())
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
return this._configurer
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
updated(changes: PropertyValues<this>) {
|
|
30
|
-
if (changes.has('value')) {
|
|
31
|
-
this.configurer.updateValue(this.value!)
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
render() {
|
|
36
|
-
const configurer = this.configurer
|
|
37
|
-
|
|
38
|
-
return html`
|
|
39
|
-
<legend><ox-i18n msgid="label.chart">Chart</ox-i18n></legend>
|
|
40
|
-
|
|
41
|
-
<label for="theme"> <ox-i18n msgid="label.theme">Theme</ox-i18n> </label>
|
|
42
|
-
<select id="theme" value-key="theme" class="select-content" .value=${configurer.theme || 'light'}>
|
|
43
|
-
<option value="auto">auto</option>
|
|
44
|
-
<option value="dark">dark</option>
|
|
45
|
-
<option value="light" checked>light</option>
|
|
46
|
-
</select>
|
|
47
|
-
|
|
48
|
-
<input id="tooltip" type="checkbox" value-key="tooltip" ?checked=${configurer.tooltip} />
|
|
49
|
-
<label for="tooltip"> <ox-i18n msgid="label.tooltip">Tooltip</ox-i18n> </label>
|
|
50
|
-
|
|
51
|
-
<input id="animation" type="checkbox" value-key="animation" ?checked=${configurer.animation} />
|
|
52
|
-
<label for="animation"> <ox-i18n msgid="label.animation">Animation</ox-i18n> </label>
|
|
53
|
-
|
|
54
|
-
<input id="display" type="checkbox" value-key="display" ?checked=${configurer.display} />
|
|
55
|
-
<label for="display"> <ox-i18n msgid="label.legend">Legend</ox-i18n> </label>
|
|
56
|
-
|
|
57
|
-
<input id="stacked" type="checkbox" value-key="stacked" ?checked=${configurer.stacked} />
|
|
58
|
-
<label for="stacked"> <ox-i18n msgid="label.stacked">Stacked</ox-i18n> </label>
|
|
59
|
-
|
|
60
|
-
${configurer.display
|
|
61
|
-
? html`
|
|
62
|
-
<label for="position"> <ox-i18n msgid="label.position">Position</ox-i18n> </label>
|
|
63
|
-
<select id="position" value-key="position" class="select-content" .value=${configurer.position || ''}>
|
|
64
|
-
<option value="top">top</option>
|
|
65
|
-
<option value="right">right</option>
|
|
66
|
-
<option value="bottom">bottom</option>
|
|
67
|
-
<option value="left">left</option>
|
|
68
|
-
</select>
|
|
69
|
-
`
|
|
70
|
-
: html``}
|
|
71
|
-
${this.subTemplate()}
|
|
72
|
-
`
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
connectedCallback() {
|
|
76
|
-
super.connectedCallback()
|
|
77
|
-
|
|
78
|
-
this.renderRoot.addEventListener('change', this.onValuesChanged.bind(this))
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
subTemplate() {
|
|
82
|
-
return html``
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
getDefaultDatasets(): OperatoChart.Dataset[] {
|
|
86
|
-
return [this.getDefaultDataset('bar')]
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
getDefaultDataset(seriesType: 'bar' | 'horizontalBar' | 'line' | 'radar' | 'pie'): OperatoChart.Dataset {
|
|
90
|
-
return {
|
|
91
|
-
label: 'Series 1',
|
|
92
|
-
data: [],
|
|
93
|
-
borderWidth: 1,
|
|
94
|
-
dataKey: '',
|
|
95
|
-
yAxisID: 'left',
|
|
96
|
-
color: randomColor({
|
|
97
|
-
hue: new TinyColor('#fff').clone().toString()
|
|
98
|
-
}).toRgbString(),
|
|
99
|
-
backgroundColor: '#FFFFFF',
|
|
100
|
-
type: seriesType,
|
|
101
|
-
stack: '',
|
|
102
|
-
fill: false,
|
|
103
|
-
lineTension: 0.4,
|
|
104
|
-
pointStyle: 'circle',
|
|
105
|
-
pointRadius: 3,
|
|
106
|
-
valuePrefix: '',
|
|
107
|
-
valueSuffix: '',
|
|
108
|
-
displayValue: false
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
getDefaultChartConfig(type?: OperatoChart.ChartType, datasets?: OperatoChart.Dataset[]): OperatoChart.ChartConfig {
|
|
113
|
-
return {
|
|
114
|
-
data: {
|
|
115
|
-
datasets: datasets || [],
|
|
116
|
-
labelDataKey: ''
|
|
117
|
-
},
|
|
118
|
-
options: {
|
|
119
|
-
theme: 'light',
|
|
120
|
-
tooltip: true,
|
|
121
|
-
animation: true,
|
|
122
|
-
legend: {
|
|
123
|
-
display: true,
|
|
124
|
-
position: 'top'
|
|
125
|
-
},
|
|
126
|
-
scales: {
|
|
127
|
-
xAxes: [this.getDefaultAxisOptions()],
|
|
128
|
-
yAxes: [this.getDefaultAxisOptions()]
|
|
129
|
-
},
|
|
130
|
-
stacked: false,
|
|
131
|
-
xGridLine: true,
|
|
132
|
-
yGridLine: true,
|
|
133
|
-
y2ndGridLine: false,
|
|
134
|
-
multiAxis: false
|
|
135
|
-
},
|
|
136
|
-
type
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
getDefaultAxisOptions(): OperatoChart.AxisOptions {
|
|
141
|
-
return {
|
|
142
|
-
axisTitle: '',
|
|
143
|
-
barSpacing: 0,
|
|
144
|
-
categorySpacing: 0,
|
|
145
|
-
barPercentage: 0.9,
|
|
146
|
-
ticks: {
|
|
147
|
-
display: true,
|
|
148
|
-
autoMin: true,
|
|
149
|
-
autoMax: true,
|
|
150
|
-
min: undefined,
|
|
151
|
-
max: undefined,
|
|
152
|
-
stepSize: undefined
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
onValuesChanged(e: Event) {
|
|
158
|
-
e.stopPropagation()
|
|
159
|
-
|
|
160
|
-
const element = e.target as HTMLInputElement
|
|
161
|
-
let key = element.getAttribute('value-key')
|
|
162
|
-
let value = element.value
|
|
163
|
-
|
|
164
|
-
if (!key) {
|
|
165
|
-
return
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
value = this._getElementValue(element)
|
|
169
|
-
|
|
170
|
-
const attrs = key.split('.')
|
|
171
|
-
let attr = attrs.shift() || ''
|
|
172
|
-
let variable: any = this.configurer
|
|
173
|
-
|
|
174
|
-
while (attrs.length > 0) {
|
|
175
|
-
variable = variable[attr]
|
|
176
|
-
attr = attrs.shift() || ''
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
variable[attr] = value
|
|
180
|
-
|
|
181
|
-
this.value = { ...this.configurer.value }
|
|
182
|
-
|
|
183
|
-
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }))
|
|
184
|
-
this.requestUpdate()
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
_getElementValue(element: HTMLElement) {
|
|
188
|
-
switch (element.tagName) {
|
|
189
|
-
case 'INPUT':
|
|
190
|
-
switch ((element as HTMLInputElement).type) {
|
|
191
|
-
case 'checkbox':
|
|
192
|
-
return (element as HTMLInputElement).checked
|
|
193
|
-
case 'number':
|
|
194
|
-
return Number((element as HTMLInputElement).value) || 0
|
|
195
|
-
case 'text':
|
|
196
|
-
return String((element as HTMLInputElement).value)
|
|
197
|
-
}
|
|
198
|
-
default:
|
|
199
|
-
return (element as any).value
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|