@vaadin/charts 23.0.0-alpha5 → 23.0.0-beta4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/charts",
3
- "version": "23.0.0-alpha5",
3
+ "version": "23.0.0-beta4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,9 +34,9 @@
34
34
  ],
35
35
  "dependencies": {
36
36
  "@polymer/polymer": "^3.0.0",
37
- "@vaadin/component-base": "23.0.0-alpha5",
37
+ "@vaadin/component-base": "23.0.0-beta4",
38
38
  "@vaadin/vaadin-license-checker": "^2.1.0",
39
- "@vaadin/vaadin-themable-mixin": "23.0.0-alpha5",
39
+ "@vaadin/vaadin-themable-mixin": "23.0.0-beta4",
40
40
  "highcharts": "9.2.2"
41
41
  },
42
42
  "devDependencies": {
@@ -44,5 +44,5 @@
44
44
  "@vaadin/testing-helpers": "^0.3.2",
45
45
  "sinon": "^9.2.4"
46
46
  },
47
- "gitHead": "74f9294964eb8552d96578c14af6ad214f5257bc"
47
+ "gitHead": "d0b447f1c31ca4256a5e26f2dcd27784447ff79b"
48
48
  }
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import { Axis, Chart as HighchartsChart, ExtremesObject, Options, Point, Series } from 'highcharts';
7
7
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
8
+ import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
8
9
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
9
10
 
10
11
  export type ChartCategories = Array<string> | { [key: number]: string };
@@ -418,7 +419,7 @@ export type ChartEventMap = HTMLElementEventMap & ChartCustomEventMap;
418
419
  * @fires {CustomEvent} xaxes-extremes-set - Fired when when the minimum and maximum is set for the X axis.
419
420
  * @fires {CustomEvent} yaxes-extremes-set - Fired when when the minimum and maximum is set for the Y axis.
420
421
  */
421
- declare class Chart extends ThemableMixin(ElementMixin(HTMLElement)) {
422
+ declare class Chart extends ResizeMixin(ThemableMixin(ElementMixin(HTMLElement))) {
422
423
  readonly options: Options;
423
424
 
424
425
  /**
@@ -26,6 +26,7 @@ import { beforeNextRender } from '@polymer/polymer/lib/utils/render-status.js';
26
26
  import { html, PolymerElement } from '@polymer/polymer/polymer-element.js';
27
27
  import Highcharts from 'highcharts/es-modules/masters/highstock.src.js';
28
28
  import { ElementMixin } from '@vaadin/component-base/src/element-mixin.js';
29
+ import { ResizeMixin } from '@vaadin/component-base/src/resize-mixin.js';
29
30
  import { ThemableMixin } from '@vaadin/vaadin-themable-mixin/vaadin-themable-mixin.js';
30
31
  import { ChartSeries } from './vaadin-chart-series.js';
31
32
 
@@ -234,10 +235,11 @@ export function deepMerge(target, source) {
234
235
  * @fires {CustomEvent} yaxes-extremes-set - Fired when when the minimum and maximum is set for the Y axis.
235
236
  *
236
237
  * @extends HTMLElement
238
+ * @mixes ResizeMixin
237
239
  * @mixes ThemableMixin
238
240
  * @mixes ElementMixin
239
241
  */
240
- class Chart extends ElementMixin(ThemableMixin(PolymerElement)) {
242
+ class Chart extends ResizeMixin(ElementMixin(ThemableMixin(PolymerElement))) {
241
243
  static get template() {
242
244
  return html`
243
245
  <style>
@@ -512,8 +514,6 @@ class Chart extends ElementMixin(ThemableMixin(PolymerElement)) {
512
514
  beta: 15,
513
515
  depth: 50
514
516
  };
515
-
516
- this.__mutationCallback = this.__mutationCallback.bind(this);
517
517
  }
518
518
 
519
519
  /** @protected */
@@ -532,9 +532,6 @@ class Chart extends ElementMixin(ThemableMixin(PolymerElement)) {
532
532
  this._jsonConfigurationBuffer = null;
533
533
  this.__initChart(options);
534
534
  this.__addChildObserver();
535
- const config = { attributes: true, characterData: true };
536
- this.__mutationObserver = new MutationObserver(this.__mutationCallback);
537
- this.__mutationObserver.observe(this, config);
538
535
  });
539
536
  }
540
537
 
@@ -918,24 +915,33 @@ class Chart extends ElementMixin(ThemableMixin(PolymerElement)) {
918
915
  };
919
916
  }
920
917
 
921
- /** @private */
922
- __reflow() {
918
+ /**
919
+ * Implements resize callback from `ResizeMixin`
920
+ * to reflow when the chart element is resized.
921
+ * @protected
922
+ * @override
923
+ */
924
+ _onResize(contentRect) {
923
925
  if (!this.configuration) {
924
926
  return;
925
927
  }
926
- this.configuration.reflow();
927
- }
928
928
 
929
- /** @private */
930
- __mutationCallback() {
931
- const { height: componentHeight } = this.getBoundingClientRect();
932
- const { chartHeight } = this.configuration;
929
+ const { height, width } = contentRect;
930
+ const { chartHeight, chartWidth } = this.configuration;
933
931
 
934
- if (componentHeight !== chartHeight) {
932
+ if (height !== chartHeight || width !== chartWidth) {
935
933
  this.__reflow();
936
934
  }
937
935
  }
938
936
 
937
+ /** @private */
938
+ __reflow() {
939
+ if (!this.configuration) {
940
+ return;
941
+ }
942
+ this.configuration.reflow();
943
+ }
944
+
939
945
  /** @private */
940
946
  __addChildObserver() {
941
947
  this._childObserver = new FlattenedNodesObserver(this.$.slot, (info) => {
@@ -1055,7 +1061,6 @@ class Chart extends ElementMixin(ThemableMixin(PolymerElement)) {
1055
1061
  /** @protected */
1056
1062
  disconnectedCallback() {
1057
1063
  super.disconnectedCallback();
1058
- this.__mutationObserver && this.__mutationObserver.disconnect();
1059
1064
  this._childObserver && this._childObserver.disconnect();
1060
1065
  }
1061
1066
 
@@ -48,6 +48,19 @@ const chartColors = css`
48
48
  --vaadin-charts-color-positive: var(--vaadin-charts-color-3);
49
49
  --vaadin-charts-color-negative: var(--vaadin-charts-color-9);
50
50
  }
51
+
52
+ :host([theme~='classic']) {
53
+ --vaadin-charts-color-0: #7cb5ec;
54
+ --vaadin-charts-color-1: #434348;
55
+ --vaadin-charts-color-2: #90ed7d;
56
+ --vaadin-charts-color-3: #f7a35c;
57
+ --vaadin-charts-color-4: #8085e9;
58
+ --vaadin-charts-color-5: #f15c80;
59
+ --vaadin-charts-color-6: #e4d354;
60
+ --vaadin-charts-color-7: #2b908f;
61
+ --vaadin-charts-color-8: #f45b5b;
62
+ --vaadin-charts-color-9: #91e8e1;
63
+ }
51
64
  `;
52
65
 
53
66
  const chartTheme = css`
@@ -48,6 +48,19 @@ const chartColors = css`
48
48
  --vaadin-charts-color-positive: var(--vaadin-charts-color-8);
49
49
  --vaadin-charts-color-negative: var(--vaadin-charts-color-0);
50
50
  }
51
+
52
+ :host([theme~='classic']) {
53
+ --vaadin-charts-color-0: #7cb5ec;
54
+ --vaadin-charts-color-1: #434348;
55
+ --vaadin-charts-color-2: #90ed7d;
56
+ --vaadin-charts-color-3: #f7a35c;
57
+ --vaadin-charts-color-4: #8085e9;
58
+ --vaadin-charts-color-5: #f15c80;
59
+ --vaadin-charts-color-6: #e4d354;
60
+ --vaadin-charts-color-7: #2b908f;
61
+ --vaadin-charts-color-8: #f45b5b;
62
+ --vaadin-charts-color-9: #91e8e1;
63
+ }
51
64
  `;
52
65
 
53
66
  const chartTheme = css`
@@ -1017,7 +1017,7 @@ const chartBaseTheme = css`
1017
1017
  }
1018
1018
 
1019
1019
  /* https://github.com/highcharts/highcharts/issues/16282 */
1020
- /* without this __mutationCallback always calls __reflow */
1020
+ /* without this the resize callback always calls __reflow */
1021
1021
  ul[aria-hidden='false'] {
1022
1022
  margin: 0px;
1023
1023
  }