8000 [DO NOT MERGE] Animations by rreusser · Pull Request #550 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

[DO NOT MERGE] Animations #550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
54bf57c
First cut at animations
rreusser May 18, 2016
c3517c2
Slightly ugly hack to animate point styles
rreusser May 31, 2016
dba188b
Merge remote-tracking branch 'upstream/master' into animations
rreusser Jun 2, 2016
2eae93a
Remove stray markTime
rreusser Jun 2, 2016
e9bcf90
A method to clone input traces
rreusser Jun 2, 2016
5497e7d
Make animations promise-based
rreusser Jun 8, 2016
c159dae
Non-working commit in the right direction...
rreusser Jun 8, 2016
1449cc5
Partial trace refactor
rreusser Jun 9, 2016
99b4bed
Scattertrace element persistence cleanup
rreusser Jun 10, 2016
7285a0a
Further animation progress and cleanup
rreusser Jun 11, 2016
8dc302c
Scatter trace optimization
rreusser Jun 12, 2016
5a624de
Scatter trace optimization
rreusser Jun 12, 2016
d580df3
Merge branch 'animations' of github.com:rreusser/plotly.js into anima…
rreusser Jun 13, 2016
81e2182
Refactor scatter traces
rreusser Jun 14, 2016
82071e3
Refactor scatter traces
rreusser Jun 14, 2016
710de7f
Merge branch 'animations' of github.com:rreusser/plotly.js into anima…
rreusser Jun 14, 2016
48e9b29
Merge remote-tracking branch 'upstream/master' into animations
rreusser Jun 14, 2016
aa19ac0
Add build
rreusser Jun 14, 2016
821c57e
Object persistence for error bars
rreusser Jun 16, 2016
a655a4b
Error bar transitions
rreusser Jun 17, 2016
c978b46
First cut at scale transitions
rreusser Jun 20, 2016
51672d8
Undo build
rreusser Jun 20, 2016
31f4f1b
Merge remote-tracking branch 'upstream/master' into animations
rreusser Jun 20, 2016
5c5c715
Animation interrupts
rreusser Jun 20, 2016
b75280f
Remove linepoint override
rreusser Jun 21, 2016
990787e
Removed unused logic
rreusser Jun 21, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8000
Prev Previous commit
Next Next commit
Refactor scatter traces
  • Loading branch information
rreusser committed Jun 14, 2016
commit 82071e371876c6db03985b66b537d1463a831d59
9 changes: 4 additions & 5 deletions src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ drawing.setRect = function(s, x, y, w, h) {
s.call(drawing.setPosition, x, y).call(drawing.setSize, w, h);
};

