@eclipse-scout/chart 22.0.0-beta.1 → 22.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eclipse-scout/chart",
3
- "version": "22.0.0-beta.1",
3
+ "version": "22.0.0",
4
4
  "description": "Eclipse Scout chart",
5
5
  "author": "BSI Business Systems Integration AG",
6
6
  "homepage": "https://www.eclipse.org/scout",
@@ -25,13 +25,13 @@
25
25
  "src"
26
26
  ],
27
27
  "devDependencies": {
28
- "@eclipse-scout/cli": "22.0.0-beta.1",
28
+ "@eclipse-scout/cli": "22.0.0",
29
29
  "@eclipse-scout/releng": "^22.0.0",
30
30
  "jasmine-core": "3.10.1",
31
31
  "karma": "6.3.9"
32
32
  },
33
33
  "dependencies": {
34
- "@eclipse-scout/core": "22.0.0-beta.1",
34
+ "@eclipse-scout/core": "22.0.0",
35
35
  "jquery": "3.6.0",
36
36
  "chart.js": "3.7.0",
37
37
  "chartjs-plugin-datalabels": "2.0.0"
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2010-2020 BSI Business Systems Integration AG.
2
+ * Copyright (c) 2010-2022 BSI Business Systems Integration AG.
3
3
  * All rights reserved. This program and the accompanying materials
4
4
  * are made available under the terms of the Eclipse Public License v1.0
5
5
  * which accompanies this distribution, and is available at
@@ -96,13 +96,6 @@ export default class AbstractChartRenderer {
96
96
  // Override in subclasses
97
97
  }
98
98
 
99
- checkCompletlyRendered() {
100
- if (this.rendered || !this.chart.data) {
101
- return;
102
- }
103
- this.render();
104
- }
105
-
106
99
  renderCheckedItems() {
107
100
  if (this.rendered) {
108
101
  this._renderCheckedItems();
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2010-2021 BSI Business Systems Integration AG.
2
+ * Copyright (c) 2010-2022 BSI Business Systems Integration AG.
3
3
  * All rights reserved. This program and the accompanying materials
4
4
  * are made available under the terms of the Eclipse Public License v1.0
5
5
  * which accompanies this distribution, and is available at
@@ -45,6 +45,7 @@ export default class Chart extends Widget {
45
45
 
46
46
  this._updateChartTimeoutId = null;
47
47
  this._updateChartOpts = null;
48
+ this._updateChartOptsWhileNotAttached = [];
48
49
  this.updatedOnce = false;
49
50
  }
50
51
 
@@ -103,6 +104,11 @@ export default class Chart extends Widget {
103
104
  });
104
105
  }
105
106
 
107
+ _renderOnAttach() {
108
+ super._renderOnAttach();
109
+ this._updateChartOptsWhileNotAttached.splice(0).forEach(opts => this.updateChart($.extend(true, {}, opts, {debounce: true})));
110
+ }
111
+
106
112
  _remove() {
107
113
  if (this.chartRenderer) {
108
114
  this.chartRenderer.remove(false);
@@ -278,6 +284,7 @@ export default class Chart extends Widget {
278
284
  */
279
285
  updateChart(opts) {
280
286
  opts = opts || {};
287
+ opts.enforceRerender = !opts.onlyUpdateData && !opts.onlyRefresh;
281
288
 
282
289
  // Cancel previously scheduled update and merge opts
283
290
  if (this._updateChartTimeoutId) {
@@ -285,6 +292,9 @@ export default class Chart extends Widget {
285
292
  if (this._updateChartOpts) {
286
293
  // Inherit 'true' values from previously scheduled updates
287
294
  opts.requestAnimation = opts.requestAnimation || this._updateChartOpts.requestAnimation;
295
+ opts.onlyUpdateData = opts.onlyUpdateData || this._updateChartOpts.onlyUpdateData;
296
+ opts.onlyRefresh = opts.onlyRefresh || this._updateChartOpts.onlyRefresh;
297
+ opts.enforceRerender = opts.enforceRerender || this._updateChartOpts.enforceRerender;
288
298
  }
289
299
  this._updateChartTimeoutId = null;
290
300
  this._updateChartOpts = null;
@@ -308,11 +318,17 @@ export default class Chart extends Widget {
308
318
  function updateChartImpl() {
309
319
  this._updateChartTimeoutId = null;
310
320
  this._updateChartOpts = null;
311
- if (opts.onlyUpdateData && this.chartRenderer && this.chartRenderer.isDataUpdatable()) {
312
- this.chartRenderer.updateData(opts.requestAnimation);
313
- } else if (opts.onlyRefresh && this.chartRenderer) {
314
- this.chartRenderer.refresh();
315
- } else if (this.chartRenderer) {
321
+
322
+ if (!this.$container || !this.$container.isAttached()) {
323
+ this._updateChartOptsWhileNotAttached.push(opts);
324
+ return;
325
+ }
326
+
327
+ this.updatedOnce = true;
328
+ if (!this.chartRenderer) {
329
+ return; // nothing to render when there is no renderer.
330
+ }
331
+ if (opts.enforceRerender) {
316
332
  this.chartRenderer.remove(this.chartRenderer.shouldAnimateRemoveOnUpdate(opts), chartAnimationStopping => {
317
333
  if (this.removing || chartAnimationStopping) {
318
334
  // prevent exceptions trying to render after navigated away, and do not update/render while a running animation is being stopped
@@ -321,8 +337,11 @@ export default class Chart extends Widget {
321
337
  this.chartRenderer.render(opts.requestAnimation);
322
338
  this.trigger('chartRender');
323
339
  });
340
+ } else if (opts.onlyUpdateData && this.chartRenderer.isDataUpdatable()) {
341
+ this.chartRenderer.updateData(opts.requestAnimation);
342
+ } else if (opts.onlyRefresh) {
343
+ this.chartRenderer.refresh();
324
344
  }
325
- this.updatedOnce = true;
326
345
  }
327
346
  }
328
347
 
@@ -916,6 +916,9 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
916
916
  }
917
917
 
918
918
  _renderTooltipLater(context) {
919
+ if (!this.rendered || this.removing) {
920
+ return;
921
+ }
919
922
  let tooltip = context.tooltip,
920
923
  tooltipItems = tooltip._tooltipItems;
921
924
  if (tooltipItems.length < 1) {
@@ -1888,7 +1891,7 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
1888
1891
  }
1889
1892
  let defaultGenerateLabels = defaultTypeGenerateLabels || ChartJs.defaults.plugins.legend.labels.generateLabels;
1890
1893
  let labels = defaultGenerateLabels.call(chart, chart);
1891
- if (!this.rendered || this.removing) {
1894
+ if (this.removing) {
1892
1895
  return labels;
1893
1896
  }
1894
1897
  let data = config.data,
@@ -2694,10 +2697,10 @@ export default class ChartJsRenderer extends AbstractChartRenderer {
2694
2697
  _remove(afterRemoveFunc) {
2695
2698
  if (this.rendered && !this.removing) {
2696
2699
  this.removing = true;
2697
- this.$canvas.remove();
2698
- this.$canvas = null;
2699
2700
  this.chartJs.destroy();
2700
2701
  this.chartJs = null;
2702
+ this.$canvas.remove();
2703
+ this.$canvas = null;
2701
2704
  }
2702
2705
  super._remove(afterRemoveFunc);
2703
2706
  this.removing = false;
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2010-2021 BSI Business Systems Integration AG.
2
+ * Copyright (c) 2010-2022 BSI Business Systems Integration AG.
3
3
  * All rights reserved. This program and the accompanying materials
4
4
  * are made available under the terms of the Eclipse Public License v1.0
5
5
  * which accompanies this distribution, and is available at
@@ -112,14 +112,6 @@ export default class VennChartRenderer extends AbstractSvgChartRenderer {
112
112
  }
113
113
  }
114
114
 
115
- checkCompletlyRendered() {
116
- if (this.readyToDraw) {
117
- this._draw(false, true);
118
- } else {
119
- super.checkCompletlyRendered();
120
- }
121
- }
122
-
123
115
  remove(requestAnimation, afterRemoveFunc) {
124
116
  this._cancelAsync3Calculator();
125
117
  super.remove(requestAnimation, afterRemoveFunc);
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright (c) 2010-2020 BSI Business Systems Integration AG.
2
+ * Copyright (c) 2010-2022 BSI Business Systems Integration AG.
3
3
  * All rights reserved. This program and the accompanying materials
4
4
  * are made available under the terms of the Eclipse Public License v1.0
5
5
  * which accompanies this distribution, and is available at
@@ -36,11 +36,4 @@ export default class ChartField extends FormField {
36
36
  this.chart.remove();
37
37
  this._removeField();
38
38
  }
39
-
40
- _renderOnAttach() {
41
- super._renderOnAttach();
42
- if (this.chart && this.chart.chartRenderer) {
43
- this.chart.chartRenderer.checkCompletlyRendered();
44
- }
45
- }
46
39
  }