Repository: ignite
Updated Branches:
  refs/heads/ignite-843-rc1 e4078904f -> d0945a109


IGNITE-1705 Fixed x-axis labels in special case. Fixed clear history on query 
change.


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

Branch: refs/heads/ignite-843-rc1
Commit: d0945a1096acb030022315a4a8e7f6d7dd5ea5e6
Parents: e407890
Author: Alexey Kuznetsov <[email protected]>
Authored: Fri Oct 16 17:54:05 2015 +0700
Committer: Alexey Kuznetsov <[email protected]>
Committed: Fri Oct 16 17:54:05 2015 +0700

----------------------------------------------------------------------
 .../src/main/js/controllers/sql-controller.js   | 32 ++++++++++++++++----
 1 file changed, 26 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/d0945a10/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 799962c..960575c 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
@@ -512,6 +512,17 @@ consoleModule.controller('sqlController',
 
             var chartHistory = paragraph.chartHistory;
 
+            // Clear history on query change.
+            if (paragraph.prevQuery != paragraph.query) {
+                paragraph.prevQuery = paragraph.query;
+
+                chartHistory.length = 0;
+
+                _.forEach(paragraph.charts, function (chart) {
+                    chart.data.length = 0;
+                })
+            }
+
             // Add results to history.
             chartHistory.push({tm: new Date(), rows: paragraph.rows});
 
@@ -546,7 +557,14 @@ consoleModule.controller('sqlController',
     $scope.execute = function (paragraph) {
         _saveNotebook();
 
-        paragraph.queryArgs = { type: "QUERY", query: paragraph.query, 
pageSize: paragraph.pageSize, cacheName: paragraph.cacheName };
+        paragraph.prevQuery = paragraph.queryArgs ? paragraph.queryArgs.query 
: paragraph.query;
+
+        paragraph.queryArgs = {
+            type: "QUERY",
+            query: paragraph.query,
+            pageSize: paragraph.pageSize,
+            cacheName: paragraph.cacheName
+        };
 
         _showLoading(paragraph, true);
 
@@ -911,14 +929,16 @@ consoleModule.controller('sqlController',
         return d3.time.format('%X')(new Date(d));
     }
 
-    var _xAxisWithLabelFormat = function(values) {
+    var _xAxisWithLabelFormat = function(paragraph) {
         return function (d) {
+            var values = paragraph.charts[0].data[0].values;
+
             var dx = values[d];
 
             if (!dx)
                 return d3.format(',.2f')(d);
 
-            var lbl = values[d]['xLbl'];
+            var lbl = dx.xLbl;
 
             return lbl ? lbl : d3.format(',.2f')(d);
         }
@@ -955,7 +975,7 @@ consoleModule.controller('sqlController',
                     y: _yY,
                     xAxis: {
                         axisLabel: _chartAxisLabel(paragraph.chartKeyCols, 
'X'),
-                        tickFormat: paragraph.chartTimeLineEnabled() ? 
_xAxisTimeFormat : _xAxisWithLabelFormat(datum[0].values),
+                        tickFormat: paragraph.chartTimeLineEnabled() ? 
_xAxisTimeFormat : _xAxisWithLabelFormat(paragraph),
                         showMaxMin: false
                     },
                     yAxis: {
@@ -1021,7 +1041,7 @@ consoleModule.controller('sqlController',
                     y: _yY,
                     xAxis: {
                         axisLabel: _chartAxisLabel(paragraph.chartKeyCols, 
'X'),
-                        tickFormat: paragraph.chartTimeLineEnabled() ? 
_xAxisTimeFormat : _xAxisWithLabelFormat(datum[0].values),
+                        tickFormat: paragraph.chartTimeLineEnabled() ? 
_xAxisTimeFormat : _xAxisWithLabelFormat(paragraph),
                         showMaxMin: false
                     },
                     yAxis: {
@@ -1054,7 +1074,7 @@ consoleModule.controller('sqlController',
                     y: _yY,
                     xAxis: {
                         axisLabel:  _chartAxisLabel(paragraph.chartKeyCols, 
'X'),
-                        tickFormat: paragraph.chartTimeLineEnabled() ? 
_xAxisTimeFormat : _xAxisWithLabelFormat(datum[0].values),
+                        tickFormat: paragraph.chartTimeLineEnabled() ? 
_xAxisTimeFormat : _xAxisWithLabelFormat(paragraph),
                         showMaxMin: false
                     },
                     yAxis: {

Reply via email to