Skip to content

Commit 1367c07

Browse files
committed
Merge branch 'master' into streamtube-traces
2 parents 218dfc8 + 887cae6 commit 1367c07

File tree

13 files changed

+640
-870
lines changed

13 files changed

+640
-870
lines changed

package-lock.json

Lines changed: 475 additions & 811 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@
5858
"@plotly/d3-sankey": "^0.5.0",
5959
"alpha-shape": "^1.0.0",
6060
"array-range": "^1.0.1",
61-
"bubleify": "^1.0.0",
6261
"canvas-fit": "^1.5.0",
6362
"color-normalize": "^1.0.3",
6463
"color-rgba": "^2.0.0",
@@ -75,7 +74,7 @@
7574
"gl-error3d": "^1.0.7",
7675
"gl-heatmap2d": "^1.0.4",
7776
"gl-line3d": "^1.1.2",
78-
"gl-mat4": "^1.1.2",
77+
"gl-mat4": "^1.2.0",
7978
"gl-mesh3d": "^2.0.0",
8079
"gl-plot2d": "^1.3.1",
8180
"gl-plot3d": "^1.5.5",
@@ -122,7 +121,7 @@
122121
"check-node-version": "^3.2.0",
123122
"deep-equal": "^1.0.1",
124123
"ecstatic": "^3.2.0",
125-
"eslint": "^4.18.0",
124+
"eslint": "^4.19.1",
126125
"falafel": "^2.0.0",
127126
"fs-extra": "^2.0.0",
128127
"fuse.js": "^3.2.0",
@@ -131,27 +130,26 @@
131130
"image-size": "^0.6.2",
132131
"into-stream": "^3.1.0",
133132
"jasmine-core": "^2.99.1",
134-
"jsdom": "^11.6.2",
135-
"karma": "^2.0.0",
133+
"jsdom": "^11.10.0",
134+
"karma": "^2.0.2",
136135
"karma-browserify": "^5.2.0",
137136
"karma-chrome-launcher": "^2.0.0",
138-
"karma-coverage": "^1.0.0",
139137
"karma-firefox-launcher": "^1.0.1",
140-
"karma-jasmine": "^1.1.0",
138+
"karma-jasmine": "^1.1.2",
141139
"karma-jasmine-spec-tags": "^1.0.1",
142140
"karma-spec-reporter": "0.0.32",
143141
"karma-verbose-reporter": "0.0.6",
144142
"madge": "^3.0.1",
145-
"minify-stream": "^1.1.0",
143+
"minify-stream": "^1.2.0",
146144
"minimist": "^1.2.0",
147-
"node-sass": "^4.7.2",
145+
"node-sass": "^4.9.0",
148146
"npm-link-check": "^2.0.0",
149147
"open": "0.0.5",
150148
"prepend-file": "^1.3.1",
151149
"prettysize": "1.1.0",
152-
"read-last-lines": "^1.1.0",
150+
"read-last-lines": "^1.4.0",
153151
"requirejs": "^2.3.1",
154-
"run-series": "^1.1.4",
152+
"run-series": "^1.1.8",
155153
"through2": "^2.0.3",
156154
"true-case-path": "^1.0.2",
157155
"watchify": "^3.10.0",

