Add support for legend woth empty series

parent bfb83a71
......@@ -86,6 +86,13 @@ c3_chart_internal_fn.convertColumnsToData = function (columns) {
new_rows[j - 1][key] = columns[i][j];
}
}
if(!new_rows.length){
new_rows.empty = true;
new_rows[0] = {};
for (i = 0; i < columns.length; i++) {
new_rows[0][columns[i][0]] = undefined;
}
}
return new_rows;
};
c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
......
......@@ -137,9 +137,10 @@ c3_chart_internal_fn.getMaxDataCountTarget = function (targets) {
};
c3_chart_internal_fn.getEdgeX = function (targets) {
var $$ = this;
return !targets.length ? [0, 0] : [
$$.d3.min(targets, function (t) { return t.values[0].x; }),
$$.d3.max(targets, function (t) { return t.values[t.values.length - 1].x; })
var filtered = targets.filter(function(t){ return !!t.values.length; });
return !filtered.length ? [0, 0] : [
$$.d3.min(filtered, function (t) { return t.values[0].x; }),
$$.d3.max(filtered, function (t) { return t.values[t.values.length - 1].x; })
];
};
c3_chart_internal_fn.mapToIds = function (targets) {
......
......@@ -62,7 +62,10 @@ c3_chart_internal_fn.getYDomainMax = function (targets) {
};
c3_chart_internal_fn.getYDomain = function (targets, axisId, xDomain) {
var $$ = this, config = $$.config,
targetsByAxisId = targets.filter(function (t) { return $$.getAxisId(t.id) === axisId; }),
targetsByAxisId = targets.filter(function (t) {
if($$.getAxisId(t.id) !== axisId) return false;
return !!t.values.length;
}),
yTargets = xDomain ? $$.filterByXDomain(targetsByAxisId, xDomain) : targetsByAxisId,
yMin = axisId === 'y2' ? config.axis_y2_min : config.axis_y_min,
yMax = axisId === 'y2' ? config.axis_y2_max : config.axis_y_max,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment