Repository: kylin Updated Branches: refs/heads/v1.6.0-rc1 f2003eeee -> da826094b
KYLIN 2119 Wrong chart value and sort when process scientific notation Signed-off-by: Jason <jiat...@163.com> Project: http://git-wip-us.apache.org/repos/asf/kylin/repo Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/da826094 Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/da826094 Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/da826094 Branch: refs/heads/v1.6.0-rc1 Commit: da826094bf86759aee0ceb82eae7fc1aed88edf6 Parents: f2003ee Author: chenzhx <346839...@qq.com> Authored: Mon Nov 7 18:40:26 2016 +0800 Committer: Jason <jiat...@163.com> Committed: Mon Nov 7 18:53:06 2016 +0800 ---------------------------------------------------------------------- webapp/app/index.html | 2 +- webapp/app/js/controllers/query.js | 11 +++++++++-- webapp/app/js/services/graph.js | 10 +++++++++- webapp/app/js/utils/utils.js | 20 ++++++++++++++++++++ 4 files changed, 39 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kylin/blob/da826094/webapp/app/index.html ---------------------------------------------------------------------- diff --git a/webapp/app/index.html b/webapp/app/index.html index 8fb2cb9..ad881d5 100644 --- a/webapp/app/index.html +++ b/webapp/app/index.html @@ -163,7 +163,7 @@ <!--New GUI--> <script src="js/model/modelsManager.js"></script> <script src="js/services/badQuery.js"></script> - +<script src="js/utils/utils.js"></script> <script src="js/controllers/page.js"></script> <script src="js/controllers/index.js"></script> <script src="js/controllers/access.js"></script> http://git-wip-us.apache.org/repos/asf/kylin/blob/da826094/webapp/app/js/controllers/query.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/controllers/query.js b/webapp/app/js/controllers/query.js index dede294..6be915b 100644 --- a/webapp/app/js/controllers/query.js +++ b/webapp/app/js/controllers/query.js @@ -19,7 +19,7 @@ 'use strict'; KylinApp - .controller('QueryCtrl', function ($scope, storage, $base64, $q, $location, $anchorScroll, $routeParams, QueryService, $modal, MessageService, $domUtilityService, $timeout, TableService,SweetAlert) { + .controller('QueryCtrl', function ($scope, storage, $base64, $q, $location, $anchorScroll, $routeParams, QueryService, $modal, MessageService, $domUtilityService, $timeout, TableService, SweetAlert, VdmUtil) { $scope.mainPanel = 'query'; $scope.rowsPerPage = 50000; $scope.base64 = $base64; @@ -207,7 +207,14 @@ KylinApp } else { oneQuery.result.data = data; } - + angular.forEach(oneQuery.result.data,function(row,index){ + angular.forEach(row,function(column,value){ + var float =VdmUtil.SCToFloat(column); + if (float!=""){ + oneQuery.result.data[index][value]=parseFloat(float); + } + }); + }); $scope.curQuery.result.isResponsePartial = result.partial; } http://git-wip-us.apache.org/repos/asf/kylin/blob/da826094/webapp/app/js/services/graph.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/services/graph.js b/webapp/app/js/services/graph.js index b191c50..dc69519 100644 --- a/webapp/app/js/services/graph.js +++ b/webapp/app/js/services/graph.js @@ -16,7 +16,7 @@ * limitations under the License. */ -KylinApp.service('GraphService', function (GraphBuilder) { +KylinApp.service('GraphService', function (GraphBuilder, VdmUtil) { this.buildGraph = function (query) { var graphData = null; @@ -27,6 +27,14 @@ KylinApp.service('GraphService', function (GraphBuilder) { metricsList = metricsList.concat(query.graph.state.metrics); angular.forEach(metricsList, function (metrics, index) { var aggregatedData = {}; + angular.forEach(query.result.results,function(row,index){ + angular.forEach(row,function(column,value){ + var float = VdmUtil.SCToFloat(column); + if (float!=""){ + query.result.results[index][value]=float; + } + }); + }); angular.forEach(query.result.results, function (data, index) { aggregatedData[data[dimension.index]] = (!!aggregatedData[data[dimension.index]] ? aggregatedData[data[dimension.index]] : 0) + parseFloat(data[metrics.index].replace(/[^\d\.\-]/g, "")); http://git-wip-us.apache.org/repos/asf/kylin/blob/da826094/webapp/app/js/utils/utils.js ---------------------------------------------------------------------- diff --git a/webapp/app/js/utils/utils.js b/webapp/app/js/utils/utils.js index d838e9e..d25c4e1 100644 --- a/webapp/app/js/utils/utils.js +++ b/webapp/app/js/utils/utils.js @@ -63,6 +63,26 @@ KylinApp.factory('VdmUtil', function ($modal, $timeout, $location, $anchorScroll if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); return fmt; + }, + + SCToFloat:function(data){ + var resultValue = ""; + if (data.indexOf('E') != -1){ + var regExp = new RegExp('^((\\d+.?\\d+)[Ee]{1}(\\d+))$', 'ig'); + var result = regExp.exec(data); + var power = ""; + if (result != null){ + resultValue = result[2]; + power = result[3]; + } + if (resultValue != ""){ + if (power != ""){ + var powVer = Math.pow(10, power); + resultValue = (resultValue * powVer).toFixed(2); + } + } + } + return resultValue; } } });