From 14603daa221b975889381006edf31be3a1d6a87a Mon Sep 17 00:00:00 2001 From: "Dakota St. Laurent" Date: Fri, 8 Jan 2016 12:39:06 -0500 Subject: [PATCH] src/tooltip total row cleanup --- src/tooltip.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tooltip.js b/src/tooltip.js index 720c33b..696394f 100644 --- a/src/tooltip.js +++ b/src/tooltip.js @@ -76,12 +76,15 @@ c3_chart_internal_fn.getTooltipContent = function (d, defaultTitleFormat, defaul // value will be formatted the same way as the other values if (config.tooltip_total_show) { totalValue = 0; - for (i=0; i < d.length; i++) { + for (i = 0; i < d.length; i++) { + if (! (d[i] && (d[i].value || d[i].value === 0))) { continue; } totalValue += d[i].value; } totalValue = totalValueFormat(totalValue); - text += "" + totalName + ""; - text += "" + totalValue + ""; + text += ""; + text += "" + totalName + ""; + text += "" + totalValue + ""; + text += ""; } return text + ""; };