diff --git a/src/data.js b/src/data.js index b0c3cbc..12f1b05 100644 --- a/src/data.js +++ b/src/data.js @@ -53,7 +53,7 @@ c3_chart_internal_fn.addName = function (data) { var $$ = this, name; if (data) { name = $$.config.data_names[data.id]; - data.name = name ? name : data.id; + data.name = name !== undefined ? name : data.id; } return data; }; diff --git a/src/legend.js b/src/legend.js index 2e0508e..bf52fb3 100644 --- a/src/legend.js +++ b/src/legend.js @@ -119,6 +119,9 @@ c3_chart_internal_fn.updateLegend = function (targetIds, options, transitions) { var withTransition, withTransitionForTransform; var texts, rects, tiles, background; + // Skip elements when their name is set to null + targetIds = targetIds.filter(function(id) {return !isDefined(config.data_names[id]) || config.data_names[id] !== null;}); + options = options || {}; withTransition = getOption(options, "withTransition", true); withTransitionForTransform = getOption(options, "withTransitionForTransform", true); diff --git a/src/tooltip.js b/src/tooltip.js index 75d1416..1ac1a62 100644 --- a/src/tooltip.js +++ b/src/tooltip.js @@ -40,6 +40,8 @@ c3_chart_internal_fn.getTooltipContent = function (d, defaultTitleFormat, defaul value = valueFormat(d[i].value, d[i].ratio, d[i].id, d[i].index); if (value !== undefined) { + // Skip elements when their name is set to null + if (d[i].name === null) { continue; } name = nameFormat(d[i].name, d[i].ratio, d[i].id, d[i].index); bgcolor = $$.levelColor ? $$.levelColor(d[i].value) : color(d[i].id);