From 5c71ee7a9b4e4ab21b7ce58b0123ef02a9f8dbb9 Mon Sep 17 00:00:00 2001 From: Richard Kubina Date: Fri, 4 Mar 2016 16:40:32 -0500 Subject: [PATCH] gh-1616 Fix categorical charts with value 0 --- src/data.convert.js | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/data.convert.js b/src/data.convert.js index 497954f..e6b1d6c 100644 --- a/src/data.convert.js +++ b/src/data.convert.js @@ -166,17 +166,9 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) { var xKey = $$.getXKey(id), rawX = d[xKey], value = d[id] !== null && !isNaN(d[id]) ? +d[id] : null, x; // use x as categories if custom x and categorized - if ($$.isCustomX() && $$.isCategorized() && rawX) { - if (index === 0 && i === 0) { - config.axis_x_categories = []; - } - x = config.axis_x_categories.indexOf(rawX); - if (x === -1) { - x = config.axis_x_categories.length; - config.axis_x_categories.push(rawX); - } - } else { - x = $$.generateTargetX(rawX, id, i); + if ($$.isCustomX() && $$.isCategorized() && index === 0 && !isUndefined(rawX)) { + if (i === 0) { config.axis_x_categories = []; } + config.axis_x_categories.push(rawX); } // mark as x = undefined if value is undefined and filter to remove after mapped if (isUndefined(d[id]) || $$.data.xs[id].length <= i) {