You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ak...@apache.org on 2015/09/25 04:58:23 UTC

ignite git commit: IGNITE-843 WIP support multiple series on charts.

Repository: ignite
Updated Branches:
  refs/heads/ignite-843 a9c59f408 -> e6991b886


IGNITE-843 WIP support multiple series on charts.


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

Branch: refs/heads/ignite-843
Commit: e6991b8864e03f8cbdef49a7b3f97a51721c1cd8
Parents: a9c59f4
Author: Alexey Kuznetsov <ak...@apache.org>
Authored: Fri Sep 25 09:58:22 2015 +0700
Committer: Alexey Kuznetsov <ak...@apache.org>
Committed: Fri Sep 25 09:58:22 2015 +0700

----------------------------------------------------------------------
 .../src/main/js/controllers/sql-controller.js   | 80 ++++++++++++--------
 1 file changed, 49 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e6991b88/modules/control-center-web/src/main/js/controllers/sql-controller.js
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/controllers/sql-controller.js b/modules/control-center-web/src/main/js/controllers/sql-controller.js
index 25cbe8e..42f0f85 100644
--- a/modules/control-center-web/src/main/js/controllers/sql-controller.js
+++ b/modules/control-center-web/src/main/js/controllers/sql-controller.js
@@ -638,21 +638,25 @@ controlCenterModule.controller('sqlController',
         return dflt;
     }
 
-    function _chartDatum(key, paragraph) {
-        var values = [];
+    function _chartDatum(paragraph) {
+        var datum = [];
 
-         if (paragraph.hasChartColumns()) {
-             var index = 0;
+        if (paragraph.hasChartColumns()) {
+             paragraph.chartValCols.forEach(function (valCol) {
+                 var index = 0;
+
+                 var values = _.map(paragraph.rows, function (row) {
+                     return {
+                         x: _chartNumber(row, paragraph.chartKeyCols[0].value, index++),
+                         y: _chartNumber(row, valCol.value, 0)
+                     }
+                 });
 
-             values = _.map(paragraph.rows, function (row) {
-                 return {
-                     x: _chartNumber(row, paragraph.chartKeyCols[0].value, index++),
-                     y: _chartNumber(row, paragraph.chartValCols[0].value, 0)
-                 }
+                 datum.push({key: valCol.label, values: values});
              });
          }
 
-        return [{key: key, values: values}];
+        return datum;
     }
 
     function _colLabel(col) {
@@ -714,26 +718,40 @@ controlCenterModule.controller('sqlController',
         }
     };
 
-    function _barChart(paragraph) {
-        var index = 0;
+    function _xLbl(d) {
+        return d.lbl;
+    }
 
+    function _yVal(d) {
+        return d.val;
+    }
+
+
+    function _barChart(paragraph) {
         nv.addGraph(function() {
-            var chart = nv.models.discreteBarChart()
-                .x(function (d) { return d.label; })
-                .y(function (d) { return d.value;})
+            var chart = nv.models.multiBarChart()
+                .showControls(true) //Allow user to switch between 'Grouped' and 'Stacked' mode.
+                .x(_xLbl)
+                .y(_yVal)
                 .margin({left: 70});
 
-            var values = [];
+            var datum = [];
 
             if (paragraph.hasChartColumns())
-                values = _.map(paragraph.rows, function (row) {
-                    return {
-                        label: _chartLabel(row, paragraph.chartKeyCols[0].value, index++),
-                        value: _chartNumber(row, paragraph.chartValCols[0].value, 0)
-                    };
-            });
+                paragraph.chartValCols.forEach(function (valCol) {
+                    var index = 0;
+
+                    var values = _.map(paragraph.rows, function (row) {
+                        return {
+                            lbl: _chartLabel(row, paragraph.chartKeyCols[0].value, index++),
+                            val: _chartNumber(row, valCol.value, 0)
+                        }
+                    });
+
+                    datum.push({key: valCol.label, values: values});
+                });
 
-            _insertChart(paragraph, [{key: 'bar', values: values}], chart);
+            _insertChart(paragraph, datum, chart);
         });
     }
 
@@ -763,33 +781,33 @@ controlCenterModule.controller('sqlController',
         });
     }
 
-    function _x(d) {
+    function _xX(d) {
         return d.x;
     }
 
-    function _y(d) {
+    function _yY(d) {
         return d.y;
     }
 
     function _lineChart(paragraph) {
         nv.addGraph(function() {
             var chart = nv.models.lineChart()
-                .x(_x)
-                .y(_y)
+                .x(_xX)
+                .y(_yY)
                 .margin({left: 70});
 
-            _insertChart(paragraph, _chartDatum('Line chart', paragraph), chart);
+            _insertChart(paragraph, _chartDatum(paragraph), chart);
         });
     }
 
     function _areaChart(paragraph) {
         nv.addGraph(function() {
             var chart = nv.models.stackedAreaChart()
-                .x(_x)
-                .y(_y)
+                .x(_xX)
+                .y(_yY)
                 .margin({left: 70});
 
-            _insertChart(paragraph, _chartDatum('Area chart', paragraph), chart);
+            _insertChart(paragraph, _chartDatum(paragraph), chart);
         });
     }