ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject ignite git commit: IGNITE-843 Support multiple series on charts: pie chart.
Date Fri, 25 Sep 2015 04:07:38 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-843 e6991b886 -> 31cda5a6e


IGNITE-843 Support multiple series on charts: pie chart.


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

Branch: refs/heads/ignite-843
Commit: 31cda5a6ec29e55d23ff0ed3b1598345f281d943
Parents: e6991b8
Author: Alexey Kuznetsov <akuznetsov@apache.org>
Authored: Fri Sep 25 11:07:40 2015 +0700
Committer: Alexey Kuznetsov <akuznetsov@apache.org>
Committed: Fri Sep 25 11:07:40 2015 +0700

----------------------------------------------------------------------
 .../src/main/js/controllers/sql-controller.js   | 96 +++++++++++---------
 .../src/main/js/views/sql/chart-settings.jade   |  2 +-
 .../src/main/js/views/sql/sql.jade              |  1 -
 3 files changed, 55 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/31cda5a6/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 42f0f85..91f15c1 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,7 +638,29 @@ controlCenterModule.controller('sqlController',
         return dflt;
     }
 
-    function _chartDatum(paragraph) {
+    function _chartDatumLblNum(paragraph) {
+        var datum = [];
+
+        if (paragraph.hasChartColumns()) {
+            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});
+            });
+        }
+
+        return datum;
+    }
+
+
+    function _chartDatumNumNum(paragraph) {
         var datum = [];
 
         if (paragraph.hasChartColumns()) {
@@ -663,7 +685,7 @@ controlCenterModule.controller('sqlController',
         return col.label;
     }
 
-    function _insertChart(paragraph, datum, chart) {
+    function _insertChart(paragraph, datum, chart, remove) {
         var chartId = 'chart-' + paragraph.id;
 
         var xAxisLabel = 'X';
@@ -675,8 +697,8 @@ controlCenterModule.controller('sqlController',
         }
 
         $timeout(function() {
-            // Remove previous chart.
-            d3.selectAll('#' + chartId + ' svg > *').remove();
+            if (remove)
+                d3.select('#' + chartId).selectAll('*').remove();
 
             chart.height(400);
 
@@ -687,7 +709,8 @@ controlCenterModule.controller('sqlController',
                 chart.yAxis.axisLabel(yAxisLabel);
 
             // Insert new chart.
-            d3.select('#' + chartId + ' svg')
+            d3.select('#' + chartId)
+                .append('svg')
                 .datum(datum)
                 .call(chart)
                 .attr('height', 400);
@@ -735,49 +758,38 @@ controlCenterModule.controller('sqlController',
                 .y(_yVal)
                 .margin({left: 70});
 
-            var datum = [];
-
-            if (paragraph.hasChartColumns())
-                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, datum, chart);
+            _insertChart(paragraph, _chartDatumLblNum(paragraph), chart, true);
         });
     }
 
     function _pieChart(paragraph) {
-        var index = 0;
+        var datum = _chartDatumLblNum(paragraph);
 
-        nv.addGraph(function() {
-            var chart = nv.models.pieChart()
-                    .x(function (row) {
-                        return _chartLabel(row, paragraph.chartKeyCols[0].value, index++);
-                    })
-                    .y(function (row) {
-                        return _chartNumber(row, paragraph.chartValCols[0].value, 0);
-                    })
-                .showLabels(true)
-                .labelThreshold(.05)
-                .labelType("percent")
-                .donut(true)
-                .donutRatio(0.35);
+        if (datum.length == 0)
+            datum = [{key: 'No data', values: []}];
+
+        var first = true;
 
-            var datum = [];
+        datum.forEach(function (d) {
+            nv.addGraph(function() {
+                var chart = nv.models.pieChart()
+                    .x(_xLbl)
+                    .y(_yVal)
+                    .showLabels(true)
+                    .labelThreshold(.05)
+                    .labelType("percent")
+                    .donut(true)
+                    .donutRatio(0.35);
 
-            if (paragraph.hasChartColumns())
-                datum = paragraph.rows;
+                var datum = [];
 
-            _insertChart(paragraph, datum, chart);
+                if (paragraph.hasChartColumns())
+                    datum = paragraph.rows;
+
+                _insertChart(paragraph, d.values, chart, first);
+
+                first = false;
+            });
         });
     }
 
@@ -796,7 +808,7 @@ controlCenterModule.controller('sqlController',
                 .y(_yY)
                 .margin({left: 70});
 
-            _insertChart(paragraph, _chartDatum(paragraph), chart);
+            _insertChart(paragraph, _chartDatumNumNum(paragraph), chart, true);
         });
     }
 
@@ -807,7 +819,7 @@ controlCenterModule.controller('sqlController',
                 .y(_yY)
                 .margin({left: 70});
 
-            _insertChart(paragraph, _chartDatum(paragraph), chart);
+            _insertChart(paragraph, _chartDatumNumNum(paragraph), chart, true);
         });
     }
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/31cda5a6/modules/control-center-web/src/main/js/views/sql/chart-settings.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/sql/chart-settings.jade b/modules/control-center-web/src/main/js/views/sql/chart-settings.jade
index 708bff6..1650ee1 100644
--- a/modules/control-center-web/src/main/js/views/sql/chart-settings.jade
+++ b/modules/control-center-web/src/main/js/views/sql/chart-settings.jade
@@ -26,7 +26,7 @@
                     li(ng-repeat='col in paragraph.chartColumns track by $index')
                         .btn.btn-default.btn-chart-column-movable(dnd-draggable='col' dnd-effect-allowed='copy'
dnd-dragstart='chartSettingsDragStart(paragraph)') {{col.label}}
                 label X axis
-                ul.chart-settings-columns-list(id='chart-settings-keys' dnd-list='paragraph.chartKeyCols'
dnd-drop='acceptKeyColumn(event, index, item, external, type, allowedType)')
+                ul.chart-settings-columns-list(id='chart-settings-keys' dnd-list='paragraph.chartKeyCols'
dnd-disable-if='paragraph.chartKeyCols.length > 0' dnd-drop='acceptKeyColumn(event, index,
item, external, type, allowedType)')
                     li(ng-repeat='col in paragraph.chartKeyCols track by $index')
                         .btn.btn-info.btn-chart-column {{col.label}}
                             i.fa.fa-close(ng-click='removeKeyColumn(paragraph, $index)')

http://git-wip-us.apache.org/repos/asf/ignite/blob/31cda5a6/modules/control-center-web/src/main/js/views/sql/sql.jade
----------------------------------------------------------------------
diff --git a/modules/control-center-web/src/main/js/views/sql/sql.jade b/modules/control-center-web/src/main/js/views/sql/sql.jade
index ee6a4e6..b02989c 100644
--- a/modules/control-center-web/src/main/js/views/sql/sql.jade
+++ b/modules/control-center-web/src/main/js/views/sql/sql.jade
@@ -151,7 +151,6 @@ block container
                                             i.fa.fa-chevron-circle-down
                                             a(ng-show='paragraph.chart' ng-click='$event.stopPropagation()'
bs-popover data-template-url='chart-settings' data-placement='bottom' data-auto-close='1'
data-trigger='click') Chart settings
                                         div(id='chart-{{paragraph.id}}')
-                                            svg
                                     div(ng-show='paragraph.queryId')
                                         hr(style='margin-top: 0; margin-bottom: 5px')
                                         i.fa.fa-chevron-circle-right(style='float: right;margin-right:
10px;' ng-click='nextPage(paragraph)')


Mime
View raw message