Browse Source

Refactor #1305

pull/1414/merge
Masayuki Tanaka 9 years ago
parent
commit
e3ebb7f28c
  1. 9
      c3.js
  2. 2
      c3.min.js
  3. 13
      src/arc.js

9
c3.js

@ -4784,7 +4784,12 @@
c3_chart_internal_fn.updateAngle = function (d) { 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, gMax, gTic, gValue;
if (!config) {
return null;
}
$$.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;
@ -4800,6 +4805,8 @@
d.endAngle = d.startAngle; d.endAngle = d.startAngle;
} }
if ($$.isGaugeType(d.data)) { if ($$.isGaugeType(d.data)) {
gMin = config.gauge_min;
gMax = config.gauge_max;
gTic = (Math.PI) / (gMax - gMin); gTic = (Math.PI) / (gMax - gMin);
gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : (gMax - gMin); gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : (gMax - gMin);
d.startAngle = -1 * (Math.PI / 2); d.startAngle = -1 * (Math.PI / 2);

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

13
src/arc.js

@ -26,9 +26,13 @@ c3_chart_internal_fn.updateArc = function () {
c3_chart_internal_fn.updateAngle = function (d) { c3_chart_internal_fn.updateAngle = function (d) {
var $$ = this, config = $$.config, var $$ = this, config = $$.config,
found = false, index = 0; found = false, index = 0,
if (config) { gMin, gMax, gTic, gValue;
var gMin = config.gauge_min, gMax = config.gauge_max, gTic, gValue;
if (!config) {
return null;
}
$$.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;
@ -44,12 +48,13 @@ c3_chart_internal_fn.updateAngle = function (d) {
d.endAngle = d.startAngle; d.endAngle = d.startAngle;
} }
if ($$.isGaugeType(d.data)) { if ($$.isGaugeType(d.data)) {
gMin = config.gauge_min;
gMax = config.gauge_max;
gTic = (Math.PI) / (gMax - gMin); gTic = (Math.PI) / (gMax - gMin);
gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : (gMax - gMin); gValue = d.value < gMin ? 0 : d.value < gMax ? d.value - gMin : (gMax - gMin);
d.startAngle = -1 * (Math.PI / 2); d.startAngle = -1 * (Math.PI / 2);
d.endAngle = d.startAngle + gTic * gValue; d.endAngle = d.startAngle + gTic * gValue;
} }
}
return found ? d : null; return found ? d : null;
}; };

Loading…
Cancel
Save