@vaadin/charts 25.0.0-alpha2 → 25.0.0-alpha21

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.
@@ -85,6 +85,11 @@ export type ChartRedrawEvent = CustomEvent<{ chart: HighchartsChart; originalEve
85
85
  */
86
86
  export type ChartSelectionEvent = CustomEvent<{ chart: HighchartsChart; originalEvent: ChartEvent }>;
87
87
 
88
+ /**
89
+ * Fired when the chart finishes resizing.
90
+ */
91
+ export type ChartEndResizeEvent = CustomEvent<{ chart: HighchartsChart; originalEvent: ChartEvent }>;
92
+
88
93
  /**
89
94
  * Fired when the series has finished its initial animation.
90
95
  */
@@ -181,7 +186,7 @@ export type ChartPointDropEvent = CustomEvent<{ point: Point; originalEvent: Cha
181
186
  export type ChartPointDragEvent = CustomEvent<{ point: Point; originalEvent: ChartPointEvent }>;
182
187
 
183
188
  /**
184
- * Fired when when the minimum and maximum is set for the X axis.
189
+ * Fired when the minimum and maximum is set for the X axis.
185
190
  */
186
191
  export type ChartXaxesExtremesSetEvent = CustomEvent<{
187
192
  axis: Axis;
@@ -192,7 +197,7 @@ export type ChartXaxesExtremesSetEvent = CustomEvent<{
192
197
  }>;
193
198
 
194
199
  /**
195
- * Fired when when the minimum and maximum is set for the Y axis.
200
+ * Fired when the minimum and maximum is set for the Y axis.
196
201
  */
197
202
  export type ChartYaxesExtremesSetEvent = CustomEvent<{
198
203
  axis: Axis;
@@ -227,6 +232,8 @@ export interface ChartCustomEventMap {
227
232
 
228
233
  'chart-selection': ChartSelectionEvent;
229
234
 
235
+ 'chart-end-resize': ChartEndResizeEvent;
236
+
230
237
  'series-after-animate': ChartSeriesAfterAnimateEvent;
231
238
 
232
239
  'series-checkbox-click': ChartSeriesCheckboxClickEvent;
@@ -28,12 +28,14 @@ import 'highcharts/es-modules/masters/modules/xrange.src.js';
28
28
  import 'highcharts/es-modules/masters/modules/bullet.src.js';
29
29
  import 'highcharts/es-modules/masters/modules/gantt.src.js';
30
30
  import 'highcharts/es-modules/masters/modules/draggable-points.src.js';
31
+ import KeyboardNavigation from 'highcharts/es-modules/Accessibility/KeyboardNavigation.js';
32
+ import HTMLUtilities from 'highcharts/es-modules/Accessibility/Utils/HTMLUtilities.js';
31
33
  import Pointer from 'highcharts/es-modules/Core/Pointer.js';
32
34
  import Highcharts from 'highcharts/es-modules/masters/highstock.src.js';
33
35
  import { get } from '@vaadin/component-base/src/path-utils.js';
34
36
  import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
35
37
  import { SlotObserver } from '@vaadin/component-base/src/slot-observer.js';
36
- import { deepMerge, inflateFunctions } from './helpers.js';
38
+ import { cleanupExport, deepMerge, inflateFunctions, prepareExport } from './helpers.js';
37
39
 
38
40
  ['exportChart', 'exportChartLocal', 'getSVG'].forEach((methodName) => {
39
41
  /* eslint-disable @typescript-eslint/no-invalid-this, prefer-arrow-callback */
@@ -57,7 +59,7 @@ Pointer.prototype.onDocumentMouseMove = function (e) {
57
59
  // If we're outside, hide the tooltip
58
60
  if (
59
61
  chartPosition &&
60
- (!tooltip || !tooltip.isStickyOnContact()) &&
62
+ (!tooltip || !tooltip.isSticky) &&
61
63
  !chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop, {
62
64
  visiblePlotOnly: true,
63
65
  }) &&
@@ -68,6 +70,35 @@ Pointer.prototype.onDocumentMouseMove = function (e) {
68
70
  }
69
71
  };
70
72
 
73
+ // As the `mouseup` event is attached to the document element, the target will reference
74
+ // the instance of the `vaadin-chart` element instead of the element the event originated from.
75
+ // That causes some mishbehaviors, e.g. in a drilldown series, clicking in the point does not
76
+ // drills down the series in some cases.
77
+ // Change to check for the first element in the composed path as the target of the event.
78
+ // Workaround for https://github.com/highcharts/highcharts/issues/23490
79
+ //
80
+ // TODO: Remove this monkeypatch once the referenced issue is fixed
81
+ const { simulatedEventTarget } = HTMLUtilities;
82
+ KeyboardNavigation.prototype.onMouseUp = function (e) {
83
+ delete this.isClickingChart;
84
+ if (!this.keyboardReset && e.relatedTarget !== simulatedEventTarget) {
85
+ const chart = this.chart;
86
+ const target = e.composedPath()[0];
87
+ if (!target || !chart.container.contains(target)) {
88
+ const curMod = this.modules && this.modules[this.currentModuleIx || 0];
89
+ if (curMod && curMod.terminate) {
90
+ curMod.terminate();
91
+ }
92
+ this.currentModuleIx = 0;
93
+ }
94
+ if (chart.focusElement) {
95
+ chart.focusElement.removeFocusBorder();
96
+ delete chart.focusElement;
97
+ }
98
+ this.keyboardReset = true;
99
+ }
100
+ };
101
+
71
102
  // Init Highcharts global language defaults
72
103
  // No data message should be empty by default
73
104
  Highcharts.setOptions({ lang: { noData: '' } });
@@ -301,11 +332,13 @@ export const ChartMixin = (superClass) =>
301
332
  args.forEach((arg) => inflateFunctions(arg));
302
333
  functionToCall.apply(this.configuration, args);
303
334
  if (redrawCharts) {
335
+ const lang = Highcharts.defaultOptions.lang;
304
336
  Highcharts.charts.forEach((c) => {
305
337
  // Ignore `undefined` values that are preserved in the array
306
338
  // after their corresponding chart instances are destroyed.
307
339
  // See https://github.com/vaadin/flow-components/issues/6607
308
340
  if (c !== undefined) {
341
+ c.time.lang = lang;
309
342
  c.redraw();
310
343
  }
311
344
  });
@@ -449,7 +482,7 @@ export const ChartMixin = (superClass) =>
449
482
  return options;
450
483
  }
451
484
 
452
- /**
485
+ /*
453
486
  * Name of the chart events to add to the configuration and its corresponding event for the chart element
454
487
  * @private
455
488
  */
@@ -551,6 +584,14 @@ export const ChartMixin = (superClass) =>
551
584
  * @param {Object} chart Chart object where the event was sent from
552
585
  */
553
586
  selection: 'chart-selection',
587
+
588
+ /**
589
+ * Fired when the chart finishes resizing.
590
+ * @event chart-end-resize
591
+ * @param {Object} detail.originalEvent object with details about the event sent
592
+ * @param {Object} chart Chart object where the event was sent from
593
+ */
594
+ endResize: 'chart-end-resize',
554
595
  };
555
596
  }
556
597
 
@@ -598,7 +639,6 @@ export const ChartMixin = (superClass) =>
598
639
  * @param {Object} detail.originalEvent object with details about the event sent
599
640
  * @param {Object} series Series object where the event was sent from
600
641
  */
601
- legendItemClick: 'series-legend-item-click',
602
642
 
603
643
  /**
604
644
  * Fired when the mouses leave the graph.
@@ -646,7 +686,6 @@ export const ChartMixin = (superClass) =>
646
686
  * @param {Object} detail.originalEvent object with details about the event sent
647
687
  * @param {Object} point Point object where the event was sent from
648
688
  */
649
- legendItemClick: 'point-legend-item-click',
650
689
 
651
690
  /**
652
691
  * Fired when the mouse leaves the area close to the point.
@@ -726,7 +765,7 @@ export const ChartMixin = (superClass) =>
726
765
  get __xAxesEventNames() {
727
766
  return {
728
767
  /**
729
- * Fired when when the minimum and maximum is set for the x axis.
768
+ * Fired when the minimum and maximum is set for the x axis.
730
769
  * @event xaxes-extremes-set
731
770
  * @param {Object} detail.originalEvent object with details about the event sent
732
771
  * @param {Object} axis Point object where the event was sent from
@@ -739,7 +778,7 @@ export const ChartMixin = (superClass) =>
739
778
  get __yAxesEventNames() {
740
779
  return {
741
780
  /**
742
- * Fired when when the minimum and maximum is set for the y axis.
781
+ * Fired when the minimum and maximum is set for the y axis.
743
782
  * @event yaxes-extremes-set
744
783
  * @param {Object} detail.originalEvent object with details about the event sent
745
784
  * @param {Object} axis Point object where the event was sent from
@@ -907,6 +946,8 @@ export const ChartMixin = (superClass) =>
907
946
  } else {
908
947
  this.configuration = Highcharts.chart(this.$.chart, options);
909
948
  }
949
+
950
+ this.__forceResize();
910
951
  }
911
952
 
912
953
  /** @private */
@@ -920,7 +961,7 @@ export const ChartMixin = (superClass) =>
920
961
  super.disconnectedCallback();
921
962
 
922
963
  if (this.configuration) {
923
- this._jsonConfigurationBuffer = this.configuration.userOptions;
964
+ this._jsonConfigurationBuffer = deepMerge({}, this.configuration.userOptions);
924
965
  }
925
966
 
926
967
  queueMicrotask(() => {
@@ -1112,6 +1153,7 @@ export const ChartMixin = (superClass) =>
1112
1153
  this.__initSeriesEventsListeners(configuration);
1113
1154
  this.__initPointsEventsListeners(configuration);
1114
1155
  this.__initAxisEventsListeners(configuration, true);
1156
+ this.__initLegendItemClickEventListener(configuration);
1115
1157
  this.__initAxisEventsListeners(configuration, false);
1116
1158
  }
1117
1159
 
@@ -1130,6 +1172,39 @@ export const ChartMixin = (superClass) =>
1130
1172
  this.__createEventListeners(this.__pointEventNames, configuration, 'plotOptions.series.point.events', 'point');
1131
1173
  }
1132
1174
 
1175
+ /** @private */
1176
+ __initLegendItemClickEventListener(configuration) {
1177
+ const eventObject = this.__ensureObjectPath(configuration, 'legend.events');
1178
+ eventObject.itemClick = (event) => {
1179
+ const customEvent = {
1180
+ bubbles: false,
1181
+ composed: true,
1182
+ detail: {
1183
+ originalEvent: event,
1184
+ legend: event.target,
1185
+ },
1186
+ };
1187
+
1188
+ // `event.legendItem` might be an object of type `Highcharts.Series`, `Highcharts.Point` or
1189
+ // `Highcharts.LegendItemObject`. We care only about the first two to dispatch either a
1190
+ // `series-legend-item-click` or `point-legend-item-click` event.
1191
+ const legendItemMatch = [
1192
+ { clazz: Highcharts.Series, type: 'series' },
1193
+ { clazz: Highcharts.Point, type: 'point' },
1194
+ ].find(({ clazz }) => event.legendItem instanceof clazz);
1195
+
1196
+ if (legendItemMatch) {
1197
+ const { type: legendItemClickType } = legendItemMatch;
1198
+ customEvent.detail[legendItemClickType] = event.legendItem;
1199
+ this.dispatchEvent(new CustomEvent(`${legendItemClickType}-legend-item-click`, customEvent));
1200
+
1201
+ if (this._visibilityTogglingDisabled) {
1202
+ return false;
1203
+ }
1204
+ }
1205
+ };
1206
+ }
1207
+
1133
1208
  /** @private */
1134
1209
  __initAxisEventsListeners(configuration, isXAxis) {
1135
1210
  let eventNames, axes;
@@ -1202,62 +1277,15 @@ export const ChartMixin = (superClass) =>
1202
1277
  // Workaround for https://github.com/vaadin/vaadin-charts/issues/389
1203
1278
  // Hook into beforePrint and beforeExport to ensure correct styling
1204
1279
  if (['beforePrint', 'beforeExport'].indexOf(event.type) >= 0) {
1205
- // Guard against another print 'before print' event coming before
1206
- // the 'after print' event.
1207
- if (!self.tempBodyStyle) {
1208
- let effectiveCss = '';
1209
-
1210
- // PolymerElement uses `<style>` tags for adding styles
1211
- [...self.shadowRoot.querySelectorAll('style')].forEach((style) => {
1212
- effectiveCss += style.textContent;
1213
- });
1214
-
1215
- // LitElement uses `adoptedStyleSheets` for adding styles
1216
- if (self.shadowRoot.adoptedStyleSheets) {
1217
- self.shadowRoot.adoptedStyleSheets.forEach((sheet) => {
1218
- effectiveCss += [...sheet.cssRules].map((rule) => rule.cssText).join('\n');
1219
- });
1220
- }
1221
-
1222
- // Strip off host selectors that target individual instances
1223
- effectiveCss = effectiveCss.replace(/:host\(.+?\)/gu, (match) => {
1224
- const selector = match.substr(6, match.length - 7);
1225
- return self.matches(selector) ? '' : match;
1226
- });
1227
-
1228
- // Zoom out a bit to avoid clipping the chart's edge on paper
1229
- effectiveCss =
1230
- `${effectiveCss}body {` +
1231
- ` -moz-transform: scale(0.9, 0.9);` + // Mozilla
1232
- ` zoom: 0.9;` + // Others
1233
- ` zoom: 90%;` + // Webkit
1234
- `}`;
1235
-
1236
- self.tempBodyStyle = document.createElement('style');
1237
- self.tempBodyStyle.textContent = effectiveCss;
1238
- document.body.appendChild(self.tempBodyStyle);
1239
- if (self.options.chart.styledMode) {
1240
- document.body.setAttribute('styled-mode', '');
1241
- }
1242
- }
1280
+ prepareExport(self);
1243
1281
  }
1244
1282
 
1245
1283
  // Hook into afterPrint and afterExport to revert changes made before
1246
1284
  if (['afterPrint', 'afterExport'].indexOf(event.type) >= 0) {
1247
- if (self.tempBodyStyle) {
1248
- document.body.removeChild(self.tempBodyStyle);
1249
- delete self.tempBodyStyle;
1250
- if (self.options.chart.styledMode) {
1251
- document.body.removeAttribute('styled-mode');
1252
- }
1253
- }
1285
+ cleanupExport(self);
1254
1286
  }
1255
1287
 
1256
1288
  self.dispatchEvent(new CustomEvent(eventList[key], customEvent));
1257
-
1258
- if (event.type === 'legendItemClick' && self._visibilityTogglingDisabled) {
1259
- return false;
1260
- }
1261
1289
  };
1262
1290
  }
1263
1291
  }
@@ -1279,7 +1307,15 @@ export const ChartMixin = (superClass) =>
1279
1307
  }
1280
1308
 
1281
1309
  /** @private */
1282
- __hasConfigurationBuffer(path) {
1310
+ __hasConfigurationBuffer(path, property) {
1311
+ if (
1312
+ property &&
1313
+ path.startsWith(property) &&
1314
+ this._jsonConfigurationBuffer &&
1315
+ Array.isArray(this._jsonConfigurationBuffer[property])
1316
+ ) {
1317
+ return get(path.split('.')[1], this._jsonConfigurationBuffer[property][0]);
1318
+ }
1283
1319
  return get(path, this._jsonConfigurationBuffer) !== undefined;
1284
1320
  }
1285
1321
 
@@ -1331,7 +1367,7 @@ export const ChartMixin = (superClass) =>
1331
1367
 
1332
1368
  /** @private */
1333
1369
  __updateCategories(categories, config) {
1334
- if (categories === undefined || !config || this.__hasConfigurationBuffer('xAxis.categories')) {
1370
+ if (categories === undefined || !config || this.__hasConfigurationBuffer('xAxis.categories', 'xAxis')) {
1335
1371
  return;
1336
1372
  }
1337
1373
 
@@ -1340,7 +1376,7 @@ export const ChartMixin = (superClass) =>
1340
1376
 
1341
1377
  /** @private */
1342
1378
  __updateCategoryMax(max, config) {
1343
- if (max === undefined || !config || this.__hasConfigurationBuffer('xAxis.max')) {
1379
+ if (max === undefined || !config || this.__hasConfigurationBuffer('xAxis.max', 'xAxis')) {
1344
1380
  return;
1345
1381
  }
1346
1382
 
@@ -1354,7 +1390,7 @@ export const ChartMixin = (superClass) =>
1354
1390
 
1355
1391
  /** @private */
1356
1392
  __updateCategoryMin(min, config) {
1357
- if (min === undefined || !config || this.__hasConfigurationBuffer('xAxis.min')) {
1393
+ if (min === undefined || !config || this.__hasConfigurationBuffer('xAxis.min', 'xAxis')) {
1358
1394
  return;
1359
1395
  }
1360
1396
 
@@ -1655,18 +1691,13 @@ export const ChartMixin = (superClass) =>
1655
1691
 
1656
1692
  // If chart element is a flexible item the chartContainer should be flex too
1657
1693
  if (isFlex) {
1658
- this.$.chart.setAttribute('style', 'flex: 1; ');
1659
- let style = '';
1660
- if (this.hasAttribute('style')) {
1661
- style = this.getAttribute('style');
1662
- if (!style.endsWith(';')) {
1663
- style += ';';
1664
- }
1665
- }
1666
- style += 'display: flex;';
1667
- this.setAttribute('style', style);
1694
+ this.style.display = 'flex';
1695
+ this.$.wrapper.style.display = 'flex';
1696
+ this.$.chart.style.flex = 1;
1668
1697
  } else {
1669
- this.$.chart.setAttribute('style', 'height:100%; width:100%;');
1698
+ this.style.display = '';
1699
+ this.$.wrapper.style.display = '';
1700
+ this.$.chart.style.flex = '';
1670
1701
  }
1671
1702
  }
1672
1703
 
@@ -1675,6 +1706,30 @@ export const ChartMixin = (superClass) =>
1675
1706
  console.warn(`<vaadin-chart> Acceptable values for "${propertyName}" are ${acceptedValues}`);
1676
1707
  }
1677
1708
 
1709
+ /**
1710
+ * @private
1711
+ * Workaround for https://github.com/highcharts/highcharts/issues/23443
1712
+ * Forces a resize in the chart to make it calculate the labels positions
1713
+ * correctly in a chart with "organization" series
1714
+ *
1715
+ * TODO: Remove when the related ticket is fixed
1716
+ */
1717
+ __forceResize() {
1718
+ const chart = this.configuration;
1719
+ const { options } = chart;
1720
+ const hasOrganizationSeries =
1721
+ options.chart.styledMode &&
1722
+ (options.chart.type === 'organization' || options.series.some((series) => series.type === 'organization'));
1723
+ if (!hasOrganizationSeries) {
1724
+ return;
1725
+ }
1726
+
1727
+ requestAnimationFrame(() => {
1728
+ chart.setSize(chart.chartWidth - 10, chart.chartHeight);
1729
+ chart.setSize(null, null);
1730
+ });
1731
+ }
1732
+
1678
1733
  /** @private */
1679
1734
  __onRedraw() {
1680
1735
  this.__checkTurboMode();
@@ -19,15 +19,15 @@ export * from './vaadin-chart-series-mixin.js';
19
19
  * To use `<vaadin-chart-series>`, add it inside a `<vaadin-chart>` element:
20
20
  *
21
21
  * ```html
22
- * <vaadin-chart>
23
- * <vaadin-chart-series></vaadin-chart-series>
24
- * </vaadin-chart>
22
+ * <vaadin-chart>
23
+ * <vaadin-chart-series></vaadin-chart-series>
24
+ * </vaadin-chart>
25
25
  * ```
26
26
  *
27
27
  * `<vaadin-chart-series>` accepts `values` as an array attribute, so you can add it to your element definition:
28
28
  *
29
29
  * ```html
30
- * <vaadin-chart-series values="[10,20,30,40,50]"></vaadin-chart-series>
30
+ * <vaadin-chart-series values="[10, 20, 30, 40, 50]"></vaadin-chart-series>
31
31
  * ```
32
32
  *
33
33
  * which will add a new line series, where each value will be a data point.
@@ -40,18 +40,18 @@ export * from './vaadin-chart-series-mixin.js';
40
40
  * To create a new series, call `document.createElement('vaadin-chart-series')` and append it to your `<vaadin-chart>`:
41
41
  *
42
42
  * ```js
43
- * const chart = \* a <vaadin-chart> reference *\
44
- * const newSeries = document.createElement('vaadin-chart-series');
45
- * newSeries.values = [10,20,30,40,50];
46
- * chart.appendChild(newSeries);
43
+ * const chart = document.querySelector('vaadin-chart');
44
+ * const newSeries = document.createElement('vaadin-chart-series');
45
+ * newSeries.values = [10, 20, 30, 40, 50];
46
+ * chart.appendChild(newSeries);
47
47
  * ```
48
48
  *
49
49
  * In order to remove it, you should use the series to be removed as a reference for the `#removeChild()` call:
50
50
  *
51
51
  * ```js
52
- * const chart = \* a <vaadin-chart> reference *\
53
- * const seriesToBeRemoved = \* a <vaadin-chart-series> reference to remove*\
54
- * chart.removeChild(seriesToBeRemoved);
52
+ * const chart = document.querySelector('vaadin-chart');
53
+ * const seriesToBeRemoved = chart.querySelector('vaadin-chart-series');
54
+ * chart.removeChild(seriesToBeRemoved);
55
55
  * ```
56
56
  */
57
57
  declare class ChartSeries extends ChartSeriesMixin(HTMLElement) {}
@@ -21,15 +21,15 @@ import { ChartSeriesMixin } from './vaadin-chart-series-mixin.js';
21
21
  * To use `<vaadin-chart-series>`, add it inside a `<vaadin-chart>` element:
22
22
  *
23
23
  * ```html
24
- * <vaadin-chart>
25
- * <vaadin-chart-series></vaadin-chart-series>
26
- * </vaadin-chart>
24
+ * <vaadin-chart>
25
+ * <vaadin-chart-series></vaadin-chart-series>
26
+ * </vaadin-chart>
27
27
  * ```
28
28
  *
29
29
  * `<vaadin-chart-series>` accepts `values` as an array attribute, so you can add it to your element definition:
30
30
  *
31
31
  * ```html
32
- * <vaadin-chart-series values="[10,20,30,40,50]"></vaadin-chart-series>
32
+ * <vaadin-chart-series values="[10, 20, 30, 40, 50]"></vaadin-chart-series>
33
33
  * ```
34
34
  *
35
35
  * which will add a new line series, where each value will be a data point.
@@ -42,18 +42,18 @@ import { ChartSeriesMixin } from './vaadin-chart-series-mixin.js';
42
42
  * To create a new series, call `document.createElement('vaadin-chart-series')` and append it to your `<vaadin-chart>`:
43
43
  *
44
44
  * ```js
45
- * const chart = \* a <vaadin-chart> reference *\
46
- * const newSeries = document.createElement('vaadin-chart-series');
47
- * newSeries.values = [10,20,30,40,50];
48
- * chart.appendChild(newSeries);
45
+ * const chart = document.querySelector('vaadin-chart');
46
+ * const newSeries = document.createElement('vaadin-chart-series');
47
+ * newSeries.values = [10, 20, 30, 40, 50];
48
+ * chart.appendChild(newSeries);
49
49
  * ```
50
50
  *
51
51
  * In order to remove it, you should use the series to be removed as a reference for the `#removeChild()` call:
52
52
  *
53
53
  * ```js
54
- * const chart = \* a <vaadin-chart> reference *\
55
- * const seriesToBeRemoved = \* a <vaadin-chart-series> reference to remove*\
56
- * chart.removeChild(seriesToBeRemoved);
54
+ * const chart = document.querySelector('vaadin-chart');
55
+ * const seriesToBeRemoved = chart.querySelector('vaadin-chart-series');
56
+ * chart.removeChild(seriesToBeRemoved);
57
57
  * ```
58
58
  *
59
59
  * @customElement
@@ -21,89 +21,67 @@ export * from './vaadin-chart-mixin.js';
21
21
  * There are two ways of configuring your `<vaadin-chart>` element: **HTML API**, **JS API** and **JSON API**.
22
22
  * Note that you can make use of all APIs in your element.
23
23
  *
24
- * #### Configuring your chart using HTML API
24
+ * #### Using HTML API
25
25
  *
26
26
  * `vaadin-chart` has a set of attributes to make it easier for you to customize your chart.
27
27
  *
28
28
  * ```html
29
- * <vaadin-chart title="The chart title" subtitle="The chart subtitle">
30
- * <vaadin-chart-series
31
- * type="column"
32
- * title="The series title"
33
- * values="[10,20,30]">
34
- * </vaadin-chart-series>
35
- * </vaadin-chart>
29
+ * <vaadin-chart title="The chart title" subtitle="The chart subtitle">
30
+ * <vaadin-chart-series
31
+ * type="column"
32
+ * title="The series title"
33
+ * values="[10, 20, 30]"
34
+ * ></vaadin-chart-series>
35
+ * </vaadin-chart>
36
36
  * ```
37
37
  *
38
38
  * > Note that while you can set type for each series individually, for some types, such as `'bar'`, `'gauge'` and `'solidgauge'`, you
39
39
  * > have to set it as the default series type on `<vaadin-chart>` in order to work properly.
40
40
  *
41
- * #### Configuring your chart using JS API
41
+ * #### Using JS API
42
+ *
43
+ * Use [`configuration`](#/elements/vaadin-chart#property-configuration) property to set chart title, categories and data:
42
44
  *
43
- * 1. Set an id for the `<vaadin-chart>` in the template
44
- * ```html
45
- * <vaadin-chart id="mychart"></vaadin-chart>
46
- * ```
47
- * 1. Add a function that uses `configuration` property (JS Api) to set chart title, categories and data
48
- * ```js
49
- * initChartWithJSApi() {
50
- * requestAnimationFrame(() => {
51
- * const configuration = this.$.mychart.configuration;
52
- * configuration.setTitle({ text: 'The chart title' });
53
- * // By default there is one X axis, it is referenced by configuration.xAxis[0].
54
- * configuration.xAxis[0].setCategories(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
55
- * configuration.addSeries({
56
- * type: 'column',
57
- * data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
58
- * });
59
- * });
60
- * }
61
- * ```
62
- * 1. Call that function from connectedCallback (when the element is added to a document)
63
45
  * ```js
64
- * connectedCallback() {
65
- * super.connectedCallback();
66
- * this.initChartWithJSApi();
67
- * }
46
+ * const chart = document.querySelector('vaadin-chart');
47
+ *
48
+ * // Wait for default configuration to be ready
49
+ * requestAnimationFrame(() => {
50
+ * const configuration = chart.configuration;
51
+ * configuration.setTitle({ text: 'The chart title' });
52
+ * // By default there is one X axis, it is referenced by configuration.xAxis[0].
53
+ * configuration.xAxis[0].setCategories(['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']);
54
+ * configuration.addSeries({
55
+ * type: 'column',
56
+ * data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
57
+ * });
58
+ * });
68
59
  * ```
69
60
  *
70
- * #### Configuring your chart using JS JSON API
61
+ * #### Using JS JSON API
71
62
  *
72
- * JS JSON API is a simple alternative to the JS API.
63
+ * Use [`updateConfiguration`](#/elements/vaadin-chart#method-updateConfiguration) method to set chart title, categories and data:
73
64
  *
74
- * 1. Set an id for the `<vaadin-chart>` in the template
75
- * ```html
76
- * <vaadin-chart id="mychart"></vaadin-chart>
77
- * ```
78
- * 1. Add a function that uses `updateConfiguration` method (JS JSON Api) to set chart title, categories and data
79
- * ```js
80
- * initChartWithJSJSONApi() {
81
- * this.$.mychart.updateConfiguration({
82
- * title: {
83
- * text: 'The chart title'
84
- * },
85
- * subtitle: {
86
- * text: 'Subtitle'
87
- * },
88
- * xAxis: {
89
- * categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
90
- * },
91
- * series: [{
92
- * type: 'column',
93
- * data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
94
- * }]
95
- * });
96
- * }
97
- * ```
98
- * 1. Call that function from connectedCallback (when the element is added to a document)
99
65
  * ```js
100
- * connectedCallback() {
101
- * super.connectedCallback();
102
- * this.initChartWithJSJSONApi();
103
- * }
66
+ * const chart = document.querySelector('vaadin-chart');
67
+ * chart.updateConfiguration({
68
+ * title: {
69
+ * text: 'The chart title'
70
+ * },
71
+ * subtitle: {
72
+ * text: 'Subtitle'
73
+ * },
74
+ * xAxis: {
75
+ * categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
76
+ * },
77
+ * series: [{
78
+ * type: 'column',
79
+ * data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
80
+ * }]
81
+ * });
104
82
  * ```
105
83
  *
106
- * It should be noted that chart style customization cannot be done via the JS or JSON API.
84
+ * **Note:** chart style customization cannot be done via the JS or JSON API.
107
85
  * Styling properties in the JSON configuration will be ignored. The following section discusses chart styling.
108
86
  *
109
87
  * ### CSS Styling
@@ -132,11 +110,6 @@ export * from './vaadin-chart-mixin.js';
132
110
  *
133
111
  * For example `--vaadin-charts-color-0` sets the color of the first series on a chart.
134
112
  *
135
- * ### Validating your License
136
- *
137
- * When using Vaadin Charts in a development environment, you will see a pop-up that asks you
138
- * to validate your license by signing in to vaadin.com.
139
- *
140
113
  * @fires {CustomEvent} chart-add-series - Fired when a new series is added.
141
114
  * @fires {CustomEvent} chart-after-export - Fired after a chart is exported.
142
115
  * @fires {CustomEvent} chart-after-print - Fired after a chart is printed.
@@ -149,6 +122,7 @@ export * from './vaadin-chart-mixin.js';
149
122
  * @fires {CustomEvent} chart-drillupall - Fired after all the drilldown series has been drilled up.
150
123
  * @fires {CustomEvent} chart-redraw - Fired after the chart redraw.
151
124
  * @fires {CustomEvent} chart-selection - Fired when an area of the chart has been selected.
125
+ * @fires {CustomEvent} chart-end-resize - Fired when the chart finishes resizing.
152
126
  * @fires {CustomEvent} series-after-animate - Fired when the series has finished its initial animation.
153
127
  * @fires {CustomEvent} series-checkbox-click - Fired when the checkbox next to the series' name in the legend is clicked.
154
128
  * @fires {CustomEvent} series-click - Fired when the series is clicked.
@@ -168,8 +142,8 @@ export * from './vaadin-chart-mixin.js';
168
142
  * @fires {CustomEvent} point-drag-start - Fired when starting to drag a point.
169
143
  * @fires {CustomEvent} point-drop - Fired when the point is dropped.
170
144
  * @fires {CustomEvent} point-drag - Fired while dragging a point.
171
- * @fires {CustomEvent} xaxes-extremes-set - Fired when when the minimum and maximum is set for the X axis.
172
- * @fires {CustomEvent} yaxes-extremes-set - Fired when when the minimum and maximum is set for the Y axis.
145
+ * @fires {CustomEvent} xaxes-extremes-set - Fired when the minimum and maximum is set for the X axis.
146
+ * @fires {CustomEvent} yaxes-extremes-set - Fired when the minimum and maximum is set for the Y axis.
173
147
  */
174
148
  declare class Chart extends ChartMixin(ThemableMixin(ElementMixin(HTMLElement))) {
175
149
  addEventListener<K extends keyof ChartEventMap>(