Commit 69b79fc1 authored by Evgeny's avatar Evgeny

Make pie values absolute. Now -100 and 100 are treated the same way. Fix issue CHRT-208

parent a0057237
all:
all:
grunt
test:
......
......@@ -5333,6 +5333,9 @@
c3_chart_internal_fn.updateArc = function () {
var $$ = this;
$$.makeTargetsValuesAbsolute($$.data.targets);
$$.svgArc = $$.getSvgArc();
$$.svgArcExpanded = $$.getSvgArcExpanded();
$$.svgArcExpandedSub = $$.getSvgArcExpanded(0.98);
......@@ -5342,14 +5345,17 @@
var $$ = this, config = $$.config,
found = false, index = 0,
gMin = config.gauge_min, gMax = config.gauge_max, gTic, gValue;
$$.pie($$.filterTargetsToShow($$.data.targets)).forEach(function (t) {
if (! found && t.data.id === d.data.id) {
found = true;
d = t;
d.index = index;
}
index++;
});
if (isNaN(d.endAngle)) {
d.endAngle = d.startAngle;
}
......@@ -5530,6 +5536,7 @@
classChartArc = $$.classChartArc.bind($$),
classArcs = $$.classArcs.bind($$),
classFocus = $$.classFocus.bind($$);
mainPieUpdate = main.select('.' + CLASS.chartArcs).selectAll('.' + CLASS.chartArc)
.data($$.pie(targets))
.attr("class", function (d) { return classChartArc(d) + classFocus(d.data); });
......@@ -5588,6 +5595,7 @@
interpolate = d3.interpolate(this._current, updated);
this._current = interpolate(0);
var interpolated = interpolate(1);
interpolated.data = d.data; // data.id will be updated by interporator
return $$.getArc(interpolated, true);
})
......@@ -5596,6 +5604,7 @@
return $$.levelColor ? $$.levelColor(d.data.values[0].value) : $$.color(d.data.id);
}) // Where gauge reading color would receive customization.
.style("opacity", 1);
mainArc.exit().transition().duration(durationForExit)
.style('opacity', 0)
.remove();
......@@ -6666,6 +6675,13 @@
},
isNode = function(){
return typeof process === 'object';
},
makeTargetsValuesAbsolute = c3_chart_internal_fn.makeTargetsValuesAbsolute = function(targets){
targets.forEach(function(target){
target.values.forEach(function(value){
value.value = Math.abs(value.value);
});
});
};
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -21,6 +21,9 @@ c3_chart_internal_fn.updateRadius = function () {
c3_chart_internal_fn.updateArc = function () {
var $$ = this;
$$.makeTargetsValuesAbsolute($$.data.targets);
$$.svgArc = $$.getSvgArc();
$$.svgArcExpanded = $$.getSvgArcExpanded();
$$.svgArcExpandedSub = $$.getSvgArcExpanded(0.98);
......@@ -30,14 +33,17 @@ c3_chart_internal_fn.updateAngle = function (d) {
var $$ = this, config = $$.config,
found = false, index = 0,
gMin = config.gauge_min, gMax = config.gauge_max, gTic, gValue;
$$.pie($$.filterTargetsToShow($$.data.targets)).forEach(function (t) {
if (! found && t.data.id === d.data.id) {
found = true;
d = t;
d.index = index;
}
index++;
});
if (isNaN(d.endAngle)) {
d.endAngle = d.startAngle;
}
......@@ -218,6 +224,7 @@ c3_chart_internal_fn.updateTargetsForArc = function (targets) {
classChartArc = $$.classChartArc.bind($$),
classArcs = $$.classArcs.bind($$),
classFocus = $$.classFocus.bind($$);
mainPieUpdate = main.select('.' + CLASS.chartArcs).selectAll('.' + CLASS.chartArc)
.data($$.pie(targets))
.attr("class", function (d) { return classChartArc(d) + classFocus(d.data); });
......@@ -276,6 +283,7 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf
interpolate = d3.interpolate(this._current, updated);
this._current = interpolate(0);
var interpolated = interpolate(1);
interpolated.data = d.data; // data.id will be updated by interporator
return $$.getArc(interpolated, true);
})
......@@ -284,6 +292,7 @@ c3_chart_internal_fn.redrawArc = function (duration, durationForExit, withTransf
return $$.levelColor ? $$.levelColor(d.data.values[0].value) : $$.color(d.data.id);
}) // Where gauge reading color would receive customization.
.style("opacity", 1);
mainArc.exit().transition().duration(durationForExit)
.style('opacity', 0)
.remove();
......
......@@ -113,5 +113,12 @@ var isValue = c3_chart_internal_fn.isValue = function (v) {
},
isNode = function(){
return typeof process === 'object';
},
makeTargetsValuesAbsolute = c3_chart_internal_fn.makeTargetsValuesAbsolute = function(targets){
targets.forEach(function(target){
target.values.forEach(function(value){
value.value = Math.abs(value.value);
});
});
};
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