@vaadin/vaadin-charts 22.0.0-alpha6 → 22.0.0-beta1

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.
File without changes
package/package.json CHANGED
@@ -1,10 +1,29 @@
1
1
  {
2
2
  "name": "@vaadin/vaadin-charts",
3
- "version": "22.0.0-alpha6",
3
+ "version": "22.0.0-beta1",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
4
7
  "description": "vaadin-charts",
8
+ "license": "https://raw.githubusercontent.com/vaadin/web-components/master/packages/vaadin-charts/LICENSE",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/vaadin/web-components.git",
12
+ "directory": "packages/vaadin-charts"
13
+ },
14
+ "author": "Vaadin Ltd",
15
+ "homepage": "https://vaadin.com/charts",
16
+ "bugs": {
17
+ "url": "https://github.com/vaadin/vaadin-charts/issues"
18
+ },
5
19
  "main": "vaadin-chart.js",
6
20
  "module": "vaadin-chart.js",
7
- "repository": "vaadin/vaadin-charts",
21
+ "files": [
22
+ "src",
23
+ "theme",
24
+ "vaadin-*.d.ts",
25
+ "vaadin-*.js"
26
+ ],
8
27
  "keywords": [
9
28
  "Vaadin",
10
29
  "vaadin-charts",
@@ -12,32 +31,8 @@
12
31
  "web-component",
13
32
  "polymer"
14
33
  ],
15
- "author": "Vaadin Ltd",
16
- "license": "SEE LICENSE IN LICENSE.txt",
17
- "bugs": {
18
- "url": "https://github.com/vaadin/vaadin-charts/issues"
19
- },
20
- "homepage": "https://vaadin.com/charts",
21
- "files": [
22
- "vaadin-*.d.ts",
23
- "vaadin-*.js",
24
- "src",
25
- "theme"
26
- ],
27
34
  "dependencies": {
28
- "@polymer/polymer": "^3.0.0",
29
- "@vaadin/vaadin-element-mixin": "^22.0.0-alpha6",
30
- "@vaadin/vaadin-license-checker": "^2.1.0",
31
- "@vaadin/vaadin-themable-mixin": "^22.0.0-alpha6",
32
- "highcharts": "9.2.2"
33
- },
34
- "devDependencies": {
35
- "@esm-bundle/chai": "^4.3.4",
36
- "@vaadin/testing-helpers": "^0.3.0",
37
- "sinon": "^9.2.4"
38
- },
39
- "publishConfig": {
40
- "access": "public"
35
+ "@vaadin/charts": "22.0.0-beta1"
41
36
  },
42
- "gitHead": "4b136b1c7da8942960e7255f40c27859125b3a45"
37
+ "gitHead": "4cf8a9d0504994200c610e44b3676114fef49c1e"
43
38
  }
@@ -1,157 +1,18 @@
1
- import { Series, SeriesOptionsType } from 'highcharts';
2
-
3
- import { ChartSeriesMarkers, ChartSeriesOptions, ChartSeriesValues } from './interfaces';
4
-
5
1
  /**
6
- * `<vaadin-chart-series>` is a custom element for creating series for Vaadin Charts.
7
- *
8
- * ### Basic use
9
- *
10
- * To use `<vaadin-chart-series>`, add it inside a `<vaadin-chart>` element:
11
- *
12
- * ```html
13
- * <vaadin-chart>
14
- * <vaadin-chart-series></vaadin-chart-series>
15
- * </vaadin-chart>
16
- * ```
17
- *
18
- * `<vaadin-chart-series>` accepts `values` as an array attribute, so you can add it to your element definition:
19
- *
20
- * ```html
21
- * <vaadin-chart-series values="[10,20,30,40,50]"></vaadin-chart-series>
22
- * ```
23
- *
24
- * which will add a new line series, where each value will be a data point.
25
- * Look for the Properties session to see all available attributes.
26
- *
27
- * ### Dynamically adding and removing series
28
- *
29
- * You are also able to add and remove series by using DOM API.
30
- *
31
- * To create a new series, call `document.createElement('vaadin-chart-series')` and append it to your `<vaadin-chart>`:
32
- *
33
- * ```js
34
- * const chart = \* a <vaadin-chart> reference *\
35
- * const newSeries = document.createElement('vaadin-chart-series');
36
- * newSeries.values = [10,20,30,40,50];
37
- * chart.appendChild(newSeries);
38
- * ```
39
- *
40
- * In order to remove it, you should use the series to be removed as a reference for the `#removeChild()` call:
41
- *
42
- * ```js
43
- * const chart = \* a <vaadin-chart> reference *\
44
- * const seriesToBeRemoved = \* a <vaadin-chart-series> reference to remove*\
45
- * chart.removeChild(seriesToBeRemoved);
46
- * ```
2
+ * @license
3
+ * Copyright (c) 2015 - 2021 Vaadin Ltd
4
+ * This program is available under Commercial Vaadin Developer License 4.0, available at https://vaadin.com/license/cvdl-4.0.
47
5
  */
