Created
February 4, 2015 21:38
-
-
Save stormpython/eea71583ee877dc69bad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pulling values recursively from Pie Chart Data | |
function getSize (obj) { | |
return obj.size; | |
} | |
function isZero (d) { | |
return d.size === 0; | |
} | |
function pushValToArray (arr, obj) { | |
return arr.push(getSize(obj)); | |
} | |
function something (dataArr, emptyArr) { | |
dataArr.forEach(function (obj) { | |
if (obj.children) { | |
something(obj.children, emptyArr); | |
} | |
return pushValToArray(emptyArr, obj); | |
}); | |
} | |
function checkForAllZeros (arr) { | |
var valsArr = []; | |
something(arr, valsArr); | |
return valsArr.every(isZero); | |
} | |
function main () { | |
var arr = this.chartData.slices.children; | |
var isAllZeros = checkForAllZeros(arr); | |
if (!isAllZeros) { return; } | |
throw new errors.AllZeros(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment