Skip to content

Commit 627c8e1

Browse files
committed
Opt for the other way of passing frame names while queueing
1 parent d639e19 commit 627c8e1

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

src/plot_api/plot_api.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2203,7 +2203,7 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
22032203

22042204
if(frameList[i].type === 'byname') {
22052205
// If it's a named frame, compute it:
2206-
computedFrame = Plots.computeFrame(gd, frameList[i].data.name);
2206+
computedFrame = Plots.computeFrame(gd, frameList[i].name);
22072207
} else {
22082208
// Otherwise we must have been given a simple object, so treat
22092209
// the input itself as the computed frame.
@@ -2219,7 +2219,7 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
22192219

22202220
var nextFrame = {
22212221
frame: computedFrame,
2222-
name: computedFrame.name,
2222+
name: frameList[i].name,
22232223
frameOpts: frameOpts,
22242224
transitionOpts: transitionOpts,
22252225
};
@@ -2365,6 +2365,7 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
23652365
if(allFrames || frame.group === frameOrGroupNameOrFrameList) {
23662366
frameList.push({
23672367
type: 'byname',
2368+
name: frame.name,
23682369
data: setTransitionConfig({name: frame.name})
23692370
});
23702371
}
@@ -2376,6 +2377,7 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
23762377
// In this case, there's an array and this frame is a string name:
23772378
frameList.push({
23782379
type: 'byname',
2380+
name: frameOrName,
23792381
data: setTransitionConfig({name: frameOrName})
23802382
});
23812383
} else {

src/plots/plots.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ plots.computeFrame = function(gd, frameName) {
12861286
}
12871287

12881288
// A new object for the merged result:
1289-
var result = {name: frameName};
1289+
var result = {};
12901290

12911291
// Merge, starting with the last and ending with the desired frame:
12921292
while((framePtr = frameStack.pop())) {

test/jasmine/tests/animate_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ describe('Test animate API', function() {
420420
transition: {duration: 1},
421421
frame: {duration: 1}
422422
}).then(function() {
423-
expect(frames).toEqual(['frame0', 'frame1', 'test', undefined]);
423+
expect(frames).toEqual(['frame0', 'frame1', undefined, undefined]);
424424
}).catch(fail).then(done);
425425

426426
});

test/jasmine/tests/compute_frame_test.js

+4-9
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ describe('Test mergeFrames', function() {
6161

6262
it('computes a single frame', function() {
6363
var computed = computeFrame(gd, 'frame1');
64-
var expected = {name: 'frame1', data: [{x: [1, 2, 3], marker: {size: 8, color: 'red'}}], traces: [0]};
64+
var expected = {data: [{x: [1, 2, 3], marker: {size: 8, color: 'red'}}], traces: [0]};
6565
expect(computed).toEqual(expected);
6666
});
6767

@@ -82,9 +82,9 @@ describe('Test mergeFrames', function() {
8282
];
8383

8484
results = [
85-
{name: 'frame0', traces: [0], data: [{marker: {size: 0}}]},
86-
{name: 'frame1', traces: [0], data: [{marker: {size: 1}}]},
87-
{name: 'frame2', traces: [0], data: [{marker: {size: 2}}]}
85+
{traces: [0], data: [{marker: {size: 0}}]},
86+
{traces: [0], data: [{marker: {size: 1}}]},
87+
{traces: [0], data: [{marker: {size: 2}}]}
8888
];
8989

9090
Plotly.addFrames(gd, frames).then(done);
@@ -140,7 +140,6 @@ describe('Test mergeFrames', function() {
140140
Plotly.addFrames(gd, frames.map(clone));
141141

142142
expect(computeFrame(gd, 'frame0')).toEqual({
143-
name: 'frame0',
144143
traces: [8, 2],
145144
data: [
146145
{marker: {size: 1}},
@@ -159,7 +158,6 @@ describe('Test mergeFrames', function() {
159158
Plotly.addFrames(gd, frames.map(clone));
160159

161160
expect(computeFrame(gd, 'frame0')).toEqual({
162-
name: 'frame0',
163161
traces: [2],
164162
data: [{marker: {size: 0}}]
165163
});
@@ -175,7 +173,6 @@ describe('Test mergeFrames', function() {
175173
Plotly.addFrames(gd, frames.map(clone));
176174

177175
expect(computeFrame(gd, 'frame0')).toEqual({
178-
name: 'frame0',
179176
traces: [2, 8],
180177
data: [
181178
{marker: {size: 0}},
@@ -192,7 +189,6 @@ describe('Test mergeFrames', function() {
192189
Plotly.addFrames(gd, frames.map(clone));
193190

194191
expect(computeFrame(gd, 'frame4')).toEqual({
195-
name: 'frame4',
196192
traces: [2, 8, 0, 1],
197193
data: [
198194
{marker: {size: 7}},
@@ -228,7 +224,6 @@ describe('Test mergeFrames', function() {
228224
var result = computeFrame(gd, 'frame0');
229225

230226
expect(result).toEqual({
231-
name: 'frame0',
232227
layout: {margin: {l: 40}}
233228
});
234229
});

0 commit comments

Comments
 (0)