Browse Source

Lightweight fix for unexpected category behavior when multiple series are used.

Fixes #1643
pull/1650/head
Richard Lindner 9 years ago
parent
commit
305ed6dc76
  1. 16
      src/data.convert.js

16
src/data.convert.js

@ -146,13 +146,21 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
id: convertedId, id: convertedId,
id_org: id, id_org: id,
values: data.map(function (d, i) { values: data.map(function (d, i) {
var xKey = $$.getXKey(id), rawX = d[xKey], x = $$.generateTargetX(rawX, id, i), var xKey = $$.getXKey(id), rawX = d[xKey],
value = d[id] !== null && !isNaN(d[id]) ? +d[id] : null; value = d[id] !== null && !isNaN(d[id]) ? +d[id] : null, x;
// use x as categories if custom x and categorized // use x as categories if custom x and categorized
if ($$.isCustomX() && $$.isCategorized() && index === 0 && rawX) { if ($$.isCustomX() && $$.isCategorized() && rawX) {
if (i === 0) { config.axis_x_categories = []; } 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); config.axis_x_categories.push(rawX);
} }
} else {
x = $$.generateTargetX(rawX, id, i);
}
// mark as x = undefined if value is undefined and filter to remove after mapped // mark as x = undefined if value is undefined and filter to remove after mapped
if (isUndefined(d[id]) || $$.data.xs[id].length <= i) { if (isUndefined(d[id]) || $$.data.xs[id].length <= i) {
x = undefined; x = undefined;

Loading…
Cancel
Save