diff --git a/lib/index.js b/lib/index.js index 7cdbe0b..74650a7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1175,15 +1175,15 @@ GitStats.prototype.authors = function (options, callback) { */ GitStats.prototype.authorsPie = function (options, callback) { - const radius = Math.round(process.stdout.rows / 2) || 20; - if (typeof options === "string") { options = { repo: options }; } - options = Ul.merge(options, { radius }); + options = Ul.merge(options, { + radius: process.stdout.rows / 2 || 20 + }); if (!IsThere(options.repo)) { return callback(new Error("The repository folder doesn't exist.")); @@ -1196,15 +1196,16 @@ GitStats.prototype.authorsPie = function (options, callback) { ; self.authors(options, function (err, authors) { + const maxAuthors = 2 * options.radius; if (err) { return callback(err); } - if (authors.length > radius) { + if (authors.length > maxAuthors) { var others = { - value: authors.slice(radius).reduce(function (a, b) { + value: authors.slice(maxAuthors).reduce(function (a, b) { return a + b.value; }, 0) , label: "Others" }; - authors = authors.slice(0, radius); + authors = authors.slice(0, maxAuthors); authors.push(others); }