Skip to content

Commit 4e6c350

Browse files
committed
Animate scatter trace opacity
1 parent 0620416 commit 4e6c350

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/traces/scatter/plot.js

+2
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition
169169

170170
if(trace.visible !== true) return;
171171

172+
transition(tr).style('opacity', trace.opacity);
173+
172174
// BUILD LINES AND FILLS
173175
var ownFillEl3, tonext;
174176
var ownFillDir = trace.fill.charAt(trace.fill.length - 1);

test/jasmine/tests/animate_test.js

+32
Original file line numberDiff line numberDiff line change
@@ -737,3 +737,35 @@ describe('non-animatable fallback', function() {
737737

738738
});
739739
});
740+
741+
describe('animating scatter traces', function() {
742+
'use strict';
743+
var gd;
744+
745+
beforeEach(function() {
746+
gd = createGraphDiv();
747+
});
748+
749+
afterEach(function() {
750+
Plotly.purge(gd);
751+
destroyGraphDiv();
752+
});
753+
754+
it('animates trace opacity', function(done) {
755+
var trace;
756+
Plotly.plot(gd, [{
757+
x: [1, 2, 3],
758+
y: [4, 5, 6],
759+
opacity: 1
760+
}]).then(function() {
761+
trace = Plotly.d3.selectAll('g.scatter.trace');
762+
expect(trace.style('opacity')).toEqual('1');
763+
764+
return Plotly.animate(gd, [{
765+
data: [{opacity: 0.1}]
766+
}], {transition: {duration: 0}, frame: {duration: 0, redraw: false}});
767+
}).then(function() {
768+
expect(trace.style('opacity')).toEqual('0.1');
769+
}).catch(fail).then(done);
770+
});
771+
});

0 commit comments

Comments
 (0)