48
- declare class ChartSeriesElement extends HTMLElement {
49
- /**
50
- * Object with the configured options defined and used to create a series.
51
- */
52
- readonly options: ChartSeriesOptions;
53
-
54
- /**
55
- * An array of data used by the series.
56
- * Format depends on the chart type and can be:
57
- * - An array of numerical values `[y0, y1, y2, y3,...]`
58
- * - An array of arrays with 2 values (`x`, `y`) `[ [x0, y0], [x1, y1], [x2, y2], ... ]`
59
- * - An array of objects, each one describing one point `[ {x: x0, y: y0, name: 'Point0', color: '#FF0000'}, {...}, ...]`
60
- *
61
- * See more in [API Site](https://api.highcharts.com/highcharts/series)
62
- *
63
- * Note that you should always use [Polymer API](https://www.polymer-project.org/2.0/docs/devguide/model-data#array-mutation)
64
- * to mutate the values array in order to make the component aware of the
65
- * change and be able to synchronize it.
66
- */
67
- values: ChartSeriesValues | null;
68
-
69
- /**
70
- * Value-axis minimum-value.
71
- * Sets the value to a series bound by 'unit' property.
72
- * Otherwise sets the value to the first series.
73
- * Undefined by default (determined from data).
74
- * @attr {number} value-min
75
- */
76
- valueMin: number | null | undefined;
77
-
78
- /**
79
- * Value-axis maximum-value.
80
- * See the 'valueMin'
81
- * @attr {number} value-max
82
- */
83
- valueMax: number | null | undefined;
84
-
85
- /**
86
- * A string with the type of the series.
87
- * Defaults to `'line'` in case no type is set for the chart.
88
- * Note that `'bar'`, `'gauge'` and `'solidgauge'` should be set as default series type on `<vaadin-chart>`.
89
- */
90
- type: string | null | undefined;
91
-
92
- /**
93
- * The name of the series as shown in the legend, tooltip etc.
94
- */
95
- title: string;
96
-
97
- /**
98
- * Shows/hides data-point markers for line-like series.
99
- * Acceptable input are:
100
- * - `shown`: markers are always visible
101
- * - `hidden`: markers are always hidden
102
- * - `auto`: markers are visible for widespread data and hidden, when data is dense *(default)*
103
- */
104
- markers: ChartSeriesMarkers | null | undefined;
105
-
106
- /**
107
- * Used to connect the series to an axis; if multiple series have the same “unit”, they will share axis.
108
- * Displayed as a title for the axis.
109
- * If no unit is defined, then series will be connected to the first axis.
110
- */
111
- unit: string | null | undefined;
6
+ import { ChartSeries } from '@vaadin/charts/src/vaadin-chart-series.js';
112
7
 
113
- /**
114
- * Used to group series in a different stacks.
115
- * "stacking" property should be specified either for each series or in plotOptions.
116
- * It is recommended to place series in a single stack, when they belong to the same yAxis.
117
- */
118
- stack: number | string;
119
-
120
- /**
121
- * The height of the neck, the lower part of the funnel.
122
- * A number defines pixel width, a percentage string defines a percentage of the plot area height. Defaults to 30%.
123
- * Note that this property only applies for "funnel" charts.
124
- * @attr {number | string} neck-position
125
- */
126
- neckPosition: number | string;
127
-
128
- /**
129
- * The width of the neck, the lower part of the funnel.
130
- * A number defines pixel width, a percentage string defines a percentage of the plot area width. Defaults to 30%.
131
- * Note that this property only applies for "funnel" charts.
132
- * @attr {number | string} neck-width
133
- */
134
- neckWidth: number | string;
135
-
136
- /**
137
- * Represents additional JSON configuration.
138
- */
139
- additionalOptions: SeriesOptionsType | null | undefined;
140
-
141
- _series: Series | undefined;
142
-
143
- /**
144
- * Method to attach a series object of type `Highcharts.Series`.
145
- *
146
- * @param series Object of type `Highcharts.Series`
147
- */
148
- setSeries(series: Series): void;
149
- }
8
+ /**
9
+ * @deprecated Import `ChartSeries` from `@vaadin/charts/src/vaadin-chart-series` instead.
10
+ */
11
+ export type ChartSeriesElement = ChartSeries;
150
12
 
