Skip to content

Commit 0d61fcc

Browse files
committed
Merge branch 'master' into dates-as-dates
2 parents 7679483 + c750179 commit 0d61fcc

File tree

12 files changed

+119
-53
lines changed

12 files changed

+119
-53
lines changed

circle.yml

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies:
1717
- npm run cibuild
1818
- npm run pretest
1919
- eval $(node tasks/docker.js setup)
20+
- npm ls
2021

2122
test:
2223
override:

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"browserify-transform-tools": "^1.5.1",
9898
"deep-equal": "^1.0.1",
9999
"ecstatic": "^2.1.0",
100-
"eslint": "^3.5.0",
100+
"eslint": "^3.9.1",
101101
"falafel": "^2.0.0",
102102
"fs-extra": "^0.30.0",
103103
"fuse.js": "^2.2.0",

src/plot_api/plot_api.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2005,7 +2005,7 @@ function _relayout(gd, aobj) {
20052005
*/
20062006
else if(['hovermode', 'dragmode'].indexOf(ai) !== -1) flags.domodebar = true;
20072007
else if(['hovermode', 'dragmode', 'height',
2008-
'width', 'autosize'].indexOf(ai) === -1) {
2008+
'width', 'autosize'].indexOf(ai) === -1) {
20092009
flags.doplot = true;
20102010
}
20112011

