Add support for negative values for stacked-100

parent 1a9b8452
......@@ -381,8 +381,10 @@ c3_chart_internal_fn.tuneAxis = function(sync, callback){
// if we don't need to tune
if($$.config.normalized){
$$.data.targets = $$.normalize($$.data._targets);
$$.cachedRedraw();
return;
if($$.data.targets.noNegative){
$$.cachedRedraw();
return;
}
}
var apply = function(){
......
......@@ -6,6 +6,8 @@ c3.chart.internal.fn.normalize = function(targets){
}
var data = [];
data.noNegative = true;
targets.forEach(function(target){
data.push($$.cloneTarget(target));
......@@ -14,7 +16,12 @@ c3.chart.internal.fn.normalize = function(targets){
for(var k = 0; k < targets[0].values.length; k++) {
var tt = 0;
for(c in targets) {
tt = tt + targets[c].values[k].value;
if(targets[c].values[k]){
if(targets[c].values[k].value < 0){
data.noNegative = false;
}
tt = tt + Math.abs(targets[c].values[k].value);
}
}
tr[k] = tt;
}
......
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