151
- declare global {
152
- interface HTMLElementTagNameMap {
153
- 'vaadin-chart-series': ChartSeriesElement;
154
- }
155
- }
13
+ /**
14
+ * @deprecated Import `ChartSeries` from `@vaadin/charts/src/vaadin-chart-series` instead.
15
+ */
16
+ export const ChartSeriesElement: typeof ChartSeries;
156
17
 
157
- export { ChartSeriesElement };
18
+ export * from '@vaadin/charts/src/vaadin-chart-series.js';
@@ -3,441 +3,11 @@
3
3
  * Copyright (c) 2015 - 2021 Vaadin Ltd
4
4
  * This program is available under Commercial Vaadin Developer License 4.0, available at https://vaadin.com/license/cvdl-4.0.
5
5
  */
6
- import { PolymerElement } from '@polymer/polymer/polymer-element.js';
7
- import { deepMerge, ChartElement } from './vaadin-chart.js';
6
+ import { ChartSeries } from '@vaadin/charts/src/vaadin-chart-series.js';
8
7
 
9
8
  /**
10
- * `<vaadin-chart-series>` is a custom element for creating series for Vaadin Charts.
11
- *
12
- * ### Basic use
13
- *
14
- * To use `<vaadin-chart-series>`, add it inside a `<vaadin-chart>` element:
15
- *
16
- * ```html
17
- * <vaadin-chart>
18
- * <vaadin-chart-series></vaadin-chart-series>
19
- * </vaadin-chart>
20
- * ```
21
- *
22
- * `<vaadin-chart-series>` accepts `values` as an array attribute, so you can add it to your element definition:
23
- *
24
- * ```html
25
- * <vaadin-chart-series values="[10,20,30,40,50]"></vaadin-chart-series>
26
- * ```
27
- *
28
- * which will add a new line series, where each value will be a data point.
29
- * Look for the Properties session to see all available attributes.
30
- *
31
- * ### Dynamically adding and removing series
32
- *
33
- * You are also able to add and remove series by using DOM API.
34
- *
35
- * To create a new series, call `document.createElement('vaadin-chart-series')` and append it to your `<vaadin-chart>`:
36
- *
37
- * ```js
38
- * const chart = \* a <vaadin-chart> reference *\
39
- * const newSeries = document.createElement('vaadin-chart-series');
40
- * newSeries.values = [10,20,30,40,50];
41
- * chart.appendChild(newSeries);
42
- * ```
43
- *
44
- * In order to remove it, you should use the series to be removed as a reference for the `#removeChild()` call:
45
- *
46
- * ```js
47
- * const chart = \* a <vaadin-chart> reference *\
48
- * const seriesToBeRemoved = \* a <vaadin-chart-series> reference to remove*\
49
- * chart.removeChild(seriesToBeRemoved);
50
- * ```
51
- *
52
- * @extends HTMLElement
9
+ * @deprecated Import `ChartSeries` from `@vaadin/charts/src/vaadin-chart-series` instead.
53
10
  */