@@ -2258,7 +2258,6 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
22582258
frameOpts: frameOpts,
22592259
transitionOpts: transitionOpts,
22602260
};
2261-
22622261
if(i === frameList.length - 1) {
22632262
// The last frame in this .animate call stores the promise resolve
22642263
// and reject callbacks. This is how we ensure that the animation
@@ -2410,14 +2409,15 @@ Plotly.animate = function(gd, frameOrGroupNameOrFrameList, animationOpts) {
24102409
} else if(isFrameArray) {
24112410
for(i = 0; i < frameOrGroupNameOrFrameList.length; i++) {
24122411
var frameOrName = frameOrGroupNameOrFrameList[i];
2413-
if(typeof frameOrName === 'string') {
2412+
if(['number', 'string'].indexOf(typeof frameOrName) !== -1) {
2413+
frameOrName = String(frameOrName);
24142414
// In this case, there's an array and this frame is a string name:
24152415
frameList.push({
24162416
type: 'byname',
24172417
name: frameOrName,
24182418
data: setTransitionConfig({name: frameOrName})
24192419
});
2420-
} else {
2420+
} else if(Lib.isPlainObject(frameOrName)) {
24212421
frameList.push({
24222422
type: 'object',
24232423
data: setTransitionConfig(Lib.extendFlat({}, frameOrName))

src/plots/cartesian/tick_label_defaults.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ module.exports = function handleTickLabelDefaults(containerIn, containerOut, coe
6767
*/
6868
function getShowAttrDflt(containerIn) {
6969
var showAttrsAll = ['showexponent',
70-
'showtickprefix',
71-
'showticksuffix'],
70+
'showtickprefix',
71+
'showticksuffix'],
7272
showAttrs = showAttrsAll.filter(function(a) {
7373
return containerIn[a] !== undefined;
7474
}),

src/plots/geo/set_scale.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ function makeRangeBox(lon0, lat0, lon1, lat1) {
127127
return {
128128
type: 'Polygon',
129129
coordinates: [
130-
[ [lon0, lat0],
130+
[ [lon0, lat0],
131131
[lon0, lat1],
132132
[lon0 + dlon4, lat1],
133133
[lon0 + 2 * dlon4, lat1],

src/plots/plots.js

+6
Original file line numberDiff line numberDiff line change
@@ -1796,6 +1796,9 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts)
17961796
}
17971797

17981798
function completeTransition(callback) {
1799+
// Fail-safe against purged plot:
1800+
if(!gd._transitionData) return;
1801+
17991802
flushCallbacks(gd._transitionData._interruptCallbacks);
18001803

18011804
return Promise.resolve().then(function() {
@@ -1813,6 +1816,9 @@ plots.transition = function(gd, data, layout, traces, frameOpts, transitionOpts)
18131816
}
18141817

18151818
function interruptPreviousTransitions() {
1819+
// Fail-safe against purged plot:
1820+
if(!gd._transitionData) return;
1821+
18161822
// If a transition is interrupted, set this to false. At the moment, the only thing that would
18171823
// interrupt a transition is another transition, so that it will momentarily be set to true
18181824
// again, but this determines whether autorange or dragbox work, so it's for the sake of

src/traces/contour/plot.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ function makePath(pi, loc, edgeflag) {
320320
// even # of pts - average central two
321321
else {
322322
newpt = [(getpt(ptavg)[0] + getpt(ptavg + 1)[0]) / 2,
323-
(getpt(ptavg)[1] + getpt(ptavg + 1)[1]) / 2];
323+
(getpt(ptavg)[1] + getpt(ptavg + 1)[1]) / 2];
324324
}
325325

326326
pts.splice(cnt2 + 1, cnt - cnt2 + 1, newpt);
@@ -458,12 +458,12 @@ function getInterpPx(pi, loc, step) {
458458
if(step[1]) {
459459
var dx = (pi.level - zxy) / (pi.z[locy][locx + 1] - zxy);
460460
return [xa.c2p((1 - dx) * pi.x[locx] + dx * pi.x[locx + 1], true),
461-
ya.c2p(pi.y[locy], true)];
461+
ya.c2p(pi.y[locy], true)];
462462
}
463463
else {
464464
var dy = (pi.level - zxy) / (pi.z[locy + 1][locx] - zxy);
465465
return [xa.c2p(pi.x[locx], true),
466-
ya.c2p((1 - dy) * pi.y[locy] + dy * pi.y[locy + 1], true)];
466+
ya.c2p((1 - dy) * pi.y[locy] + dy * pi.y[locy + 1], true)];
467467
}
468468
}
469469

src/traces/surface/convert.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ function refine(coords) {
151151
var padImg = padField(coords[i]);
152152
var scaledImg = ndarray(new Float32Array(nsize), nshape);
153153
homography(scaledImg, padImg, [scaleF, 0, 0,
154-
0, scaleF, 0,
155-
0, 0, 1]);
154+
0, scaleF, 0,
155+
0, 0, 1]);
156156
coords[i] = scaledImg;
157157
}
158158

test/jasmine/tests/animate_test.js

+53
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ describe('Test animate API', function() {
8888

8989
mockCopy = Lib.extendDeep({}, mock);
9090

91+
// ------------------------------------------------------------
92+
// NB: TRANSITION IS FAKED
93+
//
94+
// This means that you should not expect `.animate` to actually
95+
// modify the plot in any way in the tests below. For tests
96+
// involvingnon-faked transitions, see the bottom of this file.
97+
// ------------------------------------------------------------
98+
9199
spyOn(Plots, 'transition').and.callFake(function() {
92100
// Transition's fake behavior is just to delay by the duration
93101
// and resolve:
@@ -579,3 +587,48 @@ describe('Test animate API', function() {
579587
});
580588
});
581589
});
590+
591+
describe('Test animate API', function() {
592+
'use strict';
593+
594+
var gd, mockCopy;
595+
596+
beforeEach(function(done) {
597+
gd = createGraphDiv();
598+
mockCopy = Lib.extendDeep({}, mock);
599+
Plotly.plot(gd, mockCopy.data, mockCopy.layout).then(function() {
600+
return Plotly.addFrames(gd, mockCopy.frames);
601+
}).then(done);
602+
});
603+
604+
afterEach(function() {
605+
Plotly.purge(gd);
606+
destroyGraphDiv();
607+
});
608+
609+
it('does not fail if strings are not used', function(done) {
610+
Plotly.addFrames(gd, [{name: 8, data: [{x: [8, 7, 6]}]}]).then(function() {
611+
// Verify it was added as a string name:
612+
expect(gd._transitionData._frameHash['8']).not.toBeUndefined();
613+
614+
// Transition using a number:
615+
return Plotly.animate(gd, [8], {transition: {duration: 0}, frame: {duration: 0}});
616+
}).then(function() {
617+
// Confirm the result:
618+
expect(gd.data[0].x).toEqual([8, 7, 6]);
619+
}).catch(fail).then(done);
620+
});
621+
622+
it('ignores null and undefined frames', function(done) {
623+
var cnt = 0;
624+
gd.on('plotly_animatingframe', function() {cnt++;});
625+
626+
Plotly.animate(gd, ['frame0', null, undefined], {transition: {duration: 0}, frame: {duration: 0}}).then(function() {
627+
// Check only one animating was fired:
628+
expect(cnt).toEqual(1);
629+
630+
// Check unused frames did not affect the current frame:
631+
expect(gd._fullLayout._currentFrame).toEqual('frame0');
632+
}).catch(fail).then(done);
633+
});
634+
});

test/jasmine/tests/frame_api_test.js

+6
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ describe('Test frame api', function() {
6060
}).catch(fail).then(done);
6161
});
6262

63+
it('casts names to strings', function(done) {
64+
Plotly.addFrames(gd, [{name: 5}]).then(function() {
65+
expect(Object.keys(h)).toEqual(['5']);
66+
}).catch(fail).then(done);
67+
});
68+
6369
it('creates multiple unnamed frames at the same time', function(done) {
6470
Plotly.addFrames(gd, [{}, {}]).then(function() {
6571
expect(f).toEqual([{name: 'frame 0'}, {name: 'frame 1'}]);

test/jasmine/tests/heatmap_test.js

+37-37
Original file line numberDiff line numberDiff line change
@@ -452,43 +452,43 @@ describe('heatmap plot', function() {
452452

453453
argumentsWithPadding = getContextStub.fillRect.calls.allArgs().slice(getContextStub.fillRect.calls.allArgs().length - 9);
454454
expect(argumentsWithPadding).toEqual([
455-
[argumentsWithoutPadding[0][0],
456-
argumentsWithoutPadding[0][1] + edgeYGap,
457-
argumentsWithoutPadding[0][2] - edgeXGap,
458-
argumentsWithoutPadding[0][3] - edgeYGap],
459-
[argumentsWithoutPadding[1][0] + centerXGap,
460-
argumentsWithoutPadding[1][1] + edgeYGap,
461-
argumentsWithoutPadding[1][2] - edgeXGap,
462-
argumentsWithoutPadding[1][3] - edgeYGap],
463-
[argumentsWithoutPadding[2][0] + edgeXGap,
464-
argumentsWithoutPadding[2][1] + edgeYGap,
465-
argumentsWithoutPadding[2][2] - edgeXGap,
466-
argumentsWithoutPadding[2][3] - edgeYGap],
467-
[argumentsWithoutPadding[3][0],
468-
argumentsWithoutPadding[3][1] + centerYGap,
469-
argumentsWithoutPadding[3][2] - edgeXGap,
470-
argumentsWithoutPadding[3][3] - edgeYGap],
471-
[argumentsWithoutPadding[4][0] + centerXGap,
472-
argumentsWithoutPadding[4][1] + centerYGap,
473-
argumentsWithoutPadding[4][2] - edgeXGap,
474-
argumentsWithoutPadding[4][3] - edgeYGap],
475-
[argumentsWithoutPadding[5][0] + edgeXGap,
476-
argumentsWithoutPadding[5][1] + centerYGap,
477-
argumentsWithoutPadding[5][2] - edgeXGap,
478-
argumentsWithoutPadding[5][3] - edgeYGap],
479-
[argumentsWithoutPadding[6][0],
480-
argumentsWithoutPadding[6][1],
481-
argumentsWithoutPadding[6][2] - edgeXGap,
482-
argumentsWithoutPadding[6][3] - edgeYGap],
483-
[argumentsWithoutPadding[7][0] + centerXGap,
484-
argumentsWithoutPadding[7][1],
485-
argumentsWithoutPadding[7][2] - edgeXGap,
486-
argumentsWithoutPadding[7][3] - edgeYGap],
487-
[argumentsWithoutPadding[8][0] + edgeXGap,
488-
argumentsWithoutPadding[8][1],
489-
argumentsWithoutPadding[8][2] - edgeXGap,
490-
argumentsWithoutPadding[8][3] - edgeYGap
491-
]]);
455+
[argumentsWithoutPadding[0][0],
456+
argumentsWithoutPadding[0][1] + edgeYGap,
457+
argumentsWithoutPadding[0][2] - edgeXGap,
458+
argumentsWithoutPadding[0][3] - edgeYGap],
459+
[argumentsWithoutPadding[1][0] + centerXGap,
460+
argumentsWithoutPadding[1][1] + edgeYGap,
461+
argumentsWithoutPadding[1][2] - edgeXGap,
462+
argumentsWithoutPadding[1][3] - edgeYGap],
463+
[argumentsWithoutPadding[2][0] + edgeXGap,
464+
argumentsWithoutPadding[2][1] + edgeYGap,
465+
argumentsWithoutPadding[2][2] - edgeXGap,
466+
argumentsWithoutPadding[2][3] - edgeYGap],
467+
[argumentsWithoutPadding[3][0],
468+
argumentsWithoutPadding[3][1] + centerYGap,
469+
argumentsWithoutPadding[3][2] - edgeXGap,
470+
argumentsWithoutPadding[3][3] - edgeYGap],
471+
[argumentsWithoutPadding[4][0] + centerXGap,
472+
argumentsWithoutPadding[4][1] + centerYGap,
473+
argumentsWithoutPadding[4][2] - edgeXGap,
474+
argumentsWithoutPadding[4][3] - edgeYGap],
475+
[argumentsWithoutPadding[5][0] + edgeXGap,
476+
argumentsWithoutPadding[5][1] + centerYGap,
477+
argumentsWithoutPadding[5][2] - edgeXGap,
478+
argumentsWithoutPadding[5][3] - edgeYGap],
479+
[argumentsWithoutPadding[6][0],
480+
argumentsWithoutPadding[6][1],
481+
argumentsWithoutPadding[6][2] - edgeXGap,
482+
argumentsWithoutPadding[6][3] - edgeYGap],
483+
[argumentsWithoutPadding[7][0] + centerXGap,
484+
argumentsWithoutPadding[7][1],
485+
argumentsWithoutPadding[7][2] - edgeXGap,
486+
argumentsWithoutPadding[7][3] - edgeYGap],
487+
[argumentsWithoutPadding[8][0] + edgeXGap,
488+
argumentsWithoutPadding[8][1],
489+
argumentsWithoutPadding[8][2] - edgeXGap,
490+
argumentsWithoutPadding[8][3] - edgeYGap
491+
]]);
492492
done();
493493
});
494494
});

test/jasmine/tests/lib_test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ describe('Test lib.js:', function() {
662662
var colVal = 'red',
663663
sizeVal = 14,
664664
attrs = {testMarker: {testColor: {valType: 'color', dflt: 'rgba(0, 0, 0, 0)'},
665-
testSize: {valType: 'number', dflt: 20}}},
665+
testSize: {valType: 'number', dflt: 20}}},
666666
obj = {testMarker: {testColor: colVal, testSize: sizeVal}},
667667
outObj = {},
668668
colOut = coerce2(obj, outObj, attrs, 'testMarker.testColor'),
@@ -678,7 +678,7 @@ describe('Test lib.js:', function() {
678678
var colVal = 'r',
679679
sizeVal = 'aaaaah!',
680680
attrs = {testMarker: {testColor: {valType: 'color', dflt: 'rgba(0, 0, 0, 0)'},
681-
testSize: {valType: 'number', dflt: 20}}},
681+
testSize: {valType: 'number', dflt: 20}}},
682682
obj = {testMarker: {testColor: colVal, testSize: sizeVal}},
683683
outObj = {},
684684
colOut = coerce2(obj, outObj, attrs, 'testMarker.testColor'),
@@ -694,7 +694,7 @@ describe('Test lib.js:', function() {
694694
var colVal = null,
695695
sizeVal = null,
696696
attrs = {testMarker: {testColor: {valType: 'color', dflt: 'rgba(0, 0, 0, 0)'},
697-
testSize: {valType: 'number', dflt: 20}}},
697+
testSize: {valType: 'number', dflt: 20}}},
698698
obj = {testMarker: {testColor: colVal, testSize: sizeVal}},
699699
outObj = {},
700700
colOut = coerce2(obj, outObj, attrs, 'testMarker.testColor'),

0 commit comments

Comments
 (0)