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