drawing.translatePoints = function(s, xa, ya, transitionConfig, trace) {
drawing.translatePoints = function(s, xa, ya, trace, transitionConfig, joinDirection) {

var hasTransition = transitionConfig && (transitionConfig || {}).duration > 0;


if (hasTransition) {
var size = s.size();
}
Expand All @@ -67,7 +66,7 @@ drawing.translatePoints = function(s, xa, ya, transitionConfig, trace) {
} else {
if (hasTransition) {
var trans;
if (!transitionConfig.direction) {
if (!joinDirection) {
trans = p.transition()
.delay(transitionConfig.delay + transitionConfig.cascade / size * i)
.duration(transitionConfig.duration)
Expand All @@ -77,14 +76,14 @@ drawing.translatePoints = function(s, xa, ya, transitionConfig, trace) {
if (trace) {
trans.call(drawing.pointStyle, trace)
}
} else if (transitionConfig.direction === -1) {
} else if (joinDirection === -1) {
trans = p.style('opacity', 1)
.transition()
.duration(transitionConfig.duration)
.ease(transitionConfig.easing)
.style('opacity', 0)
.remove();
} else if (transitionConfig.direction === 1) {
} else if (joinDirection === 1) {
trans = p.attr('transform', 'translate('+x+','+y+')')

if (trace) {
Expand Down
30 changes: 7 additions & 23 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ Plotly.animate = function animate (gd, newData, transitionOpts, traces) {
var trace = gd._fullData[traceIdx];
var module = trace._module;

if (!module.animate) {
if (!module.animatable) {
continue;
}

Expand Down Expand Up @@ -1599,11 +1599,9 @@ Plotly.animate = function animate (gd, newData, transitionOpts, traces) {
var subplotInfo, _module;

for(var i = 0; i < subplots.length; i++) {
console.log('i:', i);
subplotInfo = fullLayout._plots[subplots[i]];

for(var j = 0; j < modules.length; j++) {
console.log('j:', j);
_module = modules[j];
if(_module.setPositions) _module.setPositions(gd, subplotInfo);
}
Expand All @@ -1612,28 +1610,22 @@ Plotly.animate = function animate (gd, newData, transitionOpts, traces) {

doSetPositions();

var animateList = [];
var restyleList = [];


function doAnimations () {
var a, i, j;
for (i = 0; i < animateList.length; i++) {
a = animateList[i];
var basePlotModules = fullLayout._basePlotModules;
for(j = 0; j < basePlotModules.length; j++) {
basePlotModules[j].plot(gd, transitionOpts);
}
var basePlotModules = fullLayout._basePlotModules;
for(j = 0; j < basePlotModules.length; j++) {
basePlotModules[j].plot(gd, animatedTraces, transitionOpts);
}

if (!transitionOpts.leadingEdgeRestyle) {
return new Promise(function(resolve, reject) {
setTimeout(resolve, transitionOpts.duration);
});
}
}

for (var i = 0; i < animatedTraces.length; i++) {
/*for (var i = 0; i < animatedTraces.length; i++) {
var trace = gd._fullData[animatedTraces[i]];
var module = trace._module;
var cd = [];
Expand All @@ -1655,22 +1647,14 @@ Plotly.animate = function animate (gd, newData, transitionOpts, traces) {
cd[0].trace = trace;

gd.calcdata[traces[i]] = cd;
}
}*/

for (i = 0; i < traces.length; i++) {
var traceIdx = traces[i];

var cont = gd.data[traceIdx];
var contFull = gd._fullData[traceIdx];
var module = contFull._module;

if (module.animate) {
animateList.push({
module: module,
contFull: contFull,
newData: newData[i]
});
} else {
if (!module.animatable) {
var thisTrace = [traceIdx];
var thisUpdate = {};

Expand Down
38 changes: 14 additions & 24 deletions src/plots/cartesian/index.js
6D40
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ exports.attrRegex = constants.attrRegex;

exports.attributes = require('./attributes');

exports.plot = function(gd, transitionOpts) {
exports.plot = function(gd, traces, transitionOpts) {
var fullLayout = gd._fullLayout,
subplots = Plots.getSubplotIds(fullLayout, 'cartesian'),
calcdata = gd.calcdata,
Expand All @@ -40,6 +40,9 @@ exports.plot = function(gd, transitionOpts) {
var cd = calcdata[i];
var trace = cd[0].trace;

// Skip trace if whitelist provided and it's not whitelisted:
// if (Array.isArray(traces) && traces.indexOf(i) === -1) continue;

if(trace.xaxis + trace.yaxis === subplot) {
cdSubplot.push(cd);
}
Expand All @@ -63,15 +66,20 @@ exports.plot = function(gd, transitionOpts) {
return cdModule;
}

function keyFunc (d) {
return d[0].trace.uid;
}

for(var i = 0; i < subplots.length; i++) {
var subplot = subplots[i],
subplotInfo = fullLayout._plots[subplot],
cdSubplot = getCdSubplot(calcdata, subplot);

// remove old traces, then redraw everything
// TODO: scatterlayer is manually excluded from this since it knows how
// to update instead of fully removing and redrawing every time. The
// remaining plot traces should also be able to do this. Once implemented,
// we won't need this - which should sometimes be a big speedup.
if(subplotInfo.plot) {
subplotInfo.plot.selectAll('g:not(.scatterlayer)').selectAll('g.trace').remove();
}

for(var j = 0; j < modules.length; j++) {
var _module = modules[j];

Expand All @@ -81,25 +89,7 @@ exports.plot = function(gd, transitionOpts) {
// plot all traces of this type on this subplot at once
var cdModule = getCdModule(cdSubplot, _module);

var tracelayer = subplotInfo.plot.select('g.' + _module.name + 'layer');
var subplotJoin = tracelayer.selectAll('g.trace').data(cdModule, keyFunc);

subplotJoin.enter()
.append('g')
.classed('trace', true)
.classed(_module.name, true)
.each(function(d) {
d[0].trace._module.plot(gd, subplotInfo, d, this)
});

subplotJoin.transition()
.each(function(d) {
d[0].trace._module.plot(gd, subplotInfo, d, this, transitionOpts)
});


subplotJoin.exit()
.remove()
_module.plot(gd, subplotInfo, cdModule, traces, transitionOpts);
}
}
};
Loading
0