Skip to content

Commit 6e9def2

Browse files
committed
lastValue: defaults to current value to fix first animation
1 parent 1e7f21d commit 6e9def2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/traces/indicator/calc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ function calc(gd, trace) {
1414
var cd = [];
1515

1616
var lastReading = trace.value;
17-
var secondLastReading = trace._lastValue || trace.value;
17+
if(!(typeof trace._lastValue === 'number')) trace._lastValue = trace.value;
18+
var secondLastReading = trace._lastValue;
1819
var deltaRef = secondLastReading;
1920
if(trace._hasDelta && typeof trace.delta.reference === 'number') {
2021
deltaRef = trace.delta.reference;

src/traces/indicator/plot.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,10 @@ function drawAngularGauge(gd, plotGroup, cd, gaugeOpts) {
478478
.transition()
479479
.duration(transitionOpts.duration)
480480
.ease(transitionOpts.easing)
481-
.each('end', function() { trace._lastValue = cd[0].y; onComplete && onComplete(); })
481+
.each('end', function() { onComplete && onComplete(); })
482482
.each('interrupt', function() { onComplete && onComplete(); })
483483
.attrTween('d', arcTween(valueArcPathGenerator, valueToAngle(cd[0].lastY), valueToAngle(cd[0].y)));
484+
trace._lastValue = cd[0].y;
484485
} else {
485486
valueArcPath
486487
.attr('d', valueArcPathGenerator.endAngle(valueToAngle(cd[0].y)));

0 commit comments

Comments
 (0)