src/lib/prepare_regl.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,12 @@ var createRegl = require('regl');
2323
* @param {array} extensions : list of extension to pass to createRegl
2424
*/
2525
module.exports = function prepareRegl(gd, extensions) {
26-
gd._fullLayout._glcanvas.each(function(d) {
26+
var fullLayout = gd._fullLayout;
27+
28+
fullLayout._glcanvas.each(function(d) {
2729
if(d.regl) return;
30+
// only parcoords needs pick layer
31+
if(d.pick && !fullLayout._has('parcoords')) return;
2832

2933
d.regl = createRegl({
3034
canvas: this,

src/traces/contourcarpet/calc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function heatmappishCalc(gd, trace) {
8484
z = trace._z = clean2dArray(trace._z || trace.z, trace.transpose);
8585

8686
trace._emptypoints = findEmpties(z);
87-
trace._interpz = interp2d(z, trace._emptypoints, trace._interpz);
87+
interp2d(z, trace._emptypoints);
8888

8989
// create arrays of brick boundaries, to be used by autorange and heatmap.plot
9090
var xlen = maxRowLength(z),

src/traces/heatmap/calc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ module.exports = function calc(gd, trace) {
7777

7878
if(isContour || trace.connectgaps) {
7979
trace._emptypoints = findEmpties(z);
80-
trace._interpz = interp2d(z, trace._emptypoints, trace._interpz);
80+
interp2d(z, trace._emptypoints);
8181
}
8282
}
8383

src/traces/heatmap/interp2d.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,37 @@
1010

1111
var Lib = require('../../lib');
1212

13-
var INTERPTHRESHOLD = 1e-2,
14-
NEIGHBORSHIFTS = [[-1, 0], [1, 0], [0, -1], [0, 1]];
13+
var INTERPTHRESHOLD = 1e-2;
14+
var NEIGHBORSHIFTS = [[-1, 0], [1, 0], [0, -1], [0, 1]];
1515

1616
function correctionOvershoot(maxFractionalChange) {
1717
// start with less overshoot, until we know it's converging,
1818
// then ramp up the overshoot for faster convergence
1919
return 0.5 - 0.25 * Math.min(1, maxFractionalChange * 0.5);
2020
}
2121

22-
module.exports = function interp2d(z, emptyPoints, savedInterpZ) {
23-
// fill in any missing data in 2D array z using an iterative
24-
// poisson equation solver with zero-derivative BC at edges
25-
// amazingly, this just amounts to repeatedly averaging all the existing
26-
// nearest neighbors (at least if we don't take x/y scaling into account)
27-
var maxFractionalChange = 1,
28-
i,
29-
thisPt;
30-
31-
if(Array.isArray(savedInterpZ)) {
32-
for(i = 0; i < emptyPoints.length; i++) {
33-
thisPt = emptyPoints[i];
34-
z[thisPt[0]][thisPt[1]] = savedInterpZ[thisPt[0]][thisPt[1]];
35-
}
36-
}
37-
else {
38-
// one pass to fill in a starting value for all the empties
39-
iterateInterp2d(z, emptyPoints);
40-
}
22+
/*
23+
* interp2d: Fill in missing data from a 2D array using an iterative
24+
* poisson equation solver with zero-derivative BC at edges.
25+
* Amazingly, this just amounts to repeatedly averaging all the existing
26+
* nearest neighbors, at least if we don't take x/y scaling into account,
27+
* which is the right approach here where x and y may not even have the
28+
* same units.
29+
*
30+
* @param {array of arrays} z
31+
* The 2D array to fill in. Will be mutated here. Assumed to already be
32+
* cleaned, so all entries are numbers except gaps, which are `undefined`.
33+
* @param {array of arrays} emptyPoints
34+
* Each entry [i, j, neighborCount] for empty points z[i][j] and the number
35+
* of neighbors that are *not* missing. Assumed to be sorted from most to
36+
* least neighbors, as produced by heatmap/find_empties.
37+
*/
38+
module.exports = function interp2d(z, emptyPoints) {
39+
var maxFractionalChange = 1;
40+
var i;
41+
42+
// one pass to fill in a starting value for all the empties
43+
iterateInterp2d(z, emptyPoints);
4144

4245
// we're don't need to iterate lone empties - remove them
4346
for(i = 0; i < emptyPoints.length; i++) {

tasks/noci_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ root=$(dirname $0)/..
66
# tests that aren't run on CI (yet)
77

88
# jasmine specs with @noCI tag
9-
npm run test-jasmine -- --tags=noCI --nowatch || EXIT_STATE=$?
9+
npm run test-jasmine -- --tags=noCI,noCIdep --nowatch || EXIT_STATE=$?
1010

1111
# mapbox image tests take too much resources on CI
1212
#

test/jasmine/karma.conf.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,13 @@ func.defaultConfig = {
210210
// A few tests don't behave well on CI
211211
// add @noCI to the spec description to skip a spec on CI
212212
//
213+
// Although not recommended, some tests "depend" on other
214+
// tests to pass (e.g. the Plotly.react tests check that
215+
// all available traces and transforms are tested). Tag these
216+
// with @noCIdep, so that
217+
// - $ npm run test-jasmine -- tags=noCI,noCIdep
218+
// can pass.
219+
//
213220
// Label tests that require a WebGL-context by @gl so that
214221
// they can be skipped using:
215222
// - $ npm run test-jasmine -- --skip-tags=gl

test/jasmine/tests/contour_test.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,46 @@ describe('contour plotting and editing', function() {
458458
.catch(fail)
459459
.then(done);
460460
});
461+
462+
it('can change z values with gaps', function(done) {
463+
Plotly.newPlot(gd, [{
464+
type: 'contour',
465+
z: [[1, 2], [null, 4], [1, 2]]
466+
}])
467+
.then(function() {
468+
expect(gd.calcdata[0][0].z).toEqual([[1, 2], [2, 4], [1, 2]]);
469+
expect(gd.calcdata[0][0].zmask).toEqual([[1, 1], [0, 1], [1, 1]]);
470+
471+
return Plotly.react(gd, [{
472+
type: 'contour',
473+
z: [[6, 5], [8, 7], [null, 10]]
474+
}]);
475+
})
476+
.then(function() {
477+
expect(gd.calcdata[0][0].z).toEqual([[6, 5], [8, 7], [9, 10]]);
478+
expect(gd.calcdata[0][0].zmask).toEqual([[1, 1], [1, 1], [0, 1]]);
479+
480+
return Plotly.react(gd, [{
481+
type: 'contour',
482+
z: [[1, 2], [null, 4], [1, 2]]
483+
}]);
484+
})
485+
.then(function() {
486+
expect(gd.calcdata[0][0].z).toEqual([[1, 2], [2, 4], [1, 2]]);
487+
expect(gd.calcdata[0][0].zmask).toEqual([[1, 1], [0, 1], [1, 1]]);
488+
489+
return Plotly.react(gd, [{
490+
type: 'contour',
491+
// notice that this one is the same as the previous, except that
492+
// a previously present value was removed...
493+
z: [[1, 2], [null, 4], [1, null]]
494+
}]);
495+
})
496+
.then(function() {
497+
expect(gd.calcdata[0][0].z).toEqual([[1, 2], [2, 4], [1, 2.5]]);
498+
expect(gd.calcdata[0][0].zmask).toEqual([[1, 1], [0, 1], [1, 0]]);
499+
})
500+
.catch(fail)
501+
.then(done);
502+
});
461503
});

0 commit comments

Comments
 (0)