Skip to content

Commit 703381f

Browse files
committed
some linting
- assign contours.value to variable - assign cd0.trace to variable - apply Math.min and Math.max instead of using .apply (only 2 values) - break up if clauses into multiple lines
1 parent 672a1c2 commit 703381f

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

src/traces/contour/close_boundaries.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = function(pathinfo, operation, perimeter, trace) {
1515
var na = pi0.x.length;
1616
var nb = pi0.y.length;
1717
var z = pi0.z;
18-
var contours = trace.contours;
18+
var contoursValue = trace.contours.value;
1919

2020
var boundaryMax = -Infinity;
2121
var boundaryMin = Infinity;
@@ -38,25 +38,25 @@ module.exports = function(pathinfo, operation, perimeter, trace) {
3838

3939
switch(operation) {
4040
case '>':
41-
if(contours.value > boundaryMax) {
41+
if(contoursValue > boundaryMax) {
4242
pi0.prefixBoundary = true;
4343
}
4444
break;
4545
case '<':
46-
if(contours.value < boundaryMin) {
46+
if(contoursValue < boundaryMin) {
4747
pi0.prefixBoundary = true;
4848
}
4949
break;
5050
case '[]':
51-
v1 = Math.min.apply(null, contours.value);
52-
v2 = Math.max.apply(null, contours.value);
51+
v1 = Math.min(contoursValue[0], contoursValue[1]);
52+
v2 = Math.max(contoursValue[0], contoursValue[1]);
5353
if(v2 < boundaryMin || v1 > boundaryMax) {
5454
pi0.prefixBoundary = true;
5555
}
5656
break;
5757
case '][':
58-
v1 = Math.min.apply(null, contours.value);
59-
v2 = Math.max.apply(null, contours.value);
58+
v1 = Math.min(contoursValue[0], contoursValue[1]);
59+
v2 = Math.max(contoursValue[0], contoursValue[1]);
6060
if(v1 < boundaryMin && v2 > boundaryMax) {
6161
pi0.prefixBoundary = true;
6262
}

src/traces/contour/convert_to_constraints.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ module.exports = function(pathinfo, operation) {
3737
for(i = 0; i < pi0.edgepaths.length; i++) {
3838
pi0.edgepaths[i] = op0(pi0.edgepaths[i]);
3939
}
40-
4140
for(i = 0; i < pi0.paths.length; i++) {
4241
pi0.paths[i] = op0(pi0.paths[i]);
4342
}
43+
4444
return pathinfo;
4545
case '][':
4646
var tmp = op0;

src/traces/contour/plot.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,17 +612,18 @@ exports.drawLabels = function(labelGroup, labelData, gd, lineClip, labelClipPath
612612
};
613613

614614
function clipGaps(plotGroup, plotinfo, gd, cd0, perimeter) {
615+
var trace = cd0.trace;
615616
var clips = gd._fullLayout._clips;
616-
var clipId = 'clip' + cd0.trace.uid;
617+
var clipId = 'clip' + trace.uid;
617618

618619
var clipPath = clips.selectAll('#' + clipId)
619-
.data(cd0.trace.connectgaps ? [] : [0]);
620+
.data(trace.connectgaps ? [] : [0]);
620621
clipPath.enter().append('clipPath')
621622
.classed('contourclip', true)
622623
.attr('id', clipId);
623624
clipPath.exit().remove();
624625

625-
if(cd0.trace.connectgaps === false) {
626+
if(trace.connectgaps === false) {
626627
var clipPathInfo = {
627628
// fraction of the way from missing to present point
628629
// to draw the boundary.

src/traces/contourcarpet/join_all_paths.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,14 @@ module.exports = function joinAllPaths(trace, pi, perimeter, ab2p, carpet, carpe
8787
var ptNew = pi.edgepaths[possiblei][0];
8888
// is ptNew on the (horz. or vert.) segment from endpt to newendpt?
8989
if(Math.abs(endpt[0] - newendpt[0]) < atol) {
90-
if(Math.abs(endpt[0] - ptNew[0]) < atol && (ptNew[1] - endpt[1]) * (newendpt[1] - ptNew[1]) >= 0) {
90+
if(Math.abs(endpt[0] - ptNew[0]) < atol &&
91+
(ptNew[1] - endpt[1]) * (newendpt[1] - ptNew[1]) >= 0) {
9192
newendpt = ptNew;
9293
nexti = possiblei;
9394
}
9495
} else if(Math.abs(endpt[1] - newendpt[1]) < btol) {
95-
if(Math.abs(endpt[1] - ptNew[1]) < btol && (ptNew[0] - endpt[0]) * (newendpt[0] - ptNew[0]) >= 0) {
96+
if(Math.abs(endpt[1] - ptNew[1]) < btol &&
97+
(ptNew[0] - endpt[0]) * (newendpt[0] - ptNew[0]) >= 0) {
9698
newendpt = ptNew;
9799
nexti = possiblei;
98100
}

0 commit comments

Comments
 (0)