diff --git a/lib/core.js b/lib/core.js index ea64d05..40416c8 100644 --- a/lib/core.js +++ b/lib/core.js @@ -80,16 +80,12 @@ module.exports = { this.chart.ctx.font = fontSize + "em 'Open Sans'" this.chart.ctx.textBaseline = 'middle' - var total = 0 - var filled = 0 + var total = this.total var clone = this.segments.slice() - clone.map(function (val) { - total = total + val.value - }) clone.pop() - clone.map(function (val) { - filled = filled + val.value - }) + var filled = clone.reduce(function (a, val) { + return a + val.value + }, 0) var text = Math.round(total > 0 ? (100 / total) * filled : 0) + '%' var textX = Math.round((width - this.chart.ctx.measureText(text).width) / 2),