IGNITE-9565 Web Console: Fixed series visibility on update via lastPoint.

Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/63d57479
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/63d57479
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/63d57479

Branch: refs/heads/ignite-gg-14206
Commit: 63d57479c45c926302439abd5d9837b5fd6943d0
Parents: 7b0d30b
Author: Alexey Kuznetsov <akuznet...@apache.org>
Authored: Wed Sep 26 15:25:48 2018 +0700
Committer: Alexey Kuznetsov <akuznet...@apache.org>
Committed: Wed Sep 26 15:25:48 2018 +0700

----------------------------------------------------------------------
 .../app/components/ignite-chart/controller.js   | 31 +++++++++++++++-----
 1 file changed, 23 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/63d57479/modules/web-console/frontend/app/components/ignite-chart/controller.js
----------------------------------------------------------------------
diff --git 
a/modules/web-console/frontend/app/components/ignite-chart/controller.js 
b/modules/web-console/frontend/app/components/ignite-chart/controller.js
index a351e7f..2012aec 100644
--- a/modules/web-console/frontend/app/components/ignite-chart/controller.js
+++ b/modules/web-console/frontend/app/components/ignite-chart/controller.js
@@ -71,7 +71,9 @@ export class IgniteChartController {
     }
 
     $onDestroy() {
-        if (this.chart) this.chart.destroy();
+        if (this.chart)
+            this.chart.destroy();
+
         this.$element = this.ctx = this.chart = null;
     }
 
@@ -79,6 +81,11 @@ export class IgniteChartController {
         this.chartColors = _.get(this.chartOptions, 'chartColors', 
this.IgniteChartColors);
     }
 
+    _refresh() {
+        this.onRefresh();
+        this.rerenderChart();
+    }
+
     /**
      * @param {{chartOptions: 
ng.IChangesObject<import('chart.js').ChartConfiguration>, chartTitle: 
ng.IChangesObject<string>, chartDataPoint: 
ng.IChangesObject<IgniteChartDataPoint>, chartHistory: 
ng.IChangesObject<Array<IgniteChartDataPoint>>}} changes
      */
@@ -89,6 +96,7 @@ export class IgniteChartController {
         // TODO: Investigate other signaling for resetting component state.
         if (changes.chartDataPoint && 
_.isNil(changes.chartDataPoint.currentValue)) {
             this.clearDatasets();
+
             return;
         }
 
@@ -101,8 +109,8 @@ export class IgniteChartController {
 
             this.newPoints.splice(0, this.newPoints.length, 
...changes.chartHistory.currentValue);
 
-            this.onRefresh();
-            this.rerenderChart();
+            this._refresh();
+
             return;
         }
 
@@ -112,6 +120,8 @@ export class IgniteChartController {
 
             this.newPoints.push(this.chartDataPoint);
             this.localHistory.push(this.chartDataPoint);
+
+            this._refresh();
         }
     }
 
@@ -321,8 +331,13 @@ export class IgniteChartController {
     addDataset(datasetName) {
         if (this.findDatasetIndex(datasetName) >= 0)
             throw new Error(`Dataset with name ${datasetName} is already in 
chart`);
-        else
-            this.config.data.datasets.push({ label: datasetName, data: [], 
hidden: true });
+        else {
+            const datasetIsHidden = 
_.isNil(this.config.datasetLegendMapping[datasetName].hidden)
+                ? false
+                : this.config.datasetLegendMapping[datasetName].hidden;
+
+            this.config.data.datasets.push({ label: datasetName, data: [], 
hidden: datasetIsHidden });
+        }
     }
 
     findDatasetIndex(searchedDatasetLabel) {
@@ -331,8 +346,7 @@ export class IgniteChartController {
 
     changeXRange(range) {
         if (this.chart) {
-            const deltaInMilliSeconds = range.value * 60 * 1000;
-            this.chart.config.options.plugins.streaming.duration = 
deltaInMilliSeconds;
+            this.chart.config.options.plugins.streaming.duration = range.value 
* 60 * 1000;
 
             this.clearDatasets();
             this.newPoints.splice(0, this.newPoints.length, 
...this.localHistory);
@@ -349,6 +363,7 @@ export class IgniteChartController {
     }
 
     rerenderChart() {
-        this.chart.update();
+        if (this.chart)
+            this.chart.update();
     }
 }

Reply via email to