@kiwibit/chart 15.0.1 → 17.0.0
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/README.md +12 -0
- package/{esm2020 → esm2022}/kiwibit-chart.mjs +4 -4
- package/esm2022/lib/chart.component.mjs +456 -0
- package/esm2022/lib/chart.module.mjs +41 -0
- package/{esm2020 → esm2022}/lib/constants/chart.constants.mjs +3 -3
- package/{esm2020 → esm2022}/lib/models/chart.models.mjs +27 -27
- package/{esm2020 → esm2022}/public-api.mjs +7 -7
- package/{fesm2020 → fesm2022}/kiwibit-chart.mjs +485 -437
- package/fesm2022/kiwibit-chart.mjs.map +1 -0
- package/index.d.ts +5 -5
- package/lib/chart.component.d.ts +111 -101
- package/lib/chart.module.d.ts +9 -9
- package/lib/constants/chart.constants.d.ts +3 -3
- package/lib/models/chart.models.d.ts +172 -172
- package/package.json +10 -15
- package/public-api.d.ts +4 -4
- package/esm2020/lib/chart.component.mjs +0 -405
- package/esm2020/lib/chart.module.mjs +0 -43
- package/fesm2015/kiwibit-chart.mjs +0 -495
- package/fesm2015/kiwibit-chart.mjs.map +0 -1
- package/fesm2020/kiwibit-chart.mjs.map +0 -1
|
@@ -1,403 +1,452 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core';
|
|
3
3
|
import { Subject, interval, takeUntil } from 'rxjs';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import { NgxEchartsModule } from 'ngx-echarts';
|
|
4
|
+
import { NgStyle, CommonModule } from '@angular/common';
|
|
5
|
+
import * as i1 from 'ngx-echarts';
|
|
6
|
+
import { NgxEchartsDirective, NgxEchartsModule } from 'ngx-echarts';
|
|
8
7
|
import * as echarts from 'echarts/core';
|
|
9
8
|
import { TitleComponent, TooltipComponent, GridComponent, LegendComponent, DataZoomComponent, ToolboxComponent } from 'echarts/components';
|
|
10
9
|
import { LineChart, ScatterChart } from 'echarts/charts';
|
|
11
10
|
import { CanvasRenderer } from 'echarts/renderers';
|
|
12
11
|
|
|
13
|
-
const ADD_POINT_IMG_OFF_LIGHT = "image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABmJLR0QA/wD/AP+gvaeTAAADkUlEQVR4nO2bz0sUYRjHv8/otviDGDuWrhKdskBaQZi57MmLgVpIkJ06bH9AEdF/kF46dEg726liBSGwBEFnTm0oaF3s4lhdh1BhNuTpsDPLu+MvmHXm0ZzP6X2feWfn+3x33nf3fXlfIOV8Q0dd7O3tvaDr+igzDxPRLQCdANqSkRaZHQBbzPyViEqu65bW19crhzU+1ADDMO4S0QSAq3GoTJAfAJ5alvXhoItN4cDY2FiTruuTRPQSQEfc6hLgEoB7uVyu3XGcBQCsXtxngJ/846TUJYjR3d3dsrm5+VkN1nUB/7V/F7rRI6IpAG9bW1vX5ufnd+JW2giDg4Ntu7u7N5h5HEARQFa9rmna6NLSUimo1wzwB7zvqO/zP4loaHl5eTVu4XFgGEYfEc0BuKKEN1zX7Q0GRi2I6ro+ivrkvbOcPADYtr3CzLcBeEr4WkdHx3BQqRnAzMPqzUQ0dZaTD7BtewXAGzWm5lozgIjyaqO9vb2Z2NUlRziX/qCgKcHLaotsNvstTkVJkslk1kKh2pigGtCutlhcXNyOU1SSHJBLLVcN55xmqQcbhjFERNMA9gA8sizro4QOsTdA07TXqI47XQCmxHRIPZiZO5Vql5SOcz8GpAZIC5AmNUBagDSpAdICpEkNkBYgTWqAtABpUgOkBUgTeT3An89PoX7JOTKmafLxrfZDRFvMXIy6nhD5DfDn8yeSfCP40+rI6wnnvgtENoCZi0S0dZJiIuIQUTHqzZHHAL/PRV7JCfd5y7KO3KsQF2kXkBYgTWqAtABpUgOkBUiTGiAtQJrUAGkB0qQGSAuQJjVA6sGhqbQjpUNyg0SwntDQfL5RxPYINbqecFKkY4BSrttLVygU2vGfMDAwcDEU+hMUVAN+q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qoBP9WMeq32kpOi3GSjFmW10C+jpRhAWWsO3XdUlYtoNehTjxmcMfuMBjGnYIGincl8h9PinKYzme8Aw3KXIcCs1TRgrbmUAjCn5Pl1nSaPsgnGHyYA+MwgocC0PLFzqJ4Qz99i0Puy1ymBkNQ3MVbk0sxh30QdGs01Ndb4ruiEe9ufvK8spScTC+5uAACE4/kRAg04LVQCAobSseATNVbxHJBdDA4CNOKeLJcgGk4vBp5WhPfKDycKPQQeASPgrDKHIRTAGFAve2v3PoQTmTrgTA8Y3QSEsbXB+bA/IK0AWGAgS0CKaXki2x/ZkBblcVj5D1vBAfS1aXiGAAAAAElFTkSuQmCC";
|
|
16
15
|
|
|
17
|
-
var TraceType;
|
|
18
|
-
(function (TraceType) {
|
|
19
|
-
TraceType["LINE"] = "line";
|
|
20
|
-
TraceType["SCATTER"] = "scatter";
|
|
21
|
-
})(TraceType || (TraceType = {}));
|
|
22
|
-
var PointSymbol;
|
|
23
|
-
(function (PointSymbol) {
|
|
24
|
-
PointSymbol["NONE"] = "none";
|
|
25
|
-
PointSymbol["CIRCLE"] = "circle";
|
|
26
|
-
PointSymbol["TRIANGLE"] = "triangle";
|
|
27
|
-
PointSymbol["PIN"] = "pin";
|
|
28
|
-
PointSymbol["DIAMOND"] = "diamond";
|
|
29
|
-
})(PointSymbol || (PointSymbol = {}));
|
|
30
|
-
var TraceStyle;
|
|
31
|
-
(function (TraceStyle) {
|
|
32
|
-
TraceStyle["SOLID"] = "solid";
|
|
33
|
-
TraceStyle["DASHED"] = "dashed";
|
|
34
|
-
TraceStyle["DOTTED"] = "dotted";
|
|
35
|
-
})(TraceStyle || (TraceStyle = {}));
|
|
36
|
-
var AxisType;
|
|
37
|
-
(function (AxisType) {
|
|
38
|
-
AxisType["VALUE"] = "value";
|
|
39
|
-
})(AxisType || (AxisType = {}));
|
|
40
|
-
var ShapeVariant;
|
|
41
|
-
(function (ShapeVariant) {
|
|
42
|
-
ShapeVariant[ShapeVariant["TRACE"] = 0] = "TRACE";
|
|
16
|
+
var TraceType;
|
|
17
|
+
(function (TraceType) {
|
|
18
|
+
TraceType["LINE"] = "line";
|
|
19
|
+
TraceType["SCATTER"] = "scatter";
|
|
20
|
+
})(TraceType || (TraceType = {}));
|
|
21
|
+
var PointSymbol;
|
|
22
|
+
(function (PointSymbol) {
|
|
23
|
+
PointSymbol["NONE"] = "none";
|
|
24
|
+
PointSymbol["CIRCLE"] = "circle";
|
|
25
|
+
PointSymbol["TRIANGLE"] = "triangle";
|
|
26
|
+
PointSymbol["PIN"] = "pin";
|
|
27
|
+
PointSymbol["DIAMOND"] = "diamond";
|
|
28
|
+
})(PointSymbol || (PointSymbol = {}));
|
|
29
|
+
var TraceStyle;
|
|
30
|
+
(function (TraceStyle) {
|
|
31
|
+
TraceStyle["SOLID"] = "solid";
|
|
32
|
+
TraceStyle["DASHED"] = "dashed";
|
|
33
|
+
TraceStyle["DOTTED"] = "dotted";
|
|
34
|
+
})(TraceStyle || (TraceStyle = {}));
|
|
35
|
+
var AxisType;
|
|
36
|
+
(function (AxisType) {
|
|
37
|
+
AxisType["VALUE"] = "value";
|
|
38
|
+
})(AxisType || (AxisType = {}));
|
|
39
|
+
var ShapeVariant;
|
|
40
|
+
(function (ShapeVariant) {
|
|
41
|
+
ShapeVariant[ShapeVariant["TRACE"] = 0] = "TRACE";
|
|
43
42
|
})(ShapeVariant || (ShapeVariant = {}));
|
|
44
43
|
|
|
45
|
-
// Angular General
|
|
46
|
-
class KiwiChartComponent {
|
|
47
|
-
constructor(cd) {
|
|
48
|
-
this.cd = cd;
|
|
49
|
-
/**
|
|
50
|
-
* The Chart Object rendered by the canvas. For all the available options refer
|
|
51
|
-
* to Chart interface in the models folder.
|
|
52
|
-
*
|
|
53
|
-
* @type {(Chart | null)}
|
|
54
|
-
* @memberof KiwiChartComponent
|
|
55
|
-
*/
|
|
56
|
-
this.chart = null;
|
|
57
|
-
/**
|
|
58
|
-
* Width and Height of the chart area. The dimensions refer to the father component
|
|
59
|
-
* into which the kiwi-chart is inserted. For example in an empty page the width/height
|
|
60
|
-
* of the chart can take the whole available space in the page.
|
|
61
|
-
*
|
|
62
|
-
* @type {string}
|
|
63
|
-
* @memberof KiwiChartComponent
|
|
64
|
-
*/
|
|
65
|
-
this.width = '100%';
|
|
66
|
-
this.height = '480px';
|
|
67
|
-
/**
|
|
68
|
-
* This property simply activates or not the dark theme of the chart
|
|
69
|
-
* defined by the Echarts library. In addition the background color can be custom
|
|
70
|
-
* so that the chart can match the background of the application in which it's used.
|
|
71
|
-
*
|
|
72
|
-
* @type {boolean}
|
|
73
|
-
* @memberof KiwiChartComponent
|
|
74
|
-
*/
|
|
75
|
-
this.darkTheme = false;
|
|
76
|
-
/**
|
|
77
|
-
* Output event used to emit to the father component the coordinates
|
|
78
|
-
* of the point clicked in the chart area. This functionality to be used must
|
|
79
|
-
* have the property "clickToAddPoint" in the Chart object set to true.
|
|
80
|
-
*
|
|
81
|
-
* @type {EventEmitter<BasePoint>}
|
|
82
|
-
* @memberof KiwiChartComponent
|
|
83
|
-
*/
|
|
84
|
-
this.addPoint = new EventEmitter();
|
|
85
|
-
/**
|
|
86
|
-
* When the cursor hovers the chart area it emits to the father component the
|
|
87
|
-
* x and y coordinates relative to the chart reference system.
|
|
88
|
-
*
|
|
89
|
-
* @type {EventEmitter<BasePoint>}
|
|
90
|
-
* @memberof KiwiChartComponent
|
|
91
|
-
*/
|
|
92
|
-
this.chartHover = new EventEmitter();
|
|
93
|
-
/**
|
|
94
|
-
* The object used by echarts to initially create the Chart.
|
|
95
|
-
* Has a default configuration that can be totally overrided using specific properties.
|
|
96
|
-
*
|
|
97
|
-
* @type {EChartsOption}
|
|
98
|
-
* @memberof KiwiChartComponent
|
|
99
|
-
*/
|
|
100
|
-
this.chartOption = {
|
|
101
|
-
title: {
|
|
102
|
-
text: 'Kiwi Chart'
|
|
103
|
-
},
|
|
104
|
-
xAxis: {
|
|
105
|
-
name: 'X'
|
|
106
|
-
},
|
|
107
|
-
yAxis: {
|
|
108
|
-
name: 'Y'
|
|
109
|
-
},
|
|
110
|
-
series: [
|
|
111
|
-
{
|
|
112
|
-
type: TraceType.LINE,
|
|
113
|
-
data: [[0, 0]]
|
|
114
|
-
}
|
|
115
|
-
]
|
|
116
|
-
};
|
|
117
|
-
/**
|
|
118
|
-
* The instance of the Chart.
|
|
119
|
-
*
|
|
120
|
-
* @type {(ECharts | null)}
|
|
121
|
-
* @memberof KiwiChartComponent
|
|
122
|
-
*/
|
|
123
|
-
this.echartsInstance = null;
|
|
124
|
-
/**
|
|
125
|
-
* Used to perform actions (as point addition based on the cursor position) on the chart.
|
|
126
|
-
*
|
|
127
|
-
* @type {(zrender.ZRenderType | null)}
|
|
128
|
-
* @memberof KiwiChartComponent
|
|
129
|
-
*/
|
|
130
|
-
this.zr = null;
|
|
131
|
-
/**
|
|
132
|
-
* Subject used to unsubscribe once the component gets destroyed.
|
|
133
|
-
*
|
|
134
|
-
* @private
|
|
135
|
-
* @type {Subject<void>}
|
|
136
|
-
* @memberof KiwiChartComponent
|
|
137
|
-
*/
|
|
138
|
-
this.destroyed$ = new Subject();
|
|
139
|
-
/**
|
|
140
|
-
* Default number of decimals that can have
|
|
141
|
-
* the values on the x and y axes.
|
|
142
|
-
*
|
|
143
|
-
* @private
|
|
144
|
-
* @type {number}
|
|
145
|
-
* @memberof KiwiChartComponent
|
|
146
|
-
*/
|
|
147
|
-
this.MAX_DECIMALS = 3;
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
*
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
this.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
},
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
44
|
+
// Angular General
|
|
45
|
+
class KiwiChartComponent {
|
|
46
|
+
constructor(cd) {
|
|
47
|
+
this.cd = cd;
|
|
48
|
+
/**
|
|
49
|
+
* The Chart Object rendered by the canvas. For all the available options refer
|
|
50
|
+
* to Chart interface in the models folder.
|
|
51
|
+
*
|
|
52
|
+
* @type {(Chart | null)}
|
|
53
|
+
* @memberof KiwiChartComponent
|
|
54
|
+
*/
|
|
55
|
+
this.chart = null;
|
|
56
|
+
/**
|
|
57
|
+
* Width and Height of the chart area. The dimensions refer to the father component
|
|
58
|
+
* into which the kiwi-chart is inserted. For example in an empty page the width/height
|
|
59
|
+
* of the chart can take the whole available space in the page.
|
|
60
|
+
*
|
|
61
|
+
* @type {string}
|
|
62
|
+
* @memberof KiwiChartComponent
|
|
63
|
+
*/
|
|
64
|
+
this.width = '100%';
|
|
65
|
+
this.height = '480px';
|
|
66
|
+
/**
|
|
67
|
+
* This property simply activates or not the dark theme of the chart
|
|
68
|
+
* defined by the Echarts library. In addition the background color can be custom
|
|
69
|
+
* so that the chart can match the background of the application in which it's used.
|
|
70
|
+
*
|
|
71
|
+
* @type {boolean}
|
|
72
|
+
* @memberof KiwiChartComponent
|
|
73
|
+
*/
|
|
74
|
+
this.darkTheme = false;
|
|
75
|
+
/**
|
|
76
|
+
* Output event used to emit to the father component the coordinates
|
|
77
|
+
* of the point clicked in the chart area. This functionality to be used must
|
|
78
|
+
* have the property "clickToAddPoint" in the Chart object set to true.
|
|
79
|
+
*
|
|
80
|
+
* @type {EventEmitter<BasePoint>}
|
|
81
|
+
* @memberof KiwiChartComponent
|
|
82
|
+
*/
|
|
83
|
+
this.addPoint = new EventEmitter();
|
|
84
|
+
/**
|
|
85
|
+
* When the cursor hovers the chart area it emits to the father component the
|
|
86
|
+
* x and y coordinates relative to the chart reference system.
|
|
87
|
+
*
|
|
88
|
+
* @type {EventEmitter<BasePoint>}
|
|
89
|
+
* @memberof KiwiChartComponent
|
|
90
|
+
*/
|
|
91
|
+
this.chartHover = new EventEmitter();
|
|
92
|
+
/**
|
|
93
|
+
* The object used by echarts to initially create the Chart.
|
|
94
|
+
* Has a default configuration that can be totally overrided using specific properties.
|
|
95
|
+
*
|
|
96
|
+
* @type {EChartsOption}
|
|
97
|
+
* @memberof KiwiChartComponent
|
|
98
|
+
*/
|
|
99
|
+
this.chartOption = {
|
|
100
|
+
title: {
|
|
101
|
+
text: 'Kiwi Chart'
|
|
102
|
+
},
|
|
103
|
+
xAxis: {
|
|
104
|
+
name: 'X'
|
|
105
|
+
},
|
|
106
|
+
yAxis: {
|
|
107
|
+
name: 'Y'
|
|
108
|
+
},
|
|
109
|
+
series: [
|
|
110
|
+
{
|
|
111
|
+
type: TraceType.LINE,
|
|
112
|
+
data: [[0, 0]]
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* The instance of the Chart.
|
|
118
|
+
*
|
|
119
|
+
* @type {(ECharts | null)}
|
|
120
|
+
* @memberof KiwiChartComponent
|
|
121
|
+
*/
|
|
122
|
+
this.echartsInstance = null;
|
|
123
|
+
/**
|
|
124
|
+
* Used to perform actions (as point addition based on the cursor position) on the chart.
|
|
125
|
+
*
|
|
126
|
+
* @type {(zrender.ZRenderType | null)}
|
|
127
|
+
* @memberof KiwiChartComponent
|
|
128
|
+
*/
|
|
129
|
+
this.zr = null;
|
|
130
|
+
/**
|
|
131
|
+
* Subject used to unsubscribe once the component gets destroyed.
|
|
132
|
+
*
|
|
133
|
+
* @private
|
|
134
|
+
* @type {Subject<void>}
|
|
135
|
+
* @memberof KiwiChartComponent
|
|
136
|
+
*/
|
|
137
|
+
this.destroyed$ = new Subject();
|
|
138
|
+
/**
|
|
139
|
+
* Default number of decimals that can have
|
|
140
|
+
* the values on the x and y axes.
|
|
141
|
+
*
|
|
142
|
+
* @private
|
|
143
|
+
* @type {number}
|
|
144
|
+
* @memberof KiwiChartComponent
|
|
145
|
+
*/
|
|
146
|
+
this.MAX_DECIMALS = 3;
|
|
147
|
+
this.legendSelected = {};
|
|
148
|
+
this.isLegendClicked = false;
|
|
149
|
+
}
|
|
150
|
+
ngOnInit() {
|
|
151
|
+
/**
|
|
152
|
+
* This is a manual change detection running every 200ms, the memory should not be much afflicted.
|
|
153
|
+
* It's necessary because when interacting with the chart (for example addPoint),
|
|
154
|
+
* Angular loses the change detection and the point is not added in the chart canvas.
|
|
155
|
+
*/
|
|
156
|
+
interval(200)
|
|
157
|
+
.pipe(takeUntil(this.destroyed$))
|
|
158
|
+
.subscribe({
|
|
159
|
+
next: () => {
|
|
160
|
+
this.cd.detectChanges();
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
onChartInit(ec) {
|
|
165
|
+
this.echartsInstance = ec;
|
|
166
|
+
this.setupZrEventHandler(ec);
|
|
167
|
+
this.setupLegendEventHandler(ec);
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* intercept a selection change event on the legend and save the state
|
|
171
|
+
* of all selections on the supporting variable legendSelected
|
|
172
|
+
*
|
|
173
|
+
* @param ec
|
|
174
|
+
*/
|
|
175
|
+
setupLegendEventHandler(ec) {
|
|
176
|
+
if (this.echartsInstance != null) {
|
|
177
|
+
this.echartsInstance.on('legendselectchanged', (params) => {
|
|
178
|
+
this.isLegendClicked = true;
|
|
179
|
+
this.legendSelected = params.selected;
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
setupZrEventHandler(ec) {
|
|
184
|
+
this.zr = ec.getZr();
|
|
185
|
+
/**
|
|
186
|
+
* Intercepts the click event on the chart (if the clickToAddPoint property is set to true)
|
|
187
|
+
* and emits the point coordinates to the father component.
|
|
188
|
+
*/
|
|
189
|
+
this.zr.on('click', params => {
|
|
190
|
+
let option = ec.getOption();
|
|
191
|
+
let active = option?.toolbox?.[0]?.feature?.myAddPoint?.iconStatus;
|
|
192
|
+
if (active && this.chart?.clickToAddPoint) {
|
|
193
|
+
const pointInPixel = [params.offsetX, params.offsetY];
|
|
194
|
+
const pointInGrid = ec.convertFromPixel('grid', pointInPixel);
|
|
195
|
+
if (ec.containPixel('grid', pointInPixel) && pointInGrid) {
|
|
196
|
+
let newPoint = {
|
|
197
|
+
x: +pointInGrid[0].toFixed(3),
|
|
198
|
+
y: +pointInGrid[1].toFixed(3)
|
|
199
|
+
};
|
|
200
|
+
this.addPoint.emit(newPoint);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
/**
|
|
205
|
+
* This is used perform custom actions when the mouse is hovering the chart area
|
|
206
|
+
*/
|
|
207
|
+
this.zr.on('mousemove', params => {
|
|
208
|
+
const pointInPixel = [params.offsetX, params.offsetY];
|
|
209
|
+
const pointInGrid = ec.convertFromPixel('grid', pointInPixel);
|
|
210
|
+
/*
|
|
211
|
+
* Logic to emit to the father component the x and y cdinates when the
|
|
212
|
+
* cursor is hovering the chart area .
|
|
213
|
+
*/
|
|
214
|
+
if (ec.containPixel('grid', pointInPixel) && pointInGrid) {
|
|
215
|
+
let newPoint = {
|
|
216
|
+
x: +pointInGrid[0].toFixed(3),
|
|
217
|
+
y: +pointInGrid[1].toFixed(3)
|
|
218
|
+
};
|
|
219
|
+
this.chartHover.emit(newPoint);
|
|
220
|
+
}
|
|
221
|
+
/* Logic to change the cursor icon when the "Click to Add Point" feature is active and viceversa. */
|
|
222
|
+
const option = ec.getOption();
|
|
223
|
+
const addPointIsActive = option?.toolbox?.[0]?.feature?.myAddPoint?.iconStatus;
|
|
224
|
+
if (addPointIsActive) {
|
|
225
|
+
this.zr?.setCursorStyle(ec.containPixel('grid', pointInPixel) ? 'copy' : 'default');
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
getLegendItemSelection(shape) {
|
|
230
|
+
if (this.isLegendClicked) {
|
|
231
|
+
return this.legendSelected[shape.name] ?? true;
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
return shape.selectedByDefault ?? true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
ngOnChanges(changes) {
|
|
238
|
+
let chart = changes['chart']?.currentValue;
|
|
239
|
+
if (chart) {
|
|
240
|
+
this.chartOption = {
|
|
241
|
+
title: {
|
|
242
|
+
text: chart.title,
|
|
243
|
+
},
|
|
244
|
+
grid: {
|
|
245
|
+
width: '70%'
|
|
246
|
+
},
|
|
247
|
+
backgroundColor: this.darkTheme ? this.darkThemeBackground ?? '#303030' : 'transparent', tooltip: {
|
|
248
|
+
axisPointer: {
|
|
249
|
+
type: 'cross',
|
|
250
|
+
crossStyle: {
|
|
251
|
+
color: '#bebebe'
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
},
|
|
255
|
+
toolbox: {
|
|
256
|
+
orient: 'horizontal',
|
|
257
|
+
left: 'center',
|
|
258
|
+
top: '25px',
|
|
259
|
+
feature: {
|
|
260
|
+
dataZoom: {
|
|
261
|
+
brushStyle: {
|
|
262
|
+
borderColor: '#000',
|
|
263
|
+
borderWidth: 1,
|
|
264
|
+
borderType: 'dashed'
|
|
265
|
+
},
|
|
266
|
+
emphasis: {
|
|
267
|
+
iconStyle: {
|
|
268
|
+
textPosition: 'top'
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
saveAsImage: {
|
|
273
|
+
emphasis: {
|
|
274
|
+
iconStyle: {
|
|
275
|
+
textPosition: 'top'
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
restore: {
|
|
280
|
+
emphasis: {
|
|
281
|
+
iconStyle: {
|
|
282
|
+
textPosition: 'top'
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
myAddPoint: {
|
|
287
|
+
show: chart.clickToAddPoint ?? false,
|
|
288
|
+
title: chart.addPointCustomName ?? 'Add Point',
|
|
289
|
+
icon: this.darkTheme ? ADD_POINT_IMG_OFF_DARK : ADD_POINT_IMG_OFF_LIGHT,
|
|
290
|
+
iconStatus: false,
|
|
291
|
+
onclick: () => {
|
|
292
|
+
let option = this.echartsInstance?.getOption();
|
|
293
|
+
let status = option.toolbox[0].feature.myAddPoint.iconStatus;
|
|
294
|
+
this.echartsInstance?.setOption({
|
|
295
|
+
toolbox: {
|
|
296
|
+
feature: {
|
|
297
|
+
myAddPoint: {
|
|
298
|
+
iconStatus: !status,
|
|
299
|
+
icon: !status ? ADD_POINT_IMG_ON : this.darkTheme ? ADD_POINT_IMG_OFF_DARK : ADD_POINT_IMG_OFF_LIGHT
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
},
|
|
305
|
+
emphasis: {
|
|
306
|
+
iconStyle: {
|
|
307
|
+
textPosition: 'top'
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
dataZoom: [
|
|
314
|
+
{
|
|
315
|
+
type: 'inside',
|
|
316
|
+
xAxisIndex: [0],
|
|
317
|
+
throttle: 0,
|
|
318
|
+
filterMode: 'none',
|
|
319
|
+
disabled: !chart.scrollToZoom
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
type: 'inside',
|
|
323
|
+
yAxisIndex: [0],
|
|
324
|
+
throttle: 0,
|
|
325
|
+
filterMode: 'none',
|
|
326
|
+
disabled: !chart.scrollToZoom
|
|
327
|
+
},
|
|
328
|
+
],
|
|
329
|
+
legend: {
|
|
330
|
+
inactiveColor: this.darkTheme ? '#8b8b8b' : '#ccc',
|
|
331
|
+
data: chart.shapes.map((shape) => ({
|
|
332
|
+
name: shape.name,
|
|
333
|
+
icon: 'circle',
|
|
334
|
+
})),
|
|
335
|
+
selected: chart.shapes.reduce((accumulator, shape) => ({
|
|
336
|
+
...accumulator,
|
|
337
|
+
[shape.name]: this.getLegendItemSelection(shape),
|
|
338
|
+
}), {}),
|
|
339
|
+
show: chart.showLegend ?? false,
|
|
340
|
+
orient: 'vertical',
|
|
341
|
+
left: 'right',
|
|
342
|
+
padding: [60, 20],
|
|
343
|
+
type: 'scroll',
|
|
344
|
+
textStyle: {
|
|
345
|
+
width: 120,
|
|
346
|
+
fontWeight: 'bold',
|
|
347
|
+
overflow: 'break'
|
|
348
|
+
}
|
|
349
|
+
},
|
|
350
|
+
xAxis: {
|
|
351
|
+
type: chart.xAxisType,
|
|
352
|
+
name: chart.xAxisUom ? `${chart.xAxisName} [ ${chart.xAxisUom} ]` : chart.xAxisName,
|
|
353
|
+
nameLocation: 'middle',
|
|
354
|
+
nameGap: 30,
|
|
355
|
+
splitLine: {
|
|
356
|
+
show: chart.showGrid ?? true,
|
|
357
|
+
lineStyle: {
|
|
358
|
+
color: this.darkTheme ? '#595959' : '#ccc'
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
min: chart.xMin?.toFixed(chart.maxAxesDecimals ?? this.MAX_DECIMALS),
|
|
362
|
+
max: chart.xMax?.toFixed(chart.maxAxesDecimals ?? this.MAX_DECIMALS),
|
|
363
|
+
},
|
|
364
|
+
yAxis: {
|
|
365
|
+
type: chart.yAxisType,
|
|
366
|
+
name: chart.yAxisUom ? `${chart.yAxisName} [ ${chart.yAxisUom} ]` : chart.yAxisName,
|
|
367
|
+
nameLocation: 'middle',
|
|
368
|
+
nameGap: 50,
|
|
369
|
+
splitLine: {
|
|
370
|
+
show: chart.showGrid ?? true,
|
|
371
|
+
lineStyle: {
|
|
372
|
+
color: this.darkTheme ? '#595959' : '#ccc'
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
min: chart.yMin?.toFixed(chart.maxAxesDecimals ?? this.MAX_DECIMALS),
|
|
376
|
+
max: chart.yMax?.toFixed(chart.maxAxesDecimals ?? this.MAX_DECIMALS),
|
|
377
|
+
},
|
|
378
|
+
series: this.createSeries(chart.shapes),
|
|
379
|
+
animation: chart.hasAnimations,
|
|
380
|
+
animationDuration: chart.animationDuration ?? 500,
|
|
381
|
+
animationEasing: 'cubicOut'
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
createSeries(shapes) {
|
|
386
|
+
let series = [];
|
|
387
|
+
shapes.forEach((shape) => {
|
|
388
|
+
switch (shape.variant) {
|
|
389
|
+
case ShapeVariant.TRACE:
|
|
390
|
+
series.push(this.createTrace(shape));
|
|
391
|
+
break;
|
|
392
|
+
default:
|
|
393
|
+
break;
|
|
394
|
+
}
|
|
395
|
+
});
|
|
396
|
+
return series;
|
|
397
|
+
}
|
|
398
|
+
createTrace(trace) {
|
|
399
|
+
return {
|
|
400
|
+
type: trace.type,
|
|
401
|
+
name: trace.name,
|
|
402
|
+
data: trace.points.map((point) => ({
|
|
403
|
+
value: [point.x, point.y],
|
|
404
|
+
symbol: point.symbol ?? 'circle',
|
|
405
|
+
name: point.name,
|
|
406
|
+
symbolSize: point.symbolSize ?? 2,
|
|
407
|
+
itemStyle: {
|
|
408
|
+
color: point.color
|
|
409
|
+
},
|
|
410
|
+
emphasis: {
|
|
411
|
+
disabled: true
|
|
412
|
+
},
|
|
413
|
+
label: {
|
|
414
|
+
show: true,
|
|
415
|
+
position: 'bottom',
|
|
416
|
+
align: 'left',
|
|
417
|
+
verticalAlign: 'bottom',
|
|
418
|
+
formatter: () => `${point.name ?? ''}`,
|
|
419
|
+
fontSize: 13,
|
|
420
|
+
padding: [0, 0, 0, 10],
|
|
421
|
+
width: 100,
|
|
422
|
+
overflow: 'truncate',
|
|
423
|
+
ellipsis: '...',
|
|
424
|
+
fontWeight: 'bold',
|
|
425
|
+
color: this.darkTheme ? '#fff' : '#000'
|
|
426
|
+
},
|
|
427
|
+
tooltip: {
|
|
378
428
|
formatter: ({ value }) => `
|
|
379
429
|
<strong>${this.chart?.xAxisName}:</strong> ${value[0].toFixed(3).replace(/[.,]000$/, "")}
|
|
380
430
|
<br>
|
|
381
431
|
<strong>${this.chart?.yAxisName}:</strong> ${value[1].toFixed(3).replace(/[.,]000$/, "")}
|
|
382
|
-
`
|
|
383
|
-
}
|
|
384
|
-
})),
|
|
385
|
-
color: trace.color,
|
|
386
|
-
lineStyle: {
|
|
387
|
-
width: trace.width,
|
|
388
|
-
type: trace.style,
|
|
389
|
-
opacity: trace.opacity ?? 1
|
|
390
|
-
},
|
|
391
|
-
smooth: trace.smooth ?? false
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
ngOnDestroy() {
|
|
395
|
-
this.destroyed$.next();
|
|
396
|
-
this.destroyed$.complete();
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
KiwiChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.0.1", type: KiwiChartComponent, selector: "kiwi-chart", inputs: { chart: "chart", width: "width", height: "height", darkTheme: "darkTheme", darkThemeBackground: "darkThemeBackground" }, outputs: { addPoint: "addPoint", chartHover: "chartHover" }, usesOnChanges: true, ngImport: i0, template: `
|
|
432
|
+
`
|
|
433
|
+
}
|
|
434
|
+
})),
|
|
435
|
+
color: trace.color,
|
|
436
|
+
lineStyle: {
|
|
437
|
+
width: trace.width,
|
|
438
|
+
type: trace.style,
|
|
439
|
+
opacity: trace.opacity ?? 1
|
|
440
|
+
},
|
|
441
|
+
smooth: trace.smooth ?? false
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
ngOnDestroy() {
|
|
445
|
+
this.destroyed$.next();
|
|
446
|
+
this.destroyed$.complete();
|
|
447
|
+
}
|
|
448
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.1", ngImport: i0, type: KiwiChartComponent, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component }); }
|
|
449
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.1", type: KiwiChartComponent, isStandalone: true, selector: "kiwi-chart", inputs: { chart: "chart", width: "width", height: "height", darkTheme: "darkTheme", darkThemeBackground: "darkThemeBackground" }, outputs: { addPoint: "addPoint", chartHover: "chartHover" }, usesOnChanges: true, ngImport: i0, template: `
|
|
401
450
|
<div
|
|
402
451
|
echarts
|
|
403
452
|
[options]="chartOption"
|
|
@@ -408,9 +457,10 @@ KiwiChartComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", ver
|
|
|
408
457
|
(chartInit)="onChartInit($event)"
|
|
409
458
|
[theme]="darkTheme ? 'dark' : ''"
|
|
410
459
|
></div>
|
|
411
|
-
`, isInline: true, styles: [""], dependencies: [{ kind: "directive", type:
|
|
412
|
-
|
|
413
|
-
|
|
460
|
+
`, isInline: true, styles: [""], dependencies: [{ kind: "directive", type: NgxEchartsDirective, selector: "echarts, [echarts]", inputs: ["options", "theme", "initOpts", "merge", "autoResize", "loading", "loadingType", "loadingOpts"], outputs: ["chartInit", "optionsError", "chartClick", "chartDblClick", "chartMouseDown", "chartMouseMove", "chartMouseUp", "chartMouseOver", "chartMouseOut", "chartGlobalOut", "chartContextMenu", "chartHighlight", "chartDownplay", "chartSelectChanged", "chartLegendSelectChanged", "chartLegendSelected", "chartLegendUnselected", "chartLegendLegendSelectAll", "chartLegendLegendInverseSelect", "chartLegendScroll", "chartDataZoom", "chartDataRangeSelected", "chartGraphRoam", "chartGeoRoam", "chartTreeRoam", "chartTimelineChanged", "chartTimelinePlayChanged", "chartRestore", "chartDataViewChanged", "chartMagicTypeChanged", "chartGeoSelectChanged", "chartGeoSelected", "chartGeoUnselected", "chartAxisAreaSelected", "chartBrush", "chartBrushEnd", "chartBrushSelected", "chartGlobalCursorTaken", "chartRendered", "chartFinished"], exportAs: ["echarts"] }, { kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }] }); }
|
|
461
|
+
}
|
|
462
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.1", ngImport: i0, type: KiwiChartComponent, decorators: [{
|
|
463
|
+
type: Component,
|
|
414
464
|
args: [{ selector: 'kiwi-chart', template: `
|
|
415
465
|
<div
|
|
416
466
|
echarts
|
|
@@ -422,62 +472,60 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.0.1", ngImpor
|
|
|
422
472
|
(chartInit)="onChartInit($event)"
|
|
423
473
|
[theme]="darkTheme ? 'dark' : ''"
|
|
424
474
|
></div>
|
|
425
|
-
|
|
426
|
-
}], ctorParameters:
|
|
427
|
-
type: Input
|
|
428
|
-
}], width: [{
|
|
429
|
-
type: Input
|
|
430
|
-
}], height: [{
|
|
431
|
-
type: Input
|
|
432
|
-
}], darkTheme: [{
|
|
433
|
-
type: Input
|
|
434
|
-
}], darkThemeBackground: [{
|
|
435
|
-
type: Input
|
|
436
|
-
}], addPoint: [{
|
|
437
|
-
type: Output
|
|
438
|
-
}], chartHover: [{
|
|
439
|
-
type: Output
|
|
475
|
+
`, standalone: true, imports: [NgxEchartsDirective, NgStyle] }]
|
|
476
|
+
}], ctorParameters: () => [{ type: i0.ChangeDetectorRef }], propDecorators: { chart: [{
|
|
477
|
+
type: Input
|
|
478
|
+
}], width: [{
|
|
479
|
+
type: Input
|
|
480
|
+
}], height: [{
|
|
481
|
+
type: Input
|
|
482
|
+
}], darkTheme: [{
|
|
483
|
+
type: Input
|
|
484
|
+
}], darkThemeBackground: [{
|
|
485
|
+
type: Input
|
|
486
|
+
}], addPoint: [{
|
|
487
|
+
type: Output
|
|
488
|
+
}], chartHover: [{
|
|
489
|
+
type: Output
|
|
440
490
|
}] } });
|
|
441
491
|
|
|
442
|
-
echarts.use([
|
|
443
|
-
TitleComponent,
|
|
444
|
-
TooltipComponent,
|
|
445
|
-
GridComponent,
|
|
446
|
-
LineChart,
|
|
447
|
-
CanvasRenderer,
|
|
448
|
-
LegendComponent,
|
|
449
|
-
DataZoomComponent,
|
|
450
|
-
ToolboxComponent,
|
|
451
|
-
ScatterChart
|
|
452
|
-
]);
|
|
453
|
-
class KiwiChartModule {
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
460
|
-
type: NgModule,
|
|
461
|
-
args: [{
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
]
|
|
472
|
-
}]
|
|
492
|
+
echarts.use([
|
|
493
|
+
TitleComponent,
|
|
494
|
+
TooltipComponent,
|
|
495
|
+
GridComponent,
|
|
496
|
+
LineChart,
|
|
497
|
+
CanvasRenderer,
|
|
498
|
+
LegendComponent,
|
|
499
|
+
DataZoomComponent,
|
|
500
|
+
ToolboxComponent,
|
|
501
|
+
ScatterChart
|
|
502
|
+
]);
|
|
503
|
+
class KiwiChartModule {
|
|
504
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.1", ngImport: i0, type: KiwiChartModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
505
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.3.1", ngImport: i0, type: KiwiChartModule, imports: [CommonModule, i1.NgxEchartsModule, KiwiChartComponent], exports: [KiwiChartComponent] }); }
|
|
506
|
+
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.3.1", ngImport: i0, type: KiwiChartModule, imports: [CommonModule,
|
|
507
|
+
NgxEchartsModule.forRoot({ echarts })] }); }
|
|
508
|
+
}
|
|
509
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.1", ngImport: i0, type: KiwiChartModule, decorators: [{
|
|
510
|
+
type: NgModule,
|
|
511
|
+
args: [{
|
|
512
|
+
imports: [
|
|
513
|
+
CommonModule,
|
|
514
|
+
NgxEchartsModule.forRoot({ echarts }),
|
|
515
|
+
KiwiChartComponent
|
|
516
|
+
],
|
|
517
|
+
exports: [
|
|
518
|
+
KiwiChartComponent
|
|
519
|
+
]
|
|
520
|
+
}]
|
|
473
521
|
}] });
|
|
474
522
|
|
|
475
|
-
/*
|
|
476
|
-
* Public API Surface of chart
|
|
523
|
+
/*
|
|
524
|
+
* Public API Surface of chart
|
|
477
525
|
*/
|
|
478
526
|
|
|
479
|
-
/**
|
|
480
|
-
* Generated bundle index. Do not edit.
|
|
527
|
+
/**
|
|
528
|
+
* Generated bundle index. Do not edit.
|
|
481
529
|
*/
|
|
482
530
|
|
|
483
531
|
export { ADD_POINT_IMG_OFF_DARK, ADD_POINT_IMG_OFF_LIGHT, ADD_POINT_IMG_ON, AxisType, KiwiChartComponent, KiwiChartModule, PointSymbol, ShapeVariant, TraceStyle, TraceType };
|