Skip to content

Commit 0be5d33

Browse files
committed
lint ('comma-spacing', 'key-spacing', some 'space-infix-ops')
1 parent 3a6b49c commit 0be5d33

File tree

12 files changed

+75
-70
lines changed

12 files changed

+75
-70
lines changed

src/components/legend/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
/**
32
* Copyright 2012-2016, Plotly, Inc.
43
* All rights reserved.

src/traces/scatter/attributes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ module.exports = {
7777
},
7878
mode: {
7979
valType: 'flaglist',
80-
flags: ['lines','markers','text'],
80+
flags: ['lines', 'markers', 'text'],
8181
extras: ['none'],
8282
role: 'info',
8383
description: [

src/traces/scatter/calc.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,17 @@ var calcMarkerColorscale = require('./marker_colorscale_calc');
1919

2020

2121
module.exports = function calc(gd, trace) {
22-
var xa = Axes.getFromId(gd,trace.xaxis||'x'),
23-
ya = Axes.getFromId(gd,trace.yaxis||'y');
22+
var xa = Axes.getFromId(gd, trace.xaxis || 'x'),
23+
ya = Axes.getFromId(gd, trace.yaxis || 'y');
2424
Lib.markTime('in Scatter.calc');
25-
var x = xa.makeCalcdata(trace,'x');
25+
26+
var x = xa.makeCalcdata(trace, 'x');
2627
Lib.markTime('finished convert x');
27-
var y = ya.makeCalcdata(trace,'y');
28+
29+
var y = ya.makeCalcdata(trace, 'y');
2830
Lib.markTime('finished convert y');
29-
var serieslen = Math.min(x.length,y.length),
31+
32+
var serieslen = Math.min(x.length, y.length),
3033
marker,
3134
s,
3235
i;
@@ -35,13 +38,13 @@ module.exports = function calc(gd, trace) {
3538
xa._minDtick = 0;
3639
ya._minDtick = 0;
3740

38-
if(x.length>serieslen) x.splice(serieslen, x.length-serieslen);
39-
if(y.length>serieslen) y.splice(serieslen, y.length-serieslen);
41+
if(x.length > serieslen) x.splice(serieslen, x.length - serieslen);
42+
if(y.length > serieslen) y.splice(serieslen, y.length - serieslen);
4043

4144
// check whether bounds should be tight, padded, extended to zero...
4245
// most cases both should be padded on both ends, so start with that.
43-
var xOptions = {padded:true},
44-
yOptions = {padded:true};
46+
var xOptions = {padded: true},
47+
yOptions = {padded: true};
4548

4649
if(subTypes.hasMarkers(trace)) {
4750

@@ -55,19 +58,19 @@ module.exports = function calc(gd, trace) {
5558
var ax = {type: 'linear'};
5659
Axes.setConvert(ax);
5760
s = ax.makeCalcdata(trace.marker, 'size');
58-
if(s.length>serieslen) s.splice(serieslen, s.length-serieslen);
61+
if(s.length > serieslen) s.splice(serieslen, s.length - serieslen);
5962
}
6063

61-
var sizeref = 1.6*(trace.marker.sizeref||1),
64+
var sizeref = 1.6 * (trace.marker.sizeref || 1),
6265
markerTrans;
63-
if(trace.marker.sizemode==='area') {
66+
if(trace.marker.sizemode === 'area') {
6467
markerTrans = function(v) {
65-
return Math.max(Math.sqrt((v||0)/sizeref),3);
68+
return Math.max(Math.sqrt((v || 0) / sizeref), 3);
6669
};
6770
}
6871
else {
6972
markerTrans = function(v) {
70-
return Math.max((v||0)/sizeref,3);
73+
return Math.max((v || 0) / sizeref, 3);
7174
};
7275
}
7376
xOptions.ppad = yOptions.ppad = Array.isArray(s) ?
@@ -80,14 +83,15 @@ module.exports = function calc(gd, trace) {
8083

8184
// include zero (tight) and extremes (padded) if fill to zero
8285
// (unless the shape is closed, then it's just filling the shape regardless)
83-
if((trace.fill==='tozerox' || (trace.fill==='tonextx' && gd.firstscatter)) &&
84-
(x[0]!==x[serieslen-1] || y[0]!==y[serieslen-1])) {
86+
if(((trace.fill === 'tozerox') ||
87+
((trace.fill === 'tonextx') && gd.firstscatter)) &&
88+
((x[0] !== x[serieslen - 1]) || (y[0] !== y[serieslen - 1]))) {
8589
xOptions.tozero = true;
8690
}
8791

8892
// if no error bars, markers or text, or fill to y=0 remove x padding
8993
else if(!trace.error_y.visible && (
90-
['tonexty', 'tozeroy'].indexOf(trace.fill)!==-1 ||
94+
['tonexty', 'tozeroy'].indexOf(trace.fill) !== -1 ||
9195
(!subTypes.hasMarkers(trace) && !subTypes.hasText(trace))
9296
)) {
9397
xOptions.padded = false;
@@ -97,13 +101,13 @@ module.exports = function calc(gd, trace) {
97101
// now check for y - rather different logic, though still mostly padded both ends
98102
// include zero (tight) and extremes (padded) if fill to zero
99103
// (unless the shape is closed, then it's just filling the shape regardless)
100-
if((trace.fill==='tozeroy' || (trace.fill==='tonexty' && gd.firstscatter)) &&
101-
(x[0]!==x[serieslen-1] || y[0]!==y[serieslen-1])) {
104+
if(((trace.fill === 'tozeroy') || ((trace.fill === 'tonexty') && gd.firstscatter)) &&
105+
((x[0] !== x[serieslen - 1]) || (y[0] !== y[serieslen - 1]))) {
102106
yOptions.tozero = true;
103107
}
104108

105109
// tight y: any x fill
106-
else if(['tonextx', 'tozerox'].indexOf(trace.fill)!==-1) {
110+
else if(['tonextx', 'tozerox'].indexOf(trace.fill) !== -1) {
107111
yOptions.padded = false;
108112
}
109113

src/traces/scatter/clean_data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = function cleanData(fullData) {
2121
for(i = 0; i < fullData.length; i++) {
2222
tracei = fullData[i];
2323
filli = tracei.fill;
24-
if(filli==='none' || (tracei.type !== 'scatter')) continue;
24+
if((filli === 'none') || (tracei.type !== 'scatter')) continue;
2525
tracei.opacity = undefined;
2626

2727
if(filli === 'tonexty' || filli === 'tonextx') {

src/traces/scatter/colorbar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module.exports = function colorbar(gd, cd) {
2828
// TODO unify Scatter.colorbar and Heatmap.colorbar
2929
// TODO make Plotly[module].colorbar support multiple colorbar per trace
3030

31-
if(marker===undefined || !marker.showscale){
31+
if((marker === undefined) || !marker.showscale){
3232
Plotly.Plots.autoMargin(gd, cbId);
3333
return;
3434
}

src/traces/scatter/defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,5 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
6868

6969
function lineShapeDefaults(traceIn, traceOut, coerce) {
7070
var shape = coerce('line.shape');
71-
if(shape==='spline') coerce('line.smoothing');
71+
if(shape === 'spline') coerce('line.smoothing');
7272
}

src/traces/scatter/hover.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,20 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
1919
trace = cd[0].trace,
2020
xa = pointData.xa,
2121
ya = pointData.ya,
22-
dx = function(di){
22+
dx = function(di) {
2323
// scatter points: d.mrc is the calculated marker radius
2424
// adjust the distance so if you're inside the marker it
2525
// always will show up regardless of point size, but
2626
// prioritize smaller points
27-
var rad = Math.max(3, di.mrc||0);
27+
var rad = Math.max(3, di.mrc || 0);
2828
return Math.max(Math.abs(xa.c2p(di.x)-xa.c2p(xval))-rad, 1-3/rad);
2929
},
30-
dy = function(di){
31-
var rad = Math.max(3, di.mrc||0);
30+
dy = function(di) {
31+
var rad = Math.max(3, di.mrc || 0);
3232
return Math.max(Math.abs(ya.c2p(di.y)-ya.c2p(yval))-rad, 1-3/rad);
3333
},
3434
dxy = function(di) {
35-
var rad = Math.max(3, di.mrc||0),
35+
var rad = Math.max(3, di.mrc || 0),
3636
dx = Math.abs(xa.c2p(di.x)-xa.c2p(xval)),
3737
dy = Math.abs(ya.c2p(di.y)-ya.c2p(yval));
3838
return Math.max(Math.sqrt(dx*dx + dy*dy)-rad, 1-3/rad);
@@ -42,13 +42,13 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
4242
Fx.getClosest(cd, distfn, pointData);
4343

4444
// skip the rest (for this trace) if we didn't find a close point
45-
if(pointData.index===false) return;
45+
if(pointData.index === false) return;
4646

4747
// the closest data point
4848
var di = cd[pointData.index],
4949
xc = xa.c2p(di.x, true),
5050
yc = ya.c2p(di.y, true),
51-
rad = di.mrc||1;
51+
rad = di.mrc || 1;
5252

5353
pointData.color = getTraceColor(trace, di);
5454

src/traces/scatter/make_bubble_size_func.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ module.exports = function makeBubbleSizeFn(trace) {
2323
// and by area or diameter.
2424
// Note this only applies to the array-value sizes
2525

26-
var baseFn = marker.sizemode==='area' ?
26+
var baseFn = (marker.sizemode === 'area') ?
2727
function(v) { return Math.sqrt(v / sizeRef); } :
2828
function(v) { return v / sizeRef; };
2929

@@ -33,7 +33,8 @@ module.exports = function makeBubbleSizeFn(trace) {
3333
var baseSize = baseFn(v / 2);
3434

3535
// don't show non-numeric and negative sizes
36-
return (isNumeric(baseSize) && baseSize>0) ?
37-
Math.max(baseSize, sizeMin) : 0;
36+
return (isNumeric(baseSize) && (baseSize > 0)) ?
37+
Math.max(baseSize, sizeMin) :
38+
0;
3839
};
3940
};

src/traces/scatter/marker_defaults.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout
3838
// if there's a line with a different color than the marker, use
3939
// that line color as the default marker line color
4040
// mostly this is for transparent markers to behave nicely
41-
if(lineColor && traceOut.marker.color!==lineColor) {
41+
if(lineColor && (traceOut.marker.color !== lineColor)) {
4242
defaultMLC = lineColor;
4343
}
4444
else if(isBubble) defaultMLC = Color.background;

src/traces/scatter/plot.js

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ module.exports = function plot(gd, plotinfo, cdscatter) {
3131
.selectAll('g.trace.scatter')
3232
.data(cdscatter);
3333
scattertraces.enter().append('g')
34-
.attr('class','trace scatter')
35-
.style('stroke-miterlimit',2);
34+
.attr('class', 'trace scatter')
35+
.style('stroke-miterlimit', 2);
3636

3737
// BUILD LINES AND FILLS
38-
var prevpath='',
39-
tozero,tonext,nexttonext;
38+
var prevpath = '',
39+
tozero, tonext, nexttonext;
40+
4041
scattertraces.each(function(d){
4142
var trace = d[0].trace,
4243
line = trace.line,
@@ -47,7 +48,7 @@ module.exports = function plot(gd, plotinfo, cdscatter) {
4748

4849
arraysToCalcdata(d);
4950

50-
if(!subTypes.hasLines(trace) && trace.fill==='none') return;
51+
if(!subTypes.hasLines(trace) && trace.fill === 'none') return;
5152

5253
var thispath,
5354
// fullpath is all paths for this curve, joined together straight
@@ -61,10 +62,10 @@ module.exports = function plot(gd, plotinfo, cdscatter) {
6162
// make the fill-to-zero path now, so it shows behind the line
6263
// fill to next puts the fill associated with one trace
6364
// grouped with the previous
64-
if(trace.fill.substr(0,6)==='tozero' ||
65-
(trace.fill.substr(0,2)==='to' && !prevpath)) {
65+
if(trace.fill.substr(0, 6) === 'tozero' ||
66+
(trace.fill.substr(0, 2) === 'to' && !prevpath)) {
6667
tozero = tr.append('path')
67-
.classed('js-fill',true);
68+
.classed('js-fill', true);
6869
}
6970
else tozero = null;
7071

@@ -75,15 +76,15 @@ module.exports = function plot(gd, plotinfo, cdscatter) {
7576
if(nexttonext) tonext = nexttonext.datum(d);
7677

7778
// now make a new nexttonext for next time
78-
nexttonext = tr.append('path').classed('js-fill',true);
79+
nexttonext = tr.append('path').classed('js-fill', true);
7980

80-
if(['hv','vh','hvh','vhv'].indexOf(line.shape)!==-1) {
81+
if(['hv', 'vh', 'hvh', 'vhv'].indexOf(line.shape) !== -1) {
8182
pathfn = Drawing.steps(line.shape);
8283
revpathbase = Drawing.steps(
8384
line.shape.split('').reverse().join('')
8485
);
8586
}
86-
else if(line.shape==='spline') {
87+
else if(line.shape === 'spline') {
8788
pathfn = revpathbase = function(pts) {
8889
return Drawing.smoothopen(pts, line.smoothing);
8990
};
@@ -96,7 +97,7 @@ module.exports = function plot(gd, plotinfo, cdscatter) {
9697

9798
revpathfn = function(pts) {
9899
// note: this is destructive (reverses pts in place) so can't use pts after this
99-
return 'L'+revpathbase(pts.reverse()).substr(1);
100+
return 'L' + revpathbase(pts.reverse()).substr(1);
100101
};
101102

102103
var segments = linePoints(d, {
@@ -115,27 +116,27 @@ module.exports = function plot(gd, plotinfo, cdscatter) {
115116
for(var i = 0; i < segments.length; i++) {
116117
var pts = segments[i];
117118
thispath = pathfn(pts);
118-
fullpath += fullpath ? ('L'+thispath.substr(1)) : thispath;
119+
fullpath += fullpath ? ('L' + thispath.substr(1)) : thispath;
119120
revpath = revpathfn(pts) + revpath;
120121
if(subTypes.hasLines(trace) && pts.length > 1) {
121-
tr.append('path').classed('js-line',true).attr('d', thispath);
122+
tr.append('path').classed('js-line', true).attr('d', thispath);
122123
}
123124
}
124125
if(tozero) {
125126
if(pt0 && pt1) {
126-
if(trace.fill.charAt(trace.fill.length-1)==='y') {
127-
pt0[1]=pt1[1]=ya.c2p(0,true);
127+
if(trace.fill.charAt(trace.fill.length - 1) === 'y') {
128+
pt0[1] = pt1[1] = ya.c2p(0, true);
128129
}
129-
else pt0[0]=pt1[0]=xa.c2p(0,true);
130+
else pt0[0] = pt1[0] = xa.c2p(0, true);
130131

131132
// fill to zero: full trace path, plus extension of
132133
// the endpoints to the appropriate axis
133-
tozero.attr('d',fullpath+'L'+pt1+'L'+pt0+'Z');
134+
tozero.attr('d', fullpath + 'L' + pt1 + 'L' + pt0 + 'Z');
134135
}
135136
}
136-
else if(trace.fill.substr(0,6)==='tonext' && fullpath && prevpath) {
137+
else if(trace.fill.substr(0, 6) === 'tonext' && fullpath && prevpath) {
137138
// fill to next: full trace path, plus the previous path reversed
138-
tonext.attr('d',fullpath+prevpath+'Z');
139+
tonext.attr('d', fullpath + prevpath + 'Z');
139140
}
140141
prevpath = revpath;
141142
}
@@ -145,12 +146,12 @@ module.exports = function plot(gd, plotinfo, cdscatter) {
145146
scattertraces.selectAll('path:not([d])').remove();
146147

147148
function visFilter(d){
148-
return d.filter(function(v){ return v.vis; });
149+
return d.filter(function(v) { return v.vis; });
149150
}
150151

151152
scattertraces.append('g')
152-
.attr('class','points')
153-
.each(function(d){
153+
.attr('class', 'points')
154+
.each(function(d) {
154155
var trace = d[0].trace,
155156
s = d3.select(this),
156157
showMarkers = subTypes.hasMarkers(trace),
@@ -184,20 +185,20 @@ function selectMarkers(gd, plotinfo, cdscatter) {
184185
xr = d3.extent(xa.range.map(xa.l2c)),
185186
yr = d3.extent(ya.range.map(ya.l2c));
186187

187-
cdscatter.forEach(function(d,i) {
188+
cdscatter.forEach(function(d, i) {
188189
var trace = d[0].trace;
189190
if(!subTypes.hasMarkers(trace)) return;
190191
// if marker.maxdisplayed is used, select a maximum of
191192
// mnum markers to show, from the set that are in the viewport
192193
var mnum = trace.marker.maxdisplayed;
193194

194195
// TODO: remove some as we get away from the viewport?
195-
if(mnum===0) return;
196+
if(mnum === 0) return;
196197

197198
var cd = d.filter(function(v) {
198199
return v.x>=xr[0] && v.x<=xr[1] && v.y>=yr[0] && v.y<=yr[1];
199200
}),
200-
inc = Math.ceil(cd.length/mnum),
201+
inc = Math.ceil(cd.length / mnum),
201202
tnum = 0;
202203
cdscatter.forEach(function(cdj, j) {
203204
var tracei = cdj[0].trace;
@@ -211,13 +212,13 @@ function selectMarkers(gd, plotinfo, cdscatter) {
211212
// display this formula offsets successive traces by 1/3 of the
212213
// increment, adding an extra small amount after each triplet so
213214
// it's not quite periodic
214-
var i0 = Math.round(tnum*inc/3 + Math.floor(tnum/3)*inc/7.1);
215+
var i0 = Math.round(tnum*inc/3 + Math.floor(tnum/3) * inc/7.1);
215216

216217
// for error bars: save in cd which markers to show
217218
// so we don't have to repeat this
218-
d.forEach(function(v){ delete v.vis; });
219-
cd.forEach(function(v,i) {
220-
if(Math.round((i+i0)%inc)===0) v.vis = true;
219+
d.forEach(function(v) { delete v.vis; });
220+
cd.forEach(function(v, i) {
221+
if(Math.round((i + i0) % inc) === 0) v.vis = true;
221222
});
222223
});
223224
}

src/traces/scatter/style.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ module.exports = function style(gd) {
2424
s.selectAll('g.points')
2525
.each(function(d){
2626
d3.select(this).selectAll('path.point')
27-
.call(Drawing.pointStyle,d.trace||d[0].trace);
27+
.call(Drawing.pointStyle, d.trace || d[0].trace);
2828
d3.select(this).selectAll('text')
29-
.call(Drawing.textPointStyle,d.trace||d[0].trace);
29+
.call(Drawing.textPointStyle, d.trace || d[0].trace);
3030
});
3131

3232
s.selectAll('g.trace path.js-line')

src/traces/scatter/xy_defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ module.exports = function handleXYDefaults(traceIn, traceOut, coerce) {
2323
// which could be a problem eg in streaming / editing if x and y
2424
// come in at different times
2525
// so we need to revisit calc before taking this out
26-
if(len<x.length) traceOut.x = x.slice(0, len);
27-
if(len<y.length) traceOut.y = y.slice(0, len);
26+
if(len < x.length) traceOut.x = x.slice(0, len);
27+
if(len < y.length) traceOut.y = y.slice(0, len);
2828
}
2929
else {
3030
len = x.length;

0 commit comments

Comments
 (0)