@vaadin/charts 25.0.0-alpha9 → 25.0.0-beta2
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 +9 -12
- package/src/helpers.js +46 -0
- package/src/styles/vaadin-chart-base-styles.js +488 -310
- package/src/vaadin-chart-mixin.d.ts +9 -2
- package/src/vaadin-chart-mixin.js +137 -73
- package/src/vaadin-chart-series.d.ts +11 -11
- package/src/vaadin-chart-series.js +11 -11
- package/src/vaadin-chart.d.ts +46 -67
- package/src/vaadin-chart.js +50 -69
- package/vaadin-chart.js +1 -1
- package/web-types.json +9 -5
- package/web-types.lit.json +12 -5
- package/src/styles/vaadin-chart-core-styles.d.ts +0 -13
- package/src/styles/vaadin-chart-core-styles.js +0 -1063
- package/theme/lumo/vaadin-chart-styles.d.ts +0 -5
- package/theme/lumo/vaadin-chart-styles.js +0 -96
- package/theme/lumo/vaadin-chart.d.ts +0 -2
- package/theme/lumo/vaadin-chart.js +0 -2
|
@@ -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
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
@@ -756,7 +795,6 @@ export const ChartMixin = (superClass) =>
|
|
|
756
795
|
// Detect if the chart had already been initialized. This might happen in
|
|
757
796
|
// environments where the chart is lazily attached (e.g Grid).
|
|
758
797
|
if (this.configuration) {
|
|
759
|
-
this.__reflow();
|
|
760
798
|
return;
|
|
761
799
|
}
|
|
762
800
|
|
|
@@ -787,6 +825,16 @@ export const ChartMixin = (superClass) =>
|
|
|
787
825
|
const { height, width } = contentRect;
|
|
788
826
|
const { chartHeight, chartWidth } = this.configuration;
|
|
789
827
|
|
|
828
|
+
this.$.wrapper.style.minHeight = '';
|
|
829
|
+
// Use 1px as the threshold to align with Highcharts
|
|
830
|
+
if (this.$.wrapper.offsetHeight <= 1) {
|
|
831
|
+
this.$.wrapper.style.minHeight = `${chartHeight}px`;
|
|
832
|
+
}
|
|
833
|
+
this.$.wrapper.style.minWidth = '';
|
|
834
|
+
if (this.$.wrapper.offsetWidth <= 1) {
|
|
835
|
+
this.$.wrapper.style.minWidth = `${chartWidth}px`;
|
|
836
|
+
}
|
|
837
|
+
|
|
790
838
|
if (height !== chartHeight || width !== chartWidth) {
|
|
791
839
|
this.__reflow();
|
|
792
840
|
}
|
|
@@ -907,6 +955,8 @@ export const ChartMixin = (superClass) =>
|
|
|
907
955
|
} else {
|
|
908
956
|
this.configuration = Highcharts.chart(this.$.chart, options);
|
|
909
957
|
}
|
|
958
|
+
|
|
959
|
+
this.__forceResize();
|
|
910
960
|
}
|
|
911
961
|
|
|
912
962
|
/** @private */
|
|
@@ -920,7 +970,7 @@ export const ChartMixin = (superClass) =>
|
|
|
920
970
|
super.disconnectedCallback();
|
|
921
971
|
|
|
922
972
|
if (this.configuration) {
|
|
923
|
-
this._jsonConfigurationBuffer = this.configuration.userOptions;
|
|
973
|
+
this._jsonConfigurationBuffer = deepMerge({}, this.configuration.userOptions);
|
|
924
974
|
}
|
|
925
975
|
|
|
926
976
|
queueMicrotask(() => {
|
|
@@ -1112,6 +1162,7 @@ export const ChartMixin = (superClass) =>
|
|
|
1112
1162
|
this.__initSeriesEventsListeners(configuration);
|
|
1113
1163
|
this.__initPointsEventsListeners(configuration);
|
|
1114
1164
|
this.__initAxisEventsListeners(configuration, true);
|
|
1165
|
+
this.__initLegendItemClickEventListener(configuration);
|
|
1115
1166
|
this.__initAxisEventsListeners(configuration, false);
|
|
1116
1167
|
}
|
|
1117
1168
|
|
|
@@ -1130,6 +1181,39 @@ export const ChartMixin = (superClass) =>
|
|
|
1130
1181
|
this.__createEventListeners(this.__pointEventNames, configuration, 'plotOptions.series.point.events', 'point');
|
|
1131
1182
|
}
|
|
1132
1183
|
|
|
1184
|
+
/** @private */
|
|
1185
|
+
__initLegendItemClickEventListener(configuration) {
|
|
1186
|
+
const eventObject = this.__ensureObjectPath(configuration, 'legend.events');
|
|
1187
|
+
eventObject.itemClick = (event) => {
|
|
1188
|
+
const customEvent = {
|
|
1189
|
+
bubbles: false,
|
|
1190
|
+
composed: true,
|
|
1191
|
+
detail: {
|
|
1192
|
+
originalEvent: event,
|
|
1193
|
+
legend: event.target,
|
|
1194
|
+
},
|
|
1195
|
+
};
|
|
1196
|
+
|
|
1197
|
+
// `event.legendItem` might be an object of type `Highcharts.Series`, `Highcharts.Point` or
|
|
1198
|
+
// `Highcharts.LegendItemObject`. We care only about the first two to dispatch either a
|
|
1199
|
+
// `series-legend-item-click` or `point-legend-item-click` event.
|
|
1200
|
+
const legendItemMatch = [
|
|
1201
|
+
{ clazz: Highcharts.Series, type: 'series' },
|
|
1202
|
+
{ clazz: Highcharts.Point, type: 'point' },
|
|
1203
|
+
].find(({ clazz }) => event.legendItem instanceof clazz);
|
|
1204
|
+
|
|
1205
|
+
if (legendItemMatch) {
|
|
1206
|
+
const { type: legendItemClickType } = legendItemMatch;
|
|
1207
|
+
customEvent.detail[legendItemClickType] = event.legendItem;
|
|
1208
|
+
this.dispatchEvent(new CustomEvent(`${legendItemClickType}-legend-item-click`, customEvent));
|
|
1209
|
+
|
|
1210
|
+
if (this._visibilityTogglingDisabled) {
|
|
1211
|
+
return false;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
};
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1133
1217
|
/** @private */
|
|
1134
1218
|
__initAxisEventsListeners(configuration, isXAxis) {
|
|
1135
1219
|
let eventNames, axes;
|
|
@@ -1202,62 +1286,15 @@ export const ChartMixin = (superClass) =>
|
|
|
1202
1286
|
// Workaround for https://github.com/vaadin/vaadin-charts/issues/389
|
|
1203
1287
|
// Hook into beforePrint and beforeExport to ensure correct styling
|
|
1204
1288
|
if (['beforePrint', 'beforeExport'].indexOf(event.type) >= 0) {
|
|
1205
|
-
|
|
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
|
-
}
|
|
1289
|
+
prepareExport(self);
|
|
1243
1290
|
}
|
|
1244
1291
|
|
|
1245
1292
|
// Hook into afterPrint and afterExport to revert changes made before
|
|
1246
1293
|
if (['afterPrint', 'afterExport'].indexOf(event.type) >= 0) {
|
|
1247
|
-
|
|
1248
|
-
document.body.removeChild(self.tempBodyStyle);
|
|
1249
|
-
delete self.tempBodyStyle;
|
|
1250
|
-
if (self.options.chart.styledMode) {
|
|
1251
|
-
document.body.removeAttribute('styled-mode');
|
|
1252
|
-
}
|
|
1253
|
-
}
|
|
1294
|
+
cleanupExport(self);
|
|
1254
1295
|
}
|
|
1255
1296
|
|
|
1256
1297
|
self.dispatchEvent(new CustomEvent(eventList[key], customEvent));
|
|
1257
|
-
|
|
1258
|
-
if (event.type === 'legendItemClick' && self._visibilityTogglingDisabled) {
|
|
1259
|
-
return false;
|
|
1260
|
-
}
|
|
1261
1298
|
};
|
|
1262
1299
|
}
|
|
1263
1300
|
}
|
|
@@ -1279,7 +1316,15 @@ export const ChartMixin = (superClass) =>
|
|
|
1279
1316
|
}
|
|
1280
1317
|
|
|
1281
1318
|
/** @private */
|
|
1282
|
-
__hasConfigurationBuffer(path) {
|
|
1319
|
+
__hasConfigurationBuffer(path, property) {
|
|
1320
|
+
if (
|
|
1321
|
+
property &&
|
|
1322
|
+
path.startsWith(property) &&
|
|
1323
|
+
this._jsonConfigurationBuffer &&
|
|
1324
|
+
Array.isArray(this._jsonConfigurationBuffer[property])
|
|
1325
|
+
) {
|
|
1326
|
+
return get(path.split('.')[1], this._jsonConfigurationBuffer[property][0]);
|
|
1327
|
+
}
|
|
1283
1328
|
return get(path, this._jsonConfigurationBuffer) !== undefined;
|
|
1284
1329
|
}
|
|
1285
1330
|
|
|
@@ -1331,7 +1376,7 @@ export const ChartMixin = (superClass) =>
|
|
|
1331
1376
|
|
|
1332
1377
|
/** @private */
|
|
1333
1378
|
__updateCategories(categories, config) {
|
|
1334
|
-
if (categories === undefined || !config || this.__hasConfigurationBuffer('xAxis.categories')) {
|
|
1379
|
+
if (categories === undefined || !config || this.__hasConfigurationBuffer('xAxis.categories', 'xAxis')) {
|
|
1335
1380
|
return;
|
|
1336
1381
|
}
|
|
1337
1382
|
|
|
@@ -1340,7 +1385,7 @@ export const ChartMixin = (superClass) =>
|
|
|
1340
1385
|
|
|
1341
1386
|
/** @private */
|
|
1342
1387
|
__updateCategoryMax(max, config) {
|
|
1343
|
-
if (max === undefined || !config || this.__hasConfigurationBuffer('xAxis.max')) {
|
|
1388
|
+
if (max === undefined || !config || this.__hasConfigurationBuffer('xAxis.max', 'xAxis')) {
|
|
1344
1389
|
return;
|
|
1345
1390
|
}
|
|
1346
1391
|
|
|
@@ -1354,7 +1399,7 @@ export const ChartMixin = (superClass) =>
|
|
|
1354
1399
|
|
|
1355
1400
|
/** @private */
|
|
1356
1401
|
__updateCategoryMin(min, config) {
|
|
1357
|
-
if (min === undefined || !config || this.__hasConfigurationBuffer('xAxis.min')) {
|
|
1402
|
+
if (min === undefined || !config || this.__hasConfigurationBuffer('xAxis.min', 'xAxis')) {
|
|
1358
1403
|
return;
|
|
1359
1404
|
}
|
|
1360
1405
|
|
|
@@ -1655,18 +1700,13 @@ export const ChartMixin = (superClass) =>
|
|
|
1655
1700
|
|
|
1656
1701
|
// If chart element is a flexible item the chartContainer should be flex too
|
|
1657
1702
|
if (isFlex) {
|
|
1658
|
-
this
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
style = this.getAttribute('style');
|
|
1662
|
-
if (!style.endsWith(';')) {
|
|
1663
|
-
style += ';';
|
|
1664
|
-
}
|
|
1665
|
-
}
|
|
1666
|
-
style += 'display: flex;';
|
|
1667
|
-
this.setAttribute('style', style);
|
|
1703
|
+
this.style.display = 'flex';
|
|
1704
|
+
this.$.wrapper.style.display = 'flex';
|
|
1705
|
+
this.$.chart.style.flex = 1;
|
|
1668
1706
|
} else {
|
|
1669
|
-
this
|
|
1707
|
+
this.style.display = '';
|
|
1708
|
+
this.$.wrapper.style.display = '';
|
|
1709
|
+
this.$.chart.style.flex = '';
|
|
1670
1710
|
}
|
|
1671
1711
|
}
|
|
1672
1712
|
|
|
@@ -1675,6 +1715,30 @@ export const ChartMixin = (superClass) =>
|
|
|
1675
1715
|
console.warn(`<vaadin-chart> Acceptable values for "${propertyName}" are ${acceptedValues}`);
|
|
1676
1716
|
}
|
|
1677
1717
|
|
|
1718
|
+
/**
|
|
1719
|
+
* @private
|
|
1720
|
+
* Workaround for https://github.com/highcharts/highcharts/issues/23443
|
|
1721
|
+
* Forces a resize in the chart to make it calculate the labels positions
|
|
1722
|
+
* correctly in a chart with "organization" series
|
|
1723
|
+
*
|
|
1724
|
+
* TODO: Remove when the related ticket is fixed
|
|
1725
|
+
*/
|
|
1726
|
+
__forceResize() {
|
|
1727
|
+
const chart = this.configuration;
|
|
1728
|
+
const { options } = chart;
|
|
1729
|
+
const hasOrganizationSeries =
|
|
1730
|
+
options.chart.styledMode &&
|
|
1731
|
+
(options.chart.type === 'organization' || options.series.some((series) => series.type === 'organization'));
|
|
1732
|
+
if (!hasOrganizationSeries) {
|
|
1733
|
+
return;
|
|
1734
|
+
}
|
|
1735
|
+
|
|
1736
|
+
requestAnimationFrame(() => {
|
|
1737
|
+
chart.setSize(chart.chartWidth - 10, chart.chartHeight);
|
|
1738
|
+
chart.setSize(null, null);
|
|
1739
|
+
});
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1678
1742
|
/** @private */
|
|
1679
1743
|
__onRedraw() {
|
|
1680
1744
|
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
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
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
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
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
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
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
|
-
*
|
|
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
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
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
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
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
|
package/src/vaadin-chart.d.ts
CHANGED
|
@@ -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
|
-
* ####
|
|
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
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
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
|
-
* ####
|
|
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
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
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
|
-
* ####
|
|
61
|
+
* #### Using JS JSON API
|
|
71
62
|
*
|
|
72
|
-
*
|
|
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
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
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
|
-
*
|
|
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
|
|
@@ -144,6 +122,7 @@ export * from './vaadin-chart-mixin.js';
|
|
|
144
122
|
* @fires {CustomEvent} chart-drillupall - Fired after all the drilldown series has been drilled up.
|
|
145
123
|
* @fires {CustomEvent} chart-redraw - Fired after the chart redraw.
|
|
146
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.
|
|
147
126
|
* @fires {CustomEvent} series-after-animate - Fired when the series has finished its initial animation.
|
|
148
127
|
* @fires {CustomEvent} series-checkbox-click - Fired when the checkbox next to the series' name in the legend is clicked.
|
|
149
128
|
* @fires {CustomEvent} series-click - Fired when the series is clicked.
|
|
@@ -163,8 +142,8 @@ export * from './vaadin-chart-mixin.js';
|
|
|
163
142
|
* @fires {CustomEvent} point-drag-start - Fired when starting to drag a point.
|
|
164
143
|
* @fires {CustomEvent} point-drop - Fired when the point is dropped.
|
|
165
144
|
* @fires {CustomEvent} point-drag - Fired while dragging a point.
|
|
166
|
-
* @fires {CustomEvent} xaxes-extremes-set - Fired when
|
|
167
|
-
* @fires {CustomEvent} yaxes-extremes-set - Fired when
|
|
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.
|
|
168
147
|
*/
|
|
169
148
|
declare class Chart extends ChartMixin(ThemableMixin(ElementMixin(HTMLElement))) {
|
|
170
149
|
addEventListener<K extends keyof ChartEventMap>(
|