Skip to content

Commit

Permalink
Fix get max level
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaeverywhere committed Nov 22, 2017
1 parent e8e84dd commit 65386b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "LightPivotTable",
"author": "ZitRo",
"version": "1.8.7",
"version": "1.8.8",
"description": "A lightweight pivot table for MDX2JSON source for InterSystems Cache",
"main": "test/testServer.js",
"repository": {
Expand Down
28 changes: 22 additions & 6 deletions source/js/DataController.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,14 +443,30 @@ DataController.prototype.resetRawData = function () {
}
};

var getMaxLevel = function (c) {
var lev = 0;
for (var i in c) {
if (c[i].children && c[i].children.length) {
lev = Math.max(lev, getMaxLevel(c[i].children));
var getMaxLevel = function (children, level) {

if (typeof level === "undefined")
level = 0;

function maxLevel (node, level) {
if (node.children) {
var max = 0;
for (var i in node.children) {
max = Math.max(max, maxLevel(node.children[i], level + 1));
}
return max;
} else {
if (node["type"] === "msr" && MEASURES_HIDDEN)
return level - 1;
return level;
}
}
return lev + 1;

return children.reduce(
function (acc, node) { return Math.max(acc, maxLevel(node, 1)) },
level
);

};

var dim1raw = function (a, c, arr, hor, level, maxLevel) {
Expand Down

0 comments on commit 65386b5

Please sign in to comment.