54
- class ChartSeriesElement extends PolymerElement {
55
- static get is() {
56
- return 'vaadin-chart-series';
57
- }
11
+ export const ChartSeriesElement = ChartSeries;
58
12
 
59
- get options() {
60
- const options = deepMerge({}, this.additionalOptions);
61
-
62
- if (this.type) {
63
- options.type = this.type;
64
- }
65
-
66
- if (this.title) {
67
- options.name = this.title;
68
- }
69
-
70
- if (this.values) {
71
- options.data = this.values;
72
- }
73
-
74
- if (this.markers) {
75
- if (!this.__isMarkersValid()) {
76
- this.markers = 'auto';
77
- }
78
- options.marker = this.__markersConfiguration;
79
- }
80
-
81
- if (this.unit) {
82
- options.yAxis = this.unit;
83
- }
84
-
85
- if (this.stack) {
86
- options.stack = this.stack;
87
- }
88
-
89
- if (isFinite(this.valueMin)) {
90
- options.yAxisValueMin = this.valueMin;
91
- }
92
-
93
- if (isFinite(this.valueMax)) {
94
- options.yAxisValueMax = this.valueMax;
95
- }
96
-
97
- if (this.neckWidth) {
98
- options.neckWidth = this.neckWidth;
99
- }
100
-
101
- if (this.neckPosition) {
102
- options.neckHeight = this.neckPosition;
103
- }
104
-
105
- return options;
106
- }
107
-
108
- static get properties() {
109
- return {
110
- /**
111
- * An array of data used by the series.
112
- * Format depends on the chart type and can be:
113
- * - An array of numerical values `[y0, y1, y2, y3,...]`
114
- * - An array of arrays with 2 values (`x`, `y`) `[ [x0, y0], [x1, y1], [x2, y2], ... ]`
115
- * - An array of objects, each one describing one point `[ {x: x0, y: y0, name: 'Point0', color: '#FF0000'}, {...}, ...]`
116
- *
117
- * See more in [API Site](https://api.highcharts.com/highcharts/series)
118
- *
119
- * Note that you should always use [Polymer API](https://www.polymer-project.org/2.0/docs/devguide/model-data#array-mutation)
120
- * to mutate the values array in order to make the component aware of the
121
- * change and be able to synchronize it.
122
- * @type {ChartSeriesValues}
123
- */
124
- values: {
125
- type: Array,
126
- value: () => []
127
- },
128
-
129
- /**
130
- * Value-axis minimum-value.
131
- * Sets the value to a series bound by 'unit' property.
132
- * Otherwise sets the value to the first series.
133
- * Undefined by default (determined from data).
134
- * @attr {number} value-min
135
- */
136
- valueMin: {
137
- type: Number,
138
- reflectToAttribute: true
139
- },
140
-
141
- /**
142
- * Value-axis maximum-value.
143
- * See the 'valueMin'
144
- * @attr {number} value-max
145
- */
146
- valueMax: {
147
- type: Number,
148
- reflectToAttribute: true
149
- },
150
-
151
- /**
152
- * A string with the type of the series.
153
- * Defaults to `'line'` in case no type is set for the chart.
154
- * Note that `'bar'`, `'gauge'` and `'solidgauge'` should be set as default series type on `<vaadin-chart>`.
155
- */
156
- type: {
157
- type: String,
158
- reflectToAttribute: true
159
- },
160
-
161
- /**
162
- * The name of the series as shown in the legend, tooltip etc.
163
- * @type {string}
164
- */
165
- title: {
166
- type: String,
167
- reflectToAttribute: true
168
- },
169
-
170
- /**
171
- * Shows/hides data-point markers for line-like series.
172
- * Acceptable input are:
173
- * - `shown`: markers are always visible
174
- * - `hidden`: markers are always hidden
175
- * - `auto`: markers are visible for widespread data and hidden, when data is dense *(default)*
176
- * @type {ChartSeriesMarkers | undefined}
177
- */
178
- markers: {
179
- type: String,
180
- reflectToAttribute: true
181
- },
182
-
183
- /**
184
- * Used to connect the series to an axis; if multiple series have the same “unit”, they will share axis.
185
- * Displayed as a title for the axis.
186
- * If no unit is defined, then series will be connected to the first axis.
187
- */
188
- unit: {
189
- type: String,
190
- reflectToAttribute: true
191
- },
192
-
193
- /**
194
- * Used to group series in a different stacks.
195
- * "stacking" property should be specified either for each series or in plotOptions.
196
- * It is recommended to place series in a single stack, when they belong to the same yAxis.
197
- * @type {number | string}
198
- */
199
- stack: {
200
- type: String,
201
- reflectToAttribute: true
202
- },
203
-
204
- /**
205
- * The height of the neck, the lower part of the funnel.
206
- * A number defines pixel width, a percentage string defines a percentage of the plot area height. Defaults to 30%.
207
- * Note that this property only applies for "funnel" charts.
208
- * @attr {number | string} neck-position
209
- * @type {number | string}
210
- */
211
- neckPosition: {
212
- type: String,
213
- reflectToAttribute: true
214
- },
215
-
216
- /**
217
- * The width of the neck, the lower part of the funnel.
218
- * A number defines pixel width, a percentage string defines a percentage of the plot area width. Defaults to 30%.
219
- * Note that this property only applies for "funnel" charts.
220
- * @attr {number | string} neck-width
221
- * @type {number | string}
222
- */
223
- neckWidth: {
224
- type: String,
225
- reflectToAttribute: true
226
- },
227
-
228
- /**
229
- * Object with the configured options defined and used to create a series.
230
- * @type {!ChartSeriesOptions}
231
- * @readonly
232
- */
233
- options: {
234
- type: Object
235
- },
236
-
237
- /**
238
- * Represents additional JSON configuration.
239
- * @type {SeriesOptionsType | undefined}
240
- */
241
- additionalOptions: {
242
- type: Object,
243
- reflectToAttribute: true
244
- },
245
-
246
- /**
247
- * @type {!Series | undefined}
248
- * @protected
249
- */
250
- _series: {
251
- type: Object
252
- }
253
- };
254
- }
255
-
256
- static get observers() {
257
- return [
258
- '__additionalOptionsObserver(additionalOptions.*, _series)',
259
- '__markersObserver(markers, _series)',
260
- '__neckPositionObserver(neckPosition, _series)',
261
- '__neckWidthObserver(neckWidth, _series)',
262
- '__stackObserver(stack, _series)',
263
- '__titleObserver(title, _series)',
264
- '__typeObserver(type, _series)',
265
- '__unitObserver(unit, valueMin, valueMax, _series)',
266
- '__valueMinObserver(valueMin, _series)',
267
- '__valueMaxObserver(valueMax, _series)',
268
- '__valuesObserver(values.splices, _series)'
269
- ];
270
- }
271
-
272
- /**
273
- * Method to attach a series object of type `Highcharts.Series`.
274
- * @param {!Series} series Object of type `Highcharts.Series`
275
- */
276
- setSeries(series) {
277
- this._series = series;
278
- }
279
-
280
- /** @private */
281
- __valuesObserver(splices, series) {
282
- if (series) {
283
- series.setData(this.values);
284
- }
285
- }
286
-
287
- /** @private */
288
- __additionalOptionsObserver(additionalOptions, series) {
289
- if (series && additionalOptions.base) {
290
- series.update(additionalOptions.base);
291
- }
292
- }
293
-
294
- /** @private */
295
- __updateAxis(series, value, key) {
296
- if (!isFinite(value)) {
297
- this.__showWarn(`value-${key}`, 'Numbers or null');
298
- return;
299
- }
300
-
301
- if (series && series.yAxis) {
302
- series.yAxis.update({ [key]: value });
303
- }
304
- }
305
-
306
- /** @private */
307
- __valueMinObserver(valueMin, series) {
308
- if (valueMin === undefined || series === undefined) {
309
- return;
310
- }
311
-
312
- this.__updateAxis(series, valueMin, 'min');
313
- }
314
-
315
- /** @private */
316
- __valueMaxObserver(valueMax, series) {
317
- if (valueMax === undefined || series === undefined) {
318
- return;
319
- }
320
-
321
- this.__updateAxis(series, valueMax, 'max');
322
- }
323
-
324
- /** @private */
325
- __typeObserver(type, series) {
326
- if (type && series) {
327
- series.update({ type });
328
- }
329
- }
330
-
331
- /** @private */
332
- __titleObserver(title, series) {
333
- if (title === undefined || series === undefined) {
334
- return;
335
- }
336
- series.update({ name: title });
337
- }
338
-
339
- /** @private */
340
- __stackObserver(stack, series) {
341
- if (stack === undefined || series === undefined) {
342
- return;
343
- }
344
- series.update({ stack });
345
- }
346
-
347
- /** @private */
348
- __neckPositionObserver(neckPosition, series) {
349
- if (neckPosition === undefined || series === undefined) {
350
- return;
351
- }
352
-
353
- series.update({ neckHeight: neckPosition });
354
- }
355
-
356
- /** @private */
357
- __neckWidthObserver(neckWidth, series) {
358
- if (neckWidth === undefined || series === undefined) {
359
- return;
360
- }
361
-
362
- series.update({ neckWidth });
363
- }
364
-
365
- /** @private */
366
- __unitObserver(unit, valueMin, valueMax, series) {
367
- if (series && unit !== this.__oldUnit) {
368
- this.__oldUnit = unit;
369
-
370
- const parent = this.parentNode instanceof ChartElement && this.parentNode;
371
- if (parent && parent instanceof ChartElement) {
372
- if (unit && !parent.__getAxis(unit)) {
373
- const title = { title: { text: unit } };
374
- parent.__addAxis(Object.assign({ id: unit, axisGenerated: true }, title));
375
- }
376
- series.update({ yAxis: unit || 0 });
377
-
378
- if (valueMin !== undefined) {
379
- this.__updateAxis(series, valueMin, 'min');
380
- }
381
-
382
- if (valueMax !== undefined) {
383
- this.__updateAxis(series, valueMax, 'max');
384
- }
385
-
386
- parent.__removeAxisIfEmpty();
387
- }
388
- }
389
- }
390
-
391
- /** @private */
392
- __isMarkersValid() {
393
- if (['shown', 'hidden', 'auto'].indexOf(this.markers) === -1) {
394
- this.__showWarn('markers', '"shown", "hidden" or "auto"');
395
- return false;
396
- }
397
- return true;
398
- }
399
-
400
- /** @private */
401
- __markersObserver(markers, series) {
402
- if (markers === undefined || series === undefined) {
403
- return;
404
- }
405
-
406
- if (!this.__isMarkersValid()) {
407
- this.markers = 'auto';
408
- return;
409
- }
410
-
411
- series.update({
412
- marker: this.__markersConfiguration
413
- });
414
- }
415
-
416
- /** @private */
417
- get __markersConfiguration() {
418
- const config = {};
419
- switch (this.markers) {
420
- case 'shown':
421
- config.enabled = true;
422
- break;
423
- case 'hidden':
424
- config.enabled = false;
425
- break;
426
- case 'auto':
427
- default:
428
- config.enabled = null;
429
- break;
430
- }
431
-
432
- return config;
433
- }
434
-
435
- /** @private */
436
- __showWarn(propertyName, acceptedValues) {
437
- console.warn('<vaadin-chart-series> Acceptable values for "' + propertyName + '" are ' + acceptedValues);
438
- }
439
- }
440
-
441
- customElements.define(ChartSeriesElement.is, ChartSeriesElement);
442
-
443
- export { ChartSeriesElement };
13
+ export * from '@vaadin/charts/src/vaadin-chart-series.js';