@genesislcap/g2plot-chart 14.197.0 → 14.197.1-alpha-1283f91.0

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.
@@ -152,6 +152,10 @@
152
152
  "kind": "field",
153
153
  "name": "config"
154
154
  },
155
+ {
156
+ "kind": "method",
157
+ "name": "configChanged"
158
+ },
155
159
  {
156
160
  "kind": "field",
157
161
  "name": "data",
@@ -25,7 +25,21 @@ declare const G2PlotChart_base: (new (...args: any[]) => {
25
25
  hidden: boolean;
26
26
  inert: boolean;
27
27
  innerText: string;
28
- lang: string;
28
+ lang: string; /**
29
+ * Get which legend items are selected (shown/hidden) so they can be re-applied during a subsequent connectedCallback
30
+ *
31
+ * @remarks
32
+ * When moving a chart around with `appendChild()` the state of hidden/shown fields is reset. This callback function
33
+ * will cache the state of the legend items so they can be re-applied when the chart is re-rendered. The cache
34
+ * is applied in `this.initalizeConfiguration()`.
35
+ *
36
+ * To get the state of the legend items, the chart's `filteredData` is used. This is the data that is currently
37
+ * shown on the chart. If we diff this with all of the data from `this.data` we can work out which fields are hidden or shown.
38
+ *
39
+ * To get the legend name from the data to pass to the options we use a legend parser which is a function that takes a single
40
+ * data item and extracts the legend name from it. There are defaults for certain chart types in `this.getLegendNameFromData`
41
+ * but this can be overridden by passing a `legendParser` function to the chart.
42
+ */
29
43
  readonly offsetHeight: number;
30
44
  readonly offsetLeft: number;
31
45
  readonly offsetParent: Element;
@@ -333,6 +347,7 @@ export declare class G2PlotChart extends G2PlotChart_base {
333
347
  chartContainer: HTMLElement;
334
348
  type: ChartTypes;
335
349
  config: any;
350
+ configChanged(): void;
336
351
  data: any[];
337
352
  errorItems: ChartErrorItem<ChartErrorEvent['detail']>[];
338
353
  private legendSelected;
@@ -1 +1 @@
1
- {"version":3,"file":"chart.d.ts","sourceRoot":"","sources":["../../src/chart.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;A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AAE;;IAmB5C,OAAO,CAAC,mBAAmB;IAI3B,OAAO,CAAC,YAAY;IAUX,SAAS,IAAI,IAAI;IAU1B,WAAW;IAUX,iBAAiB;IAcjB,oBAAoB,IAAI,IAAI;IAW5B,YAAY,mBAEV;IAEF,OAAO,CAAC,cAAc,CAapB;IAEF,OAAO,CAAC,qBAAqB,CAO3B;IAEF;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,8BAA8B;IA0BtC,OAAO,CAAC,sBAAsB,CAW5B;CACH;AAGD,eAAO,MAAM,4BAA4B,EAAE,cAA0B,CAAC;AAEtE,eAAO,MAAM,kBAAkB,IAAK,CAAC;AAErC;;;;;;GAMG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;sBAMtB,CAAC"}
package/dist/esm/chart.js CHANGED
@@ -13,6 +13,11 @@ ChartDatasource;
13
13
  * @tagname %%prefix%%-g2plot-chart
14
14
  */
15
15
  export class G2PlotChart extends LifecycleMixin(FoundationElement) {
16
+ configChanged() {
17
+ if (this.chartContainer) {
18
+ this.renderChart();
19
+ }
20
+ }
16
21
  dataChanged(oldValue, newValue) {
17
22
  var _a;
18
23
  if (!newValue)
@@ -84,17 +89,19 @@ export class G2PlotChart extends LifecycleMixin(FoundationElement) {
84
89
  return copy;
85
90
  }
86
91
  renderChart() {
92
+ if (this.chart) {
93
+ this.chart.destroy();
94
+ this.chart.off('*', this.eventHandler);
95
+ }
87
96
  this.initalizeChart[this.type](this.initalizeConfiguration());
88
97
  this.chart.render();
98
+ this.chart.on('*', this.eventHandler);
89
99
  }
90
100
  connectedCallback() {
91
101
  var _a;
92
102
  super.connectedCallback();
93
103
  registerRapidShape();
94
- if (this.config) {
95
- this.renderChart();
96
- this.chart.on('*', this.eventHandler);
97
- }
104
+ this.renderChart();
98
105
  this.cacheHiddenLegendItemsCallback = this.cacheHiddenLegendItemsCallback.bind(this);
99
106
  // as the chart is destroyed in the disconnect the event is wiped
100
107
  (_a = this.chart) === null || _a === void 0 ? void 0 : _a.on('legend-item:click', this.cacheHiddenLegendItemsCallback);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/g2plot-chart",
3
3
  "description": "Genesis G2plot Chart",
4
- "version": "14.197.0",
4
+ "version": "14.197.1-alpha-1283f91.0",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -53,22 +53,22 @@
53
53
  }
54
54
  },
55
55
  "devDependencies": {
56
- "@genesislcap/foundation-testing": "14.197.0",
57
- "@genesislcap/genx": "14.197.0",
58
- "@genesislcap/rollup-builder": "14.197.0",
59
- "@genesislcap/ts-builder": "14.197.0",
60
- "@genesislcap/uvu-playwright-builder": "14.197.0",
61
- "@genesislcap/vite-builder": "14.197.0",
62
- "@genesislcap/webpack-builder": "14.197.0",
56
+ "@genesislcap/foundation-testing": "14.197.1-alpha-1283f91.0",
57
+ "@genesislcap/genx": "14.197.1-alpha-1283f91.0",
58
+ "@genesislcap/rollup-builder": "14.197.1-alpha-1283f91.0",
59
+ "@genesislcap/ts-builder": "14.197.1-alpha-1283f91.0",
60
+ "@genesislcap/uvu-playwright-builder": "14.197.1-alpha-1283f91.0",
61
+ "@genesislcap/vite-builder": "14.197.1-alpha-1283f91.0",
62
+ "@genesislcap/webpack-builder": "14.197.1-alpha-1283f91.0",
63
63
  "rimraf": "^5.0.0"
64
64
  },
65
65
  "dependencies": {
66
66
  "@antv/g2plot": "^2.4.20",
67
- "@genesislcap/foundation-comms": "14.197.0",
68
- "@genesislcap/foundation-logger": "14.197.0",
69
- "@genesislcap/foundation-ui": "14.197.0",
70
- "@genesislcap/foundation-utils": "14.197.0",
71
- "@genesislcap/foundation-zero": "14.197.0",
67
+ "@genesislcap/foundation-comms": "14.197.1-alpha-1283f91.0",
68
+ "@genesislcap/foundation-logger": "14.197.1-alpha-1283f91.0",
69
+ "@genesislcap/foundation-ui": "14.197.1-alpha-1283f91.0",
70
+ "@genesislcap/foundation-utils": "14.197.1-alpha-1283f91.0",
71
+ "@genesislcap/foundation-zero": "14.197.1-alpha-1283f91.0",
72
72
  "@microsoft/fast-element": "^1.12.0",
73
73
  "@microsoft/fast-foundation": "^2.49.4",
74
74
  "tslib": "^2.3.1"
@@ -82,5 +82,5 @@
82
82
  "access": "public"
83
83
  },
84
84
  "customElements": "dist/custom-elements.json",
85
- "gitHead": "1520d802086369c1ef2feb25e9d06a27b6fd09d4"
85
+ "gitHead": "87e2c6ef46239131a272ae5132227833e88339fb"
86
86
  }