@vaadin/charts 24.7.0-alpha7 → 24.7.0-alpha8
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/package.json +11 -8
- package/src/helpers.js +20 -0
- package/src/vaadin-chart-mixin.d.ts +439 -0
- package/src/vaadin-chart-mixin.js +1698 -0
- package/src/vaadin-chart-series-mixin.d.ts +136 -0
- package/src/vaadin-chart-series-mixin.js +412 -0
- package/src/vaadin-chart-series.d.ts +3 -120
- package/src/vaadin-chart-series.js +3 -383
- package/src/vaadin-chart.d.ts +3 -423
- package/src/vaadin-chart.js +4 -1679
- package/src/vaadin-lit-chart-series.d.ts +11 -0
- package/src/vaadin-lit-chart-series.js +33 -0
- package/src/vaadin-lit-chart.d.ts +11 -0
- package/src/vaadin-lit-chart.js +61 -0
- package/theme/lumo/vaadin-lit-chart.d.ts +2 -0
- package/theme/lumo/vaadin-lit-chart.js +2 -0
- package/theme/material/vaadin-lit-chart.d.ts +2 -0
- package/theme/material/vaadin-lit-chart.js +2 -0
- package/vaadin-lit-chart-series.d.ts +1 -0
- package/vaadin-lit-chart-series.js +1 -0
- package/vaadin-lit-chart.d.ts +1 -0
- package/vaadin-lit-chart.js +2 -0
- package/web-types.json +228 -228
- package/web-types.lit.json +85 -85
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { PolymerElement } from '@polymer/polymer/polymer-element.js';
|
|
12
12
|
import { defineCustomElement } from '@vaadin/component-base/src/define.js';
|
|
13
|
-
import {
|
|
13
|
+
import { ChartSeriesMixin } from './vaadin-chart-series-mixin.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* `<vaadin-chart-series>` is a custom element for creating series for Vaadin Charts.
|
|
@@ -57,392 +57,12 @@ import { Chart, deepMerge } from './vaadin-chart.js';
|
|
|
57
57
|
*
|
|
58
58
|
* @customElement
|
|
59
59
|
* @extends HTMLElement
|
|
60
|
+
* @mixes ChartSeriesMixin
|
|
60
61
|
*/
|
|
61
|
-
class ChartSeries extends PolymerElement {
|
|
62
|
+
class ChartSeries extends ChartSeriesMixin(PolymerElement) {
|
|
62
63
|
static get is() {
|
|
63
64
|
return 'vaadin-chart-series';
|
|
64
65
|
}
|
|
65
|
-
|
|
66
|
-
static get properties() {
|
|
67
|
-
return {
|
|
68
|
-
/**
|
|
69
|
-
* An array of data used by the series.
|
|
70
|
-
* Format depends on the chart type and can be:
|
|
71
|
-
* - An array of numerical values `[y0, y1, y2, y3,...]`
|
|
72
|
-
* - An array of arrays with 2 values (`x`, `y`) `[ [x0, y0], [x1, y1], [x2, y2], ... ]`
|
|
73
|
-
* - An array of objects, each one describing one point `[ {x: x0, y: y0, name: 'Point0', color: '#FF0000'}, {...}, ...]`
|
|
74
|
-
*
|
|
75
|
-
* See more in [API Site](https://api.highcharts.com/highcharts/series)
|
|
76
|
-
*
|
|
77
|
-
* Note that you should always use [Polymer API](https://www.polymer-project.org/2.0/docs/devguide/model-data#array-mutation)
|
|
78
|
-
* to mutate the values array in order to make the component aware of the
|
|
79
|
-
* change and be able to synchronize it.
|
|
80
|
-
* @type {ChartSeriesValues}
|
|
81
|
-
*/
|
|
82
|
-
values: {
|
|
83
|
-
type: Array,
|
|
84
|
-
value: () => [],
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Value-axis minimum-value.
|
|
89
|
-
* Sets the value to a series bound by 'unit' property.
|
|
90
|
-
* Otherwise sets the value to the first series.
|
|
91
|
-
* Undefined by default (determined from data).
|
|
92
|
-
* @attr {number} value-min
|
|
93
|
-
*/
|
|
94
|
-
valueMin: {
|
|
95
|
-
type: Number,
|
|
96
|
-
reflectToAttribute: true,
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Value-axis maximum-value.
|
|
101
|
-
* See the 'valueMin'
|
|
102
|
-
* @attr {number} value-max
|
|
103
|
-
*/
|
|
104
|
-
valueMax: {
|
|
105
|
-
type: Number,
|
|
106
|
-
reflectToAttribute: true,
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* A string with the type of the series.
|
|
111
|
-
* Defaults to `'line'` in case no type is set for the chart.
|
|
112
|
-
* Note that `'bar'`, `'gauge'` and `'solidgauge'` should be set as default series type on `<vaadin-chart>`.
|
|
113
|
-
*/
|
|
114
|
-
type: {
|
|
115
|
-
type: String,
|
|
116
|
-
reflectToAttribute: true,
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* The name of the series as shown in the legend, tooltip etc.
|
|
121
|
-
* @type {string}
|
|
122
|
-
*/
|
|
123
|
-
title: {
|
|
124
|
-
type: String,
|
|
125
|
-
reflectToAttribute: true,
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Shows/hides data-point markers for line-like series.
|
|
130
|
-
* Acceptable input are:
|
|
131
|
-
* - `shown`: markers are always visible
|
|
132
|
-
* - `hidden`: markers are always hidden
|
|
133
|
-
* - `auto`: markers are visible for widespread data and hidden, when data is dense *(default)*
|
|
134
|
-
* @type {ChartSeriesMarkers | undefined}
|
|
135
|
-
*/
|
|
136
|
-
markers: {
|
|
137
|
-
type: String,
|
|
138
|
-
reflectToAttribute: true,
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
/**
|
|
142
|
-
* Used to connect the series to an axis; if multiple series have the same `unit`, they will share axis.
|
|
143
|
-
* Displayed as a title for the axis.
|
|
144
|
-
* If no unit is defined, then series will be connected to the first axis.
|
|
145
|
-
*/
|
|
146
|
-
unit: {
|
|
147
|
-
type: String,
|
|
148
|
-
reflectToAttribute: true,
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Used to group series in a different stacks.
|
|
153
|
-
* "stacking" property should be specified either for each series or in plotOptions.
|
|
154
|
-
* It is recommended to place series in a single stack, when they belong to the same yAxis.
|
|
155
|
-
* @type {number | string}
|
|
156
|
-
*/
|
|
157
|
-
stack: {
|
|
158
|
-
type: String,
|
|
159
|
-
reflectToAttribute: true,
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* The height of the neck, the lower part of the funnel.
|
|
164
|
-
* A number defines pixel width, a percentage string defines a percentage of the plot area height. Defaults to 30%.
|
|
165
|
-
* Note that this property only applies for "funnel" charts.
|
|
166
|
-
* @attr {number | string} neck-position
|
|
167
|
-
* @type {number | string}
|
|
168
|
-
*/
|
|
169
|
-
neckPosition: {
|
|
170
|
-
type: String,
|
|
171
|
-
reflectToAttribute: true,
|
|
172
|
-
},
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* The width of the neck, the lower part of the funnel.
|
|
176
|
-
* A number defines pixel width, a percentage string defines a percentage of the plot area width. Defaults to 30%.
|
|
177
|
-
* Note that this property only applies for "funnel" charts.
|
|
178
|
-
* @attr {number | string} neck-width
|
|
179
|
-
* @type {number | string}
|
|
180
|
-
*/
|
|
181
|
-
neckWidth: {
|
|
182
|
-
type: String,
|
|
183
|
-
reflectToAttribute: true,
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Object with the configured options defined and used to create a series.
|
|
188
|
-
* @type {!ChartSeriesOptions}
|
|
189
|
-
* @readonly
|
|
190
|
-
*/
|
|
191
|
-
options: {
|
|
192
|
-
type: Object,
|
|
193
|
-
},
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Represents additional JSON configuration.
|
|
197
|
-
* @type {SeriesOptionsType | undefined}
|
|
198
|
-
*/
|
|
199
|
-
additionalOptions: {
|
|
200
|
-
type: Object,
|
|
201
|
-
reflectToAttribute: true,
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* @type {!Series | undefined}
|
|
206
|
-
* @protected
|
|
207
|
-
*/
|
|
208
|
-
_series: {
|
|
209
|
-
type: Object,
|
|
210
|
-
},
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
static get observers() {
|
|
215
|
-
return [
|
|
216
|
-
'__additionalOptionsObserver(additionalOptions.*, _series)',
|
|
217
|
-
'__markersObserver(markers, _series)',
|
|
218
|
-
'__neckPositionObserver(neckPosition, _series)',
|
|
219
|
-
'__neckWidthObserver(neckWidth, _series)',
|
|
220
|
-
'__stackObserver(stack, _series)',
|
|
221
|
-
'__titleObserver(title, _series)',
|
|
222
|
-
'__typeObserver(type, _series)',
|
|
223
|
-
'__unitObserver(unit, valueMin, valueMax, _series)',
|
|
224
|
-
'__valueMinObserver(valueMin, _series)',
|
|
225
|
-
'__valueMaxObserver(valueMax, _series)',
|
|
226
|
-
'__valuesObserver(values.splices, _series)',
|
|
227
|
-
];
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
get options() {
|
|
231
|
-
const options = deepMerge({}, this.additionalOptions);
|
|
232
|
-
|
|
233
|
-
if (this.type) {
|
|
234
|
-
options.type = this.type;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
if (this.title) {
|
|
238
|
-
options.name = this.title;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
if (this.values) {
|
|
242
|
-
options.data = this.values;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (this.markers) {
|
|
246
|
-
if (!this.__isMarkersValid()) {
|
|
247
|
-
this.markers = 'auto';
|
|
248
|
-
}
|
|
249
|
-
options.marker = this.__markersConfiguration;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
if (this.unit) {
|
|
253
|
-
options.yAxis = this.unit;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (this.stack) {
|
|
257
|
-
options.stack = this.stack;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (isFinite(this.valueMin)) {
|
|
261
|
-
options.yAxisValueMin = this.valueMin;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (isFinite(this.valueMax)) {
|
|
265
|
-
options.yAxisValueMax = this.valueMax;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
if (this.neckWidth) {
|
|
269
|
-
options.neckWidth = this.neckWidth;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
if (this.neckPosition) {
|
|
273
|
-
options.neckHeight = this.neckPosition;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return options;
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/** @private */
|
|
280
|
-
get __markersConfiguration() {
|
|
281
|
-
const config = {};
|
|
282
|
-
switch (this.markers) {
|
|
283
|
-
case 'shown':
|
|
284
|
-
config.enabled = true;
|
|
285
|
-
break;
|
|
286
|
-
case 'hidden':
|
|
287
|
-
config.enabled = false;
|
|
288
|
-
break;
|
|
289
|
-
case 'auto':
|
|
290
|
-
default:
|
|
291
|
-
config.enabled = null;
|
|
292
|
-
break;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return config;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
/**
|
|
299
|
-
* Method to attach a series object of type `Highcharts.Series`.
|
|
300
|
-
* @param {!Series} series Object of type `Highcharts.Series`
|
|
301
|
-
*/
|
|
302
|
-
setSeries(series) {
|
|
303
|
-
this._series = series;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
/** @private */
|
|
307
|
-
__valuesObserver(_splices, series) {
|
|
308
|
-
if (series) {
|
|
309
|
-
series.setData(this.values);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/** @private */
|
|
314
|
-
__additionalOptionsObserver(additionalOptions, series) {
|
|
315
|
-
if (series && additionalOptions.base) {
|
|
316
|
-
series.update(additionalOptions.base);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/** @private */
|
|
321
|
-
__updateAxis(series, value, key) {
|
|
322
|
-
if (!isFinite(value)) {
|
|
323
|
-
this.__showWarn(`value-${key}`, 'Numbers or null');
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
if (series && series.yAxis) {
|
|
328
|
-
series.yAxis.update({ [key]: value });
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
/** @private */
|
|
333
|
-
__valueMinObserver(valueMin, series) {
|
|
334
|
-
if (valueMin === undefined || series == null) {
|
|
335
|
-
return;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
this.__updateAxis(series, valueMin, 'min');
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
/** @private */
|
|
342
|
-
__valueMaxObserver(valueMax, series) {
|
|
343
|
-
if (valueMax === undefined || series == null) {
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
this.__updateAxis(series, valueMax, 'max');
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/** @private */
|
|
351
|
-
__typeObserver(type, series) {
|
|
352
|
-
if (type && series) {
|
|
353
|
-
series.update({ type });
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/** @private */
|
|
358
|
-
__titleObserver(title, series) {
|
|
359
|
-
if (title === undefined || series == null) {
|
|
360
|
-
return;
|
|
361
|
-
}
|
|
362
|
-
series.update({ name: title });
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/** @private */
|
|
366
|
-
__stackObserver(stack, series) {
|
|
367
|
-
if (stack === undefined || series == null) {
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
series.update({ stack });
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
/** @private */
|
|
374
|
-
__neckPositionObserver(neckPosition, series) {
|
|
375
|
-
if (neckPosition === undefined || series == null) {
|
|
376
|
-
return;
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
series.update({ neckHeight: neckPosition });
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/** @private */
|
|
383
|
-
__neckWidthObserver(neckWidth, series) {
|
|
384
|
-
if (neckWidth === undefined || series == null) {
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
series.update({ neckWidth });
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
/** @private */
|
|
392
|
-
__unitObserver(unit, valueMin, valueMax, series) {
|
|
393
|
-
if (series && unit !== this.__oldUnit) {
|
|
394
|
-
this.__oldUnit = unit;
|
|
395
|
-
|
|
396
|
-
const parent = this.parentNode instanceof Chart && this.parentNode;
|
|
397
|
-
if (parent && parent instanceof Chart) {
|
|
398
|
-
if (unit && !parent.__getAxis(unit)) {
|
|
399
|
-
const title = { title: { text: unit } };
|
|
400
|
-
parent.__addAxis({ id: unit, axisGenerated: true, ...title });
|
|
401
|
-
}
|
|
402
|
-
series.update({ yAxis: unit || 0 });
|
|
403
|
-
|
|
404
|
-
if (valueMin !== undefined) {
|
|
405
|
-
this.__updateAxis(series, valueMin, 'min');
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if (valueMax !== undefined) {
|
|
409
|
-
this.__updateAxis(series, valueMax, 'max');
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
parent.__removeAxisIfEmpty();
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
/** @private */
|
|
418
|
-
__isMarkersValid() {
|
|
419
|
-
if (['shown', 'hidden', 'auto'].indexOf(this.markers) === -1) {
|
|
420
|
-
this.__showWarn('markers', '"shown", "hidden" or "auto"');
|
|
421
|
-
return false;
|
|
422
|
-
}
|
|
423
|
-
return true;
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
/** @private */
|
|
427
|
-
__markersObserver(markers, series) {
|
|
428
|
-
if (markers === undefined || series == null) {
|
|
429
|
-
return;
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
if (!this.__isMarkersValid()) {
|
|
433
|
-
this.markers = 'auto';
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
series.update({
|
|
438
|
-
marker: this.__markersConfiguration,
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
/** @private */
|
|
443
|
-
__showWarn(propertyName, acceptedValues) {
|
|
444
|
-
console.warn(`<vaadin-chart-series> Acceptable values for "${propertyName}" are ${acceptedValues}`);
|
|
445
|
-
}
|
|
446
66
|
}
|
|
447
67
|
|
|
448
68
|
defineCustomElement(ChartSeries);
|