Skip to content

Commit 268cc89

Browse files
committed
enforce key-spacing
1 parent a72c6ee commit 268cc89

File tree

27 files changed

+171
-150
lines changed

27 files changed

+171
-150
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"comma-style": [2, "last"],
2020
"semi": [2],
2121
"semi-spacing": [2, {"before": false, "after": true}],
22-
"key-spacing": [0, {"beforeColon": false, "afterColon": true}],
22+
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
2323
"no-spaced-func": [2],
2424
"space-in-parens": [2, "never"],
2525
"space-before-function-paren": [2, "never"],

src/components/annotations/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ annotations.draw = function(gd, index, opt, value) {
572572
.attr({
573573
'data-index': String(index),
574574
d: 'M3,3H-3V-3H3ZM0,0L' + (arrowX0-arrowX) + ',' + (arrowY0-arrowY),
575-
transform:'translate('+arrowX+','+arrowY+')'
575+
transform: 'translate('+arrowX+','+arrowY+')'
576576
})
577577
.style('stroke-width', (strokewidth+6)+'px')
578578
.call(Plotly.Color.stroke, 'rgba(0,0,0,0)')

src/components/color/index.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ color.combine = function(front, back){
4545

4646
var bc = tinycolor(back||color.background).toRgb(),
4747
bcflat = bc.a===1 ? bc : {
48-
r:255*(1-bc.a) + bc.r*bc.a,
49-
g:255*(1-bc.a) + bc.g*bc.a,
50-
b:255*(1-bc.a) + bc.b*bc.a
48+
r: 255 * (1-bc.a) + bc.r*bc.a,
49+
g: 255 * (1-bc.a) + bc.g*bc.a,
50+
b: 255 * (1-bc.a) + bc.b*bc.a
5151
},
5252
fcflat = {
53-
r:bcflat.r*(1-fc.a) + fc.r*fc.a,
54-
g:bcflat.g*(1-fc.a) + fc.g*fc.a,
55-
b:bcflat.b*(1-fc.a) + fc.b*fc.a
53+
r: bcflat.r*(1-fc.a) + fc.r*fc.a,
54+
g: bcflat.g*(1-fc.a) + fc.g*fc.a,
55+
b: bcflat.b*(1-fc.a) + fc.b*fc.a
5656
};
5757
return tinycolor(fcflat).toRgbString();
5858
};

src/components/colorbar/draw.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ module.exports = function draw(gd, id) {
132132

133133
// y positioning we can do correctly from the start
134134
yBottomFrac = opts.y + lenFrac *
135-
(({top:-0.5, bottom:0.5}[opts.yanchor]||0)-0.5),
135+
(({top: -0.5, bottom: 0.5}[opts.yanchor] || 0) - 0.5),
136136
yBottomPx = Math.round(fullLayout._size.h * (1-yBottomFrac)),
137137
yTopPx = yBottomPx-lenPx,
138138
titleEl,
@@ -431,7 +431,7 @@ module.exports = function draw(gd, id) {
431431
});
432432

433433
// fix positioning for xanchor!='left'
434-
var xoffset = ({center:0.5, right:1}[opts.xanchor]||0) *
434+
var xoffset = ({center: 0.5, right: 1}[opts.xanchor] || 0) *
435435
outerwidth;
436436
container.attr('transform',
437437
'translate('+(fullLayout._size.l-xoffset)+','+fullLayout._size.t+')');
@@ -440,10 +440,10 @@ module.exports = function draw(gd, id) {
440440
Plots.autoMargin(gd, id,{
441441
x: opts.x,
442442
y: opts.y,
443-
l: outerwidth*({right:1, center:0.5}[opts.xanchor]||0),
444-
r: outerwidth*({left:1, center:0.5}[opts.xanchor]||0),
445-
t: outerheight*({bottom:1, middle:0.5}[opts.yanchor]||0),
446-
b: outerheight*({top:1, middle:0.5}[opts.yanchor]||0)
443+
l: outerwidth * ({right: 1, center: 0.5}[opts.xanchor] || 0),
444+
r: outerwidth * ({left: 1, center: 0.5}[opts.xanchor] || 0),
445+
t: outerheight * ({bottom: 1, middle: 0.5}[opts.yanchor] || 0),
446+
b: outerheight * ({top: 1, middle: 0.5}[opts.yanchor] || 0)
447447
});
448448
}
449449

src/components/colorscale/scales.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,31 @@
1010

1111

1212
module.exports = {
13-
'Greys':[[0,'rgb(0,0,0)'],[1,'rgb(255,255,255)']],
13+
'Greys': [[0,'rgb(0,0,0)'],[1,'rgb(255,255,255)']],
1414

15-
'YIGnBu':[[0,'rgb(8, 29, 88)'],[0.125,'rgb(37, 52, 148)'],
15+
'YIGnBu': [[0,'rgb(8, 29, 88)'],[0.125,'rgb(37, 52, 148)'],
1616
[0.25,'rgb(34, 94, 168)'],[0.375,'rgb(29, 145, 192)'],
1717
[0.5,'rgb(65, 182, 196)'],[0.625,'rgb(127, 205, 187)'],
1818
[0.75,'rgb(199, 233, 180)'],[0.875,'rgb(237, 248, 217)'],
1919
[1,'rgb(255, 255, 217)']],
2020

21-
'Greens':[[0,'rgb(0, 68, 27)'],[0.125,'rgb(0, 109, 44)'],
21+
'Greens': [[0,'rgb(0, 68, 27)'],[0.125,'rgb(0, 109, 44)'],
2222
[0.25,'rgb(35, 139, 69)'],[0.375,'rgb(65, 171, 93)'],
2323
[0.5,'rgb(116, 196, 118)'],[0.625,'rgb(161, 217, 155)'],
2424
[0.75,'rgb(199, 233, 192)'],[0.875,'rgb(229, 245, 224)'],
2525
[1,'rgb(247, 252, 245)']],
2626

27-
'YIOrRd':[[0,'rgb(128, 0, 38)'],[0.125,'rgb(189, 0, 38)'],
27+
'YIOrRd': [[0,'rgb(128, 0, 38)'],[0.125,'rgb(189, 0, 38)'],
2828
[0.25,'rgb(227, 26, 28)'],[0.375,'rgb(252, 78, 42)'],
2929
[0.5,'rgb(253, 141, 60)'],[0.625,'rgb(254, 178, 76)'],
3030
[0.75,'rgb(254, 217, 118)'],[0.875,'rgb(255, 237, 160)'],
3131
[1,'rgb(255, 255, 204)']],
3232

33-
'Bluered':[[0,'rgb(0,0,255)'],[1,'rgb(255,0,0)']],
33+
'Bluered': [[0,'rgb(0,0,255)'],[1,'rgb(255,0,0)']],
3434

3535
// modified RdBu based on
3636
// www.sandia.gov/~kmorel/documents/ColorMaps/ColorMapsExpanded.pdf
37-
'RdBu':[[0,'rgb(5, 10, 172)'],[0.35,'rgb(106, 137, 247)'],
37+
'RdBu': [[0,'rgb(5, 10, 172)'],[0.35,'rgb(106, 137, 247)'],
3838
[0.5,'rgb(190,190,190)'],[0.6,'rgb(220, 170, 132)'],
3939
[0.7,'rgb(230, 145, 90)'],[1,'rgb(178, 10, 28)']],
4040
// Scale for non-negative numeric values
@@ -45,39 +45,39 @@ module.exports = {
4545
[0.5, 'rgb(70, 100, 245)'], [0.6, 'rgb(90, 120, 245)'],
4646
[0.7, 'rgb(106, 137, 247)'], [1, 'rgb(220, 220, 220)']],
4747

48-
'Picnic':[[0,'rgb(0,0,255)'],[0.1,'rgb(51,153,255)'],
48+
'Picnic': [[0,'rgb(0,0,255)'],[0.1,'rgb(51,153,255)'],
4949
[0.2,'rgb(102,204,255)'],[0.3,'rgb(153,204,255)'],
5050
[0.4,'rgb(204,204,255)'],[0.5,'rgb(255,255,255)'],
5151
[0.6,'rgb(255,204,255)'],[0.7,'rgb(255,153,255)'],
5252
[0.8,'rgb(255,102,204)'],[0.9,'rgb(255,102,102)'],
5353
[1,'rgb(255,0,0)']],
5454

55-
'Rainbow':[[0,'rgb(150,0,90)'],[0.125,'rgb(0, 0, 200)'],
55+
'Rainbow': [[0,'rgb(150,0,90)'],[0.125,'rgb(0, 0, 200)'],
5656
[0.25,'rgb(0, 25, 255)'],[0.375,'rgb(0, 152, 255)'],
5757
[0.5,'rgb(44, 255, 150)'],[0.625,'rgb(151, 255, 0)'],
5858
[0.75,'rgb(255, 234, 0)'],[0.875,'rgb(255, 111, 0)'],
5959
[1,'rgb(255, 0, 0)']],
6060

61-
'Portland':[[0,'rgb(12,51,131)'],[0.25,'rgb(10,136,186)'],
61+
'Portland': [[0,'rgb(12,51,131)'],[0.25,'rgb(10,136,186)'],
6262
[0.5,'rgb(242,211,56)'],[0.75,'rgb(242,143,56)'],
6363
[1,'rgb(217,30,30)']],
6464

65-
'Jet':[[0,'rgb(0,0,131)'],[0.125,'rgb(0,60,170)'],
65+
'Jet': [[0,'rgb(0,0,131)'],[0.125,'rgb(0,60,170)'],
6666
[0.375,'rgb(5,255,255)'],[0.625,'rgb(255,255,0)'],
6767
[0.875,'rgb(250,0,0)'],[1,'rgb(128,0,0)']],
6868

69-
'Hot':[[0,'rgb(0,0,0)'],[0.3,'rgb(230,0,0)'],
69+
'Hot': [[0,'rgb(0,0,0)'],[0.3,'rgb(230,0,0)'],
7070
[0.6,'rgb(255,210,0)'],[1,'rgb(255,255,255)']],
7171

72-
'Blackbody':[[0,'rgb(0,0,0)'],[0.2,'rgb(230,0,0)'],
72+
'Blackbody': [[0,'rgb(0,0,0)'],[0.2,'rgb(230,0,0)'],
7373
[0.4,'rgb(230,210,0)'],[0.7,'rgb(255,255,255)'],
7474
[1,'rgb(160,200,255)']],
7575

76-
'Earth':[[0,'rgb(0,0,130)'],[0.1,'rgb(0,180,180)'],
76+
'Earth': [[0,'rgb(0,0,130)'],[0.1,'rgb(0,180,180)'],
7777
[0.2,'rgb(40,210,40)'],[0.4,'rgb(230,230,50)'],
7878
[0.6,'rgb(120,70,20)'],[1,'rgb(255,255,255)']],
7979

80-
'Electric':[[0,'rgb(0,0,0)'],[0.15,'rgb(30,0,100)'],
80+
'Electric': [[0,'rgb(0,0,0)'],[0.15,'rgb(30,0,100)'],
8181
[0.4,'rgb(120,0,100)'],[0.6,'rgb(160,90,0)'],
8282
[0.8,'rgb(230,200,0)'],[1,'rgb(255,250,220)']],
8383

src/components/drawing/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ drawing.tryColorscale = function(cont, contIn, prefix) {
296296
};
297297

298298
// draw text at points
299-
var TEXTOFFSETSIGN = {start:1, end:-1, middle:0, bottom:1, top:-1},
299+
var TEXTOFFSETSIGN = {start: 1, end: -1, middle: 0, bottom: 1, top: -1},
300300
LINEEXPAND = 1.3;
301301
drawing.textPointStyle = function(s, trace) {
302302
s.each(function(d){
@@ -467,7 +467,10 @@ drawing.makeTester = function(gd) {
467467
testref.enter().append('path')
468468
.classed('js-reference-point', true)
469469
.attr('d','M0,0H1V1H0Z')
470-
.style({'stroke-width':0, fill:'black'});
470+
.style({
471+
'stroke-width': 0,
472+
fill: 'black'
473+
});
471474

472475
if(!tester.node()._cache) {
473476
tester.node()._cache = {};
@@ -498,7 +501,11 @@ drawing.bBox = function(node) {
498501
var testNode = node.cloneNode(true);
499502
tester.appendChild(testNode);
500503
// standardize its position... do we really want to do this?
501-
d3.select(testNode).attr({x:0, y:0, transform:''});
504+
d3.select(testNode).attr({
505+
x: 0,
506+
y: 0,
507+
transform: ''
508+
});
502509

503510
var testRect = testNode.getBoundingClientRect(),
504511
refRect = test3.select('.js-reference-point')

src/components/titles/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ Titles.draw = function(gd, title) {
5959
xa,
6060
ya,
6161
avoid = {
62-
selection:d3.select(gd).selectAll('g.'+cont._id+'tick'),
63-
side:cont.side
62+
selection: d3.select(gd).selectAll('g.'+cont._id+'tick'),
63+
side: cont.side
6464
},
6565
// multiples of fontsize to offset label from axis
6666
offsetBase = colorbar ? 0 : 1.5,

src/lib/dates.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,22 @@ exports.ms2DateTime = function(ms, r) {
166166
// TODO: this is way out of date vs. the server-side version
167167
var timeFormats = {
168168
// 24 hour
169-
H:['%H:%M:%S~%L', '%H:%M:%S', '%H:%M'],
169+
H: ['%H:%M:%S~%L', '%H:%M:%S', '%H:%M'],
170170
// with am/pm
171-
I:['%I:%M:%S~%L%p', '%I:%M:%S%p', '%I:%M%p'],
171+
I: ['%I:%M:%S~%L%p', '%I:%M:%S%p', '%I:%M%p'],
172172
// no colon, ie only date or date with hour (could also support eg 12h34m?)
173-
D:['%H', '%I%p', '%Hh']
173+
D: ['%H', '%I%p', '%Hh']
174174
};
175175

176176
var dateFormats = {
177-
Y:[
177+
Y: [
178178
'%Y~%m~%d',
179179
'%Y%m%d',
180180
'%y%m%d', // YYMMDD, has 6 digits together so will match Y, not y
181181
'%m~%d~%Y', // MM/DD/YYYY has first precedence
182182
'%d~%m~%Y' // then DD/MM/YYYY
183183
],
184-
Yb:[
184+
Yb: [
185185
'%b~%d~%Y', // eg nov 21 2013
186186
'%d~%b~%Y', // eg 21 nov 2013
187187
'%Y~%d~%b', // eg 2013 21 nov (or 2013 q3, after replacement)
@@ -191,12 +191,12 @@ var dateFormats = {
191191
* the two-digit year cases have so many potential ambiguities
192192
* it's not even funny, but we'll try them anyway.
193193
*/
194-
y:[
194+
y: [
195195
'%m~%d~%y',
196196
'%d~%m~%y',
197197
'%y~%m~%d'
198198
],
199-
yb:[
199+
yb: [
200200
'%b~%d~%y',
201201
'%d~%b~%y',
202202
'%y~%d~%b',

src/lib/svg_text_utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ util.convertToTspans = function(_context, _callback){
149149
var newSvgW = getSize(newSvg, 'width'),
150150
newSvgH = getSize(newSvg, 'height'),
151151
newX = +that.attr('x') - newSvgW *
152-
{start:0, middle:0.5, end:1}[that.attr('text-anchor') || 'start'],
152+
{start: 0, middle: 0.5, end: 1}[that.attr('text-anchor') || 'start'],
153153
// font baseline is about 1/4 fontSize below centerline
154154
textHeight = parseInt(that.style('font-size'), 10) ||
155155
getSize(that, 'height'),

src/plot_api/plot_api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,7 +1831,7 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
18311831
// it flips everything and the axes
18321832
else if(ai==='orientationaxes') {
18331833
cont.orientation =
1834-
{v:'h', h:'v'}[contFull.orientation];
1834+
{v: 'h', h: 'v'}[contFull.orientation];
18351835
}
18361836
swapXYData(cont);
18371837
}

src/plots/cartesian/axes.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,14 @@ axes.doAutoRange = function(ax) {
153153
else if(mbest) {
154154
if(ax.type==='linear' || ax.type==='-') {
155155
if(ax.rangemode==='tozero' && minbest.val>=0) {
156-
minbest = {val:0, pad:0};
156+
minbest = {val: 0, pad: 0};
157157
}
158158
else if(ax.rangemode==='nonnegative') {
159159
if(minbest.val - mbest*minbest.pad<0) {
160-
minbest = {val:0, pad:0};
160+
minbest = {val: 0, pad: 0};
161161
}
162162
if(maxbest.val<0) {
163-
maxbest = {val:1, pad:0};
163+
maxbest = {val: 1, pad: 0};
164164
}
165165
}
166166

@@ -309,8 +309,8 @@ axes.expand = function(ax, data, options) {
309309
}
310310
if(includeThis) {
311311
ax._min.push({
312-
val:dmin,
313-
pad:(tozero && dmin===0) ? 0 : ppadiminus
312+
val: dmin,
313+
pad: (tozero && dmin===0) ? 0 : ppadiminus
314314
});
315315
}
316316
}
@@ -329,8 +329,8 @@ axes.expand = function(ax, data, options) {
329329
}
330330
if(includeThis) {
331331
ax._max.push({
332-
val:dmax,
333-
pad:(tozero && dmax===0) ? 0 : ppadiplus
332+
val: dmax,
333+
pad: (tozero && dmax===0) ? 0 : ppadiplus
334334
});
335335
}
336336
}
@@ -375,7 +375,7 @@ axes.autoBin = function(data,ax,nbins,is2d) {
375375
// piggyback off autotick code to make "nice" bin sizes
376376
var dummyax = {
377377
type: ax.type==='log' ? 'linear' : ax.type,
378-
range:[datamin, datamax]
378+
range: [datamin, datamax]
379379
};
380380
axes.autoTicks(dummyax, size0);
381381
var binstart = axes.tickIncrement(
@@ -916,7 +916,7 @@ function formatDate(ax, out, hover, extraPrecision) {
916916
else {
917917
if(extraPrecision) {
918918
if(isNumeric(tr)) tr+=2;
919-
else tr = {y:'m', m:'d', d:'H', H:'M', M:'S', S:2}[tr];
919+
else tr = {y: 'm', m: 'd', d: 'H', H: 'M', M: 'S', S: 2}[tr];
920920
}
921921
if(tr==='y') tt = yearFormat(d);
922922
else if(tr==='m') tt = monthFormat(d);
@@ -1028,7 +1028,7 @@ function numFormat(v, ax, fmtoverride, hover) {
10281028
if(hover) {
10291029
// make a dummy axis obj to get the auto rounding and exponent
10301030
var ah = {
1031-
exponentformat:ax.exponentformat,
1031+
exponentformat: ax.exponentformat,
10321032
dtick: ax.showexponent==='none' ? ax.dtick :
10331033
(isNumeric(v) ? Math.abs(v) || 1 : 1),
10341034
// if not showing any exponents, don't change the exponent
@@ -1539,7 +1539,7 @@ axes.doTicks = function(td, axid, skipTitle) {
15391539
else {
15401540
var mjShift =
15411541
Plotly.Drawing.bBox(mathjaxGroup.node()).width *
1542-
{end:-0.5, start:0.5}[anchor];
1542+
{end: -0.5, start: 0.5}[anchor];
15431543
mathjaxGroup.attr('transform', transform +
15441544
(mjShift ? 'translate(' + mjShift + ',0)' : ''));
15451545
}
@@ -1575,9 +1575,9 @@ axes.doTicks = function(td, axid, skipTitle) {
15751575

15761576
lbbArray.push({
15771577
// ignore about y, just deal with x overlaps
1578-
top:0,
1579-
bottom:10,
1580-
height:10,
1578+
top: 0,
1579+
bottom: 10,
1580+
height: 10,
15811581
left: x-bb.width/2,
15821582
// impose a 2px gap
15831583
right: x+bb.width/2 + 2,
@@ -1658,10 +1658,10 @@ axes.doTicks = function(td, axid, skipTitle) {
16581658
}
16591659
var showZl = (ax.range[0]*ax.range[1]<=0) && ax.zeroline &&
16601660
(ax.type==='linear' || ax.type==='-') && gridvals.length &&
1661-
(hasBarsOrFill || clipEnds({x:0}) || !ax.showline);
1661+
(hasBarsOrFill || clipEnds({x: 0}) || !ax.showline);
16621662

16631663
var zl = zlcontainer.selectAll('path.'+zcls)
1664-
.data(showZl ? [{x:0}] : []);
1664+
.data(showZl ? [{x: 0}] : []);
16651665
zl.enter().append('path').classed(zcls,1).classed('zl',1)
16661666
.classed('crisp',1)
16671667
.attr('d',gridpath);
@@ -1754,7 +1754,7 @@ function makeAxisGroups(gd, traces) {
17541754
}
17551755

17561756
if(!groupsi.length) {
1757-
groups.push({x:[xi], y: [yi]});
1757+
groups.push({x: [xi], y: [yi]});
17581758
continue;
17591759
}
17601760

src/plots/cartesian/axis_defaults.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function setAutoType(ax, data){
141141
// first check for histograms, as the count direction
142142
// should always default to a linear axis
143143
if(d0.type==='histogram' &&
144-
axLetter === {v:'y', h:'x'}[d0.orientation || 'v']) {
144+
axLetter === {v: 'y', h: 'x'}[d0.orientation || 'v']) {
145145
ax.type='linear';
146146
return;
147147
}
@@ -171,7 +171,7 @@ function setAutoType(ax, data){
171171
}
172172

173173
function getBoxPosLetter(trace) {
174-
return {v:'x', h:'y'}[trace.orientation || 'v'];
174+
return {v: 'x', h: 'y'}[trace.orientation || 'v'];
175175
}
176176

177177
function isBoxWithoutPositionCoords(trace, axLetter) {

0 commit comments

Comments
 (0)