|
|
|
@ -96,8 +96,12 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
|
|
|
|
|
var $$ = this, config = $$.config, |
|
|
|
|
ids = $$.d3.keys(data[0]).filter($$.isNotX, $$), |
|
|
|
|
xs = $$.d3.keys(data[0]).filter($$.isX, $$), |
|
|
|
|
zeroUnderYAxis = true, |
|
|
|
|
allZero = true, |
|
|
|
|
targets; |
|
|
|
|
|
|
|
|
|
$$.allDataIsNegative = true; |
|
|
|
|
|
|
|
|
|
// save x for update data by load when custom x and c3.x API
|
|
|
|
|
ids.forEach(function (id) { |
|
|
|
|
var xKey = $$.getXKey(id); |
|
|
|
@ -140,7 +144,9 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
|
|
|
|
|
id: convertedId, |
|
|
|
|
id_org: id, |
|
|
|
|
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], |
|
|
|
|
x = $$.generateTargetX(rawX, id, i), |
|
|
|
|
value = d[id] !== null && !isNaN(d[id]) ? +d[id] : null; |
|
|
|
|
// use x as categories if custom x and categorized
|
|
|
|
|
if ($$.isCustomX() && $$.isCategorized() && index === 0 && rawX) { |
|
|
|
|
if (i === 0) { config.axis_x_categories = []; } |
|
|
|
@ -150,7 +156,16 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
|
|
|
|
|
if (isUndefined(d[id]) || $$.data.xs[id].length <= i) { |
|
|
|
|
x = undefined; |
|
|
|
|
} |
|
|
|
|
return {x: x, value: d[id] !== null && !isNaN(d[id]) ? +d[id] : null, id: convertedId}; |
|
|
|
|
|
|
|
|
|
if(value !== null && value !== 0) { |
|
|
|
|
allZero = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(value > 0) { |
|
|
|
|
zeroUnderYAxis = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return {x: x, value: value, id: convertedId}; |
|
|
|
|
}).filter(function (v) { return isDefined(v.x); }) |
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
@ -177,6 +192,12 @@ c3_chart_internal_fn.convertDataToTargets = function (data, appendXs) {
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if(allZero) { |
|
|
|
|
zeroUnderYAxis = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$$.zeroUnderYAxis = zeroUnderYAxis; |
|
|
|
|
|
|
|
|
|
// set target types
|
|
|
|
|
if (config.data_type) { |
|
|
|
|
$$.setTargetType($$.mapToIds(targets).filter(function (id) { return ! (id in config.data_types); }), config.data_type); |
|
|
|
|