Skip to content

Commit 7bb508e

Browse files
committed
ZEPPELIN-830 fix number formatting for table display
1 parent 4e6beb8 commit 7bb508e

File tree

2 files changed

+15
-33
lines changed

2 files changed

+15
-33
lines changed

zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1212,38 +1212,6 @@ angular.module('zeppelinWebApp')
12121212
};
12131213

12141214
var setTable = function(type, data, refresh) {
1215-
var getTableContentFormat = function(d) {
1216-
if (isNaN(d)) {
1217-
if (d.length>'%html'.length && '%html ' === d.substring(0, '%html '.length)) {
1218-
return 'html';
1219-
} else {
1220-
return '';
1221-
}
1222-
} else {
1223-
return '';
1224-
}
1225-
};
1226-
1227-
var formatTableContent = function(d) {
1228-
if (isNaN(d)) {
1229-
var f = getTableContentFormat(d);
1230-
if (f !== '') {
1231-
return d.substring(f.length+2);
1232-
} else {
1233-
return d;
1234-
}
1235-
} else {
1236-
var dStr = d.toString();
1237-
var splitted = dStr.split('.');
1238-
var formatted = splitted[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
1239-
if (splitted.length>1) {
1240-
formatted+= '.'+splitted[1];
1241-
}
1242-
return formatted;
1243-
}
1244-
};
1245-
1246-
12471215
var renderTable = function() {
12481216
var height = $scope.paragraph.config.graph.height;
12491217
angular.element('#p' + $scope.paragraph.id + '_table').css('height', height);
@@ -1263,7 +1231,20 @@ angular.module('zeppelinWebApp')
12631231
manualRowResize: true,
12641232
editor: false,
12651233
fillHandle: false,
1266-
disableVisualSelection: true
1234+
disableVisualSelection: true,
1235+
cells: function (row, col, prop) {
1236+
var cellProperties = {};
1237+
cellProperties.renderer = function(instance, td, row, col, prop, value, cellProperties) {
1238+
Handsontable.NumericCell.renderer.apply(this, arguments);
1239+
if (!isNaN(value)) {
1240+
cellProperties.type = 'numeric';
1241+
cellProperties.format = '0,0';
1242+
cellProperties.editor = false;
1243+
td.style.textAlign="left"
1244+
}
1245+
};
1246+
return cellProperties;
1247+
}
12671248
});
12681249
};
12691250

zeppelin-web/src/app/notebook/paragraph/paragraph.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@
400400
border-top: 0px;
401401
padding: 4px 0px 0px 0px;
402402
border-left: 0px;
403+
border-right: 0px;
403404
border-bottom: 2px solid #CCC;
404405
}
405406

0 commit comments

Comments
 (0)