diff --git a/.eslintrc b/.eslintrc index 302c24a6df4..c03a5bd58aa 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,7 +4,7 @@ "eslint:recommended" ], "parserOptions": { - "ecmaVersion": 5, + "ecmaVersion": 5 }, "env": { "commonjs": true @@ -27,7 +27,7 @@ "indent": [0], "indent-legacy": [2, 4, {"SwitchCase": 1}], "max-len": [0, 80], - "brace-style": [0, "stroustrup", {"allowSingleLine": true}], + "brace-style": [2, "1tbs", {"allowSingleLine": true}], "curly": [2, "multi-line"], "camelcase": [2, {"properties": "never"}], "comma-spacing": [2, {"before": false, "after": true}], diff --git a/devtools/test_dashboard/perf.js b/devtools/test_dashboard/perf.js index 66e19a7278e..7165f5107ea 100644 --- a/devtools/test_dashboard/perf.js +++ b/devtools/test_dashboard/perf.js @@ -25,8 +25,7 @@ window.timeit = function(f, n, nchunk, arg) { for(var j = 0; j < nchunk; j++) { f(_arg); } t1 = performance.now(); dt = (t1 - t0) / nchunk; - } - else { + } else { t0 = performance.now(); f(_arg); t1 = performance.now(); diff --git a/src/components/annotations/click.js b/src/components/annotations/click.js index fa26957c0d9..082b459c61e 100644 --- a/src/components/annotations/click.js +++ b/src/components/annotations/click.js @@ -111,8 +111,7 @@ function getToggleSets(gd, hoverData) { if(anni.visible) { if(showMode === 'onout') toggleType = offSet; else toggleType = explicitOffSet; - } - else { + } else { toggleType = onSet; } toggleType.push(i); diff --git a/src/components/annotations/draw.js b/src/components/annotations/draw.js index 60cbf7e112d..2fdb1086924 100644 --- a/src/components/annotations/draw.js +++ b/src/components/annotations/draw.js @@ -316,13 +316,11 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { } basePx = ax._offset + ax.r2p(options[axLetter]); autoAlignFraction = 0.5; - } - else { + } else { if(axLetter === 'x') { alignPosition = options[axLetter]; basePx = gs.l + gs.w * alignPosition; - } - else { + } else { alignPosition = 1 - options[axLetter]; basePx = gs.t + gs.h * alignPosition; } @@ -344,8 +342,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { posPx.tail = ax._offset + ax.r2p(arrowLength); // tail is data-referenced: autorange pads the text in px from the tail textPadShift = textShift; - } - else { + } else { posPx.tail = basePx + arrowLength; // tail is specified in px from head, so autorange also pads vs head textPadShift = textShift + arrowLength; @@ -365,8 +362,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { if(shiftPlus > 0) { posPx.tail += shiftPlus; posPx.text += shiftPlus; - } - else if(shiftMinus > 0) { + } else if(shiftMinus > 0) { posPx.tail -= shiftMinus; posPx.text -= shiftMinus; } @@ -374,8 +370,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { posPx.tail += overallShift; posPx.head += overallShift; - } - else { + } else { // with no arrow, the text rotates and *then* we put the anchor // relative to the new bounding box textShift = annSize * shiftFraction(autoAlignFraction, anchor); @@ -419,8 +414,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { y: borderfull + yShift }) .call(Drawing.setClipUrl, isSizeConstrained ? annClipID : null, gd); - } - else { + } else { var texty = borderfull + yShift - anntextBB.top; var textx = borderfull + xShift - anntextBB.left; @@ -629,8 +623,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { } drawArrow(dx, dy); - } - else if(!subplotId) { + } else if(!subplotId) { var xUpdate, yUpdate; if(xa) { xUpdate = xa.p2r(xa.r2p(options.x) + dx); @@ -660,8 +653,7 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { options.xanchor, options.yanchor ); } - } - else return; + } else return; annTextGroup.attr({ transform: 'translate(' + dx + ',' + dy + ')' + baseTextTransform @@ -698,6 +690,5 @@ function drawRaw(gd, options, index, subplotId, xa, ya) { Registry.call('_guiRelayout', gd, getUpdateObj()); }); - } - else annText.call(textLayout); + } else annText.call(textLayout); } diff --git a/src/components/annotations/draw_arrow_head.js b/src/components/annotations/draw_arrow_head.js index 48fba5ac534..e3f6f71a1e5 100644 --- a/src/components/annotations/draw_arrow_head.js +++ b/src/components/annotations/draw_arrow_head.js @@ -89,8 +89,7 @@ module.exports = function drawArrowHead(el3, ends, options) { start.y -= startbackOffY; el3.attr({x1: start.x, y1: start.y}); } - } - else if(el.nodeName === 'path') { + } else if(el.nodeName === 'path') { var pathlen = el.getTotalLength(); // using dash to hide the backOff region of the path. // if we ever allow dash for the arrow we'll have to diff --git a/src/components/calendars/index.js b/src/components/calendars/index.js index 27240860f32..c3af0421955 100644 --- a/src/components/calendars/index.js +++ b/src/components/calendars/index.js @@ -137,8 +137,7 @@ function worldCalFmt(fmt, x, calendar) { directiveLen = 3; directive = fmt.charAt(i + 2); if(modifier === '_') modifier = '-'; - } - else { + } else { directive = modifier; modifier = '0'; directiveLen = 2; @@ -146,8 +145,7 @@ function worldCalFmt(fmt, x, calendar) { directiveObj = d3ToWorldCalendars[directive]; if(!directiveObj) { i += directiveLen; - } - else { + } else { // code is recognized as a date part but world-calendars doesn't support it if(directiveObj === UNKNOWN) replacementPart = UNKNOWN; diff --git a/src/components/color/index.js b/src/components/color/index.js index 88076691637..c7ad824d234 100644 --- a/src/components/color/index.js +++ b/src/components/color/index.js @@ -106,27 +106,26 @@ color.clean = function(container) { key = keys[i]; val = container[key]; - // only sanitize keys that end in "color" or "colorscale" if(key.substr(key.length - 5) === 'color') { + // only sanitize keys that end in "color" or "colorscale" + if(Array.isArray(val)) { for(j = 0; j < val.length; j++) val[j] = cleanOne(val[j]); - } - else container[key] = cleanOne(val); - } - else if(key.substr(key.length - 10) === 'colorscale' && Array.isArray(val)) { + } else container[key] = cleanOne(val); + } else if(key.substr(key.length - 10) === 'colorscale' && Array.isArray(val)) { // colorscales have the format [[0, color1], [frac, color2], ... [1, colorN]] + for(j = 0; j < val.length; j++) { if(Array.isArray(val[j])) val[j][1] = cleanOne(val[j][1]); } - } - // recurse into arrays of objects, and plain objects - else if(Array.isArray(val)) { + } else if(Array.isArray(val)) { + // recurse into arrays of objects, and plain objects + var el0 = val[0]; if(!Array.isArray(el0) && el0 && typeof el0 === 'object') { for(j = 0; j < val.length; j++) color.clean(val[j]); } - } - else if(val && typeof val === 'object') color.clean(val); + } else if(val && typeof val === 'object') color.clean(val); } }; @@ -147,14 +146,21 @@ function cleanOne(val) { if(!parts[i].length) return val; parts[i] = Number(parts[i]); - // all parts must be non-negative numbers - if(!(parts[i] >= 0)) return val; - // alpha>1 gets clipped to 1 + if(!(parts[i] >= 0)) { + // all parts must be non-negative numbers + + return val; + } + if(i === 3) { + // alpha>1 gets clipped to 1 + if(parts[i] > 1) parts[i] = 1; + } else if(parts[i] >= 1) { + // r, g, b must be < 1 (ie 1 itself is not allowed) + + return val; } - // r, g, b must be < 1 (ie 1 itself is not allowed) - else if(parts[i] >= 1) return val; } var rgbStr = Math.round(parts[0] * 255) + ', ' + diff --git a/src/components/colorbar/draw.js b/src/components/colorbar/draw.js index d8f8313c7df..6354ab471dd 100644 --- a/src/components/colorbar/draw.js +++ b/src/components/colorbar/draw.js @@ -95,8 +95,7 @@ module.exports = function draw(gd, id) { if(opts.fillgradient) { filllevels = [0]; - } - else if(typeof opts.fillcolor === 'function') { + } else if(typeof opts.fillcolor === 'function') { if(opts.filllevels) { l0 = opts.filllevels.end + opts.filllevels.size / 100; ls = opts.filllevels.size; @@ -105,16 +104,14 @@ module.exports = function draw(gd, id) { if(ls > 0 ? (l >= l0) : (l <= l0)) break; if(l > zrange[0] && l < zrange[1]) filllevels.push(l); } - } - else { + } else { filllevels = linelevels.map(function(v) { return v - opts.levels.size / 2; }); filllevels.push(filllevels[filllevels.length - 1] + opts.levels.size); } - } - else if(opts.fillcolor && typeof opts.fillcolor === 'string') { + } else if(opts.fillcolor && typeof opts.fillcolor === 'string') { // doesn't matter what this value is, with a single value // we'll make a single fill rect covering the whole bar filllevels = [0]; @@ -292,8 +289,7 @@ module.exports = function draw(gd, id) { if(opts.title.side === 'top') { y = (1 - (yBottomFrac + lenFrac - ypadFrac)) * gs.h + gs.t + 3 + fontSize * 0.75; - } - else { + } else { y = (1 - (yBottomFrac + ypadFrac)) * gs.h + gs.t - 3 - fontSize * 0.25; } @@ -323,8 +319,7 @@ module.exports = function draw(gd, id) { // vertical alignment, but this seems to work. titleTrans[1] -= (titleHeight - lineSize) / 2; } - } - else if(titleText.node() && + } else if(titleText.node() && !titleText.classed(cn.jsPlaceholder)) { titleHeight = Drawing.bBox(titleText.node()).height; } @@ -336,8 +331,7 @@ module.exports = function draw(gd, id) { if(opts.title.side === 'top') { cbAxisOut.domain[1] -= titleHeight / gs.h; titleTrans[1] *= -1; - } - else { + } else { cbAxisOut.domain[0] += titleHeight / gs.h; var nlines = svgTextUtils.lineCount(titleText); titleTrans[1] += (1 - nlines) * lineSize; @@ -395,8 +389,7 @@ module.exports = function draw(gd, id) { if(opts.fillgradient) { Drawing.gradient(fillEl, gd, id, 'vertical', opts.fillgradient, 'fill'); - } - else { + } else { // Tinycolor can't handle exponents and // at this scale, removing it makes no difference. var colorString = fillcolormap(d).replace('e-', ''); @@ -514,8 +507,7 @@ module.exports = function draw(gd, id) { if(mathJaxNode && ['top', 'bottom'].indexOf(opts.title.side) !== -1) { titleWidth = Drawing.bBox(mathJaxNode).width; - } - else { + } else { // note: the formula below works for all title sides, // (except for top/bottom mathjax, above) // but the weird gs.l is because the titleunshift @@ -569,8 +561,7 @@ module.exports = function draw(gd, id) { marginOpts.y = opts.y; marginOpts.t = outerheight * tFrac; marginOpts.b = outerheight * bFrac; - } - else { + } else { marginOpts.t = marginOpts.b = 0; marginOpts.yt = opts.y + opts.len * tFrac; marginOpts.yb = opts.y - opts.len * bFrac; @@ -582,8 +573,7 @@ module.exports = function draw(gd, id) { marginOpts.x = opts.x; marginOpts.l = outerwidth * lFrac; marginOpts.r = outerwidth * rFrac; - } - else { + } else { var extraThickness = outerwidth - thickPx; marginOpts.l = extraThickness * lFrac; marginOpts.r = extraThickness * rFrac; diff --git a/src/components/colorscale/calc.js b/src/components/colorscale/calc.js index 6fb87c06b0c..ed2491f9420 100644 --- a/src/components/colorscale/calc.js +++ b/src/components/colorscale/calc.js @@ -41,8 +41,7 @@ module.exports = function calc(gd, trace, opts) { if(auto !== false && mid !== undefined) { if(max - mid > mid - min) { min = mid - (max - mid); - } - else if(max - mid < mid - min) { + } else if(max - mid < mid - min) { max = mid + (mid - min); } } diff --git a/src/components/colorscale/helpers.js b/src/components/colorscale/helpers.js index ff3e94e84e3..f9e262f3a18 100644 --- a/src/components/colorscale/helpers.js +++ b/src/components/colorscale/helpers.js @@ -135,20 +135,17 @@ function makeColorScaleFunc(specs, opts) { if(noNumericCheck && returnArray) { sclFunc = _sclFunc; - } - else if(noNumericCheck) { + } else if(noNumericCheck) { sclFunc = function(v) { return colorArray2rbga(_sclFunc(v)); }; - } - else if(returnArray) { + } else if(returnArray) { sclFunc = function(v) { if(isNumeric(v)) return _sclFunc(v); else if(tinycolor(v).isValid()) return v; else return Color.defaultLine; }; - } - else { + } else { sclFunc = function(v) { if(isNumeric(v)) return colorArray2rbga(_sclFunc(v)); else if(tinycolor(v).isValid()) return v; diff --git a/src/components/dragelement/index.js b/src/components/dragelement/index.js index f34e2103453..477edbb99de 100644 --- a/src/components/dragelement/index.js +++ b/src/components/dragelement/index.js @@ -241,8 +241,7 @@ dragElement.init = function init(options) { try { e2 = new MouseEvent('click', e); - } - catch(err) { + } catch(err) { var offset = pointerOffset(e); e2 = document.createEvent('MouseEvents'); e2.initMouseEvent('click', diff --git a/src/components/drawing/index.js b/src/components/drawing/index.js index 7cbd5cdbc04..aa5caec60ff 100644 --- a/src/components/drawing/index.js +++ b/src/components/drawing/index.js @@ -177,8 +177,7 @@ drawing.dashStyle = function(dash, lineWidth) { else if(dash === 'longdash') dash = (5 * dlw) + 'px,' + (5 * dlw) + 'px'; else if(dash === 'dashdot') { dash = (3 * dlw) + 'px,' + dlw + 'px,' + dlw + 'px,' + dlw + 'px'; - } - else if(dash === 'longdashdot') { + } else if(dash === 'longdashdot') { dash = (5 * dlw) + 'px,' + (2 * dlw) + 'px,' + dlw + 'px,' + (2 * dlw) + 'px'; } // otherwise user wrote the dasharray themselves - leave it be @@ -228,8 +227,7 @@ Object.keys(SYMBOLDEFS).forEach(function(k) { } if(symDef.noDot) { drawing.symbolNoDot[symDef.n] = true; - } - else { + } else { drawing.symbolList = drawing.symbolList.concat( [symDef.n + 200, k + '-dot', symDef.n + 300, k + '-open-dot']); } @@ -298,8 +296,7 @@ drawing.gradient = function(sel, gd, gradientID, type, colorscale, prop) { for(var i = 0; i < len; i++) { if(info.reversed) { colorStops[len - 1 - i] = [stopFormatter((1 - colorscale[i][0]) * 100), colorscale[i][1]]; - } - else { + } else { colorStops[i] = [stopFormatter(colorscale[i][0] * 100), colorscale[i][1]]; } } @@ -902,8 +899,7 @@ drawing.bBox = function(node, inTester, hash) { if(hash) { out = drawing.savedBBoxes[hash]; if(out) return Lib.extendFlat({}, out); - } - else if(node.childNodes.length === 1) { + } else if(node.childNodes.length === 1) { /* * If we have only one child element, which is itself hashable, make * a new hash from this element plus its x,y,transform @@ -951,8 +947,7 @@ drawing.bBox = function(node, inTester, hash) { var testNode, tester; if(inTester) { testNode = node; - } - else { + } else { tester = drawing.tester.node(); // copy the node to test into the tester diff --git a/src/components/errorbars/compute_error.js b/src/components/errorbars/compute_error.js index 0872a37809a..ca03c65c45f 100644 --- a/src/components/errorbars/compute_error.js +++ b/src/components/errorbars/compute_error.js @@ -37,8 +37,7 @@ module.exports = function makeComputeError(opts) { var val = +(array[index]); return [val, val]; }; - } - else { + } else { var arrayminus = opts.arrayminus || []; return function computeError(dataPt, index) { var val = +array[index]; @@ -52,8 +51,7 @@ module.exports = function makeComputeError(opts) { return [NaN, NaN]; }; } - } - else { + } else { var computeErrorValue = makeComputeErrorValue(type, opts.value); var computeErrorValueMinus = makeComputeErrorValue(type, opts.valueminus); @@ -62,8 +60,7 @@ module.exports = function makeComputeError(opts) { var val = computeErrorValue(dataPt); return [val, val]; }; - } - else { + } else { return function computeError(dataPt) { return [ computeErrorValueMinus(dataPt), diff --git a/src/components/errorbars/defaults.js b/src/components/errorbars/defaults.js index 39b8920b78a..c7cac1e653d 100644 --- a/src/components/errorbars/defaults.js +++ b/src/components/errorbars/defaults.js @@ -51,8 +51,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) { coerce('arrayminus'); coerce('tracerefminus'); } - } - else if(type === 'percent' || type === 'constant') { + } else if(type === 'percent' || type === 'constant') { coerce('value'); if(!symmetric) coerce('valueminus'); } diff --git a/src/components/errorbars/plot.js b/src/components/errorbars/plot.js index dd190e70efd..5e86fea073f 100644 --- a/src/components/errorbars/plot.js +++ b/src/components/errorbars/plot.js @@ -103,8 +103,7 @@ module.exports = function plot(gd, traces, plotinfo, transitionOpts) { } yerror.attr('d', path); - } - else yerror.remove(); + } else yerror.remove(); var xerror = errorbar.select('path.xerror'); if(xObj.visible && isNumeric(coords.y) && @@ -132,8 +131,7 @@ module.exports = function plot(gd, traces, plotinfo, transitionOpts) { } xerror.attr('d', path); - } - else xerror.remove(); + } else xerror.remove(); }); }); }; diff --git a/src/components/fx/click.js b/src/components/fx/click.js index 4d248c66799..4f0955d1771 100644 --- a/src/components/fx/click.js +++ b/src/components/fx/click.js @@ -27,8 +27,7 @@ module.exports = function click(gd, evt, subplot) { if(gd._hoverdata && evt && evt.target) { if(annotationsDone && annotationsDone.then) { annotationsDone.then(emitClick); - } - else emitClick(); + } else emitClick(); // why do we get a double event without this??? if(evt.stopImmediatePropagation) evt.stopImmediatePropagation(); diff --git a/src/components/fx/helpers.js b/src/components/fx/helpers.js index 2c169421b76..ef1db6bfc06 100644 --- a/src/components/fx/helpers.js +++ b/src/components/fx/helpers.js @@ -62,10 +62,8 @@ exports.getClosest = function getClosest(cd, distfn, pointData) { if(pointData.index !== false) { if(pointData.index >= 0 && pointData.index < cd.length) { pointData.distance = 0; - } - else pointData.index = false; - } - else { + } else pointData.index = false; + } else { // apply the distance function to each data point // this is the longest loop... if this bogs down, we may need // to create pre-sorted data (by x or y), not sure how to diff --git a/src/components/fx/hover.js b/src/components/fx/hover.js index ea96bdf8398..e9e1d9429ec 100644 --- a/src/components/fx/hover.js +++ b/src/components/fx/hover.js @@ -348,8 +348,7 @@ function _hover(gd, evt, subplot, noHoverEvent) { } } } - } - else { + } else { for(curvenum = 0; curvenum < gd.calcdata.length; curvenum++) { cd = gd.calcdata[curvenum]; trace = cd[0].trace; @@ -373,8 +372,7 @@ function _hover(gd, evt, subplot, noHoverEvent) { if('ypx' in evt) ypx = evt.ypx; else ypx = yaArray[0]._length / 2; - } - else { + } else { // fire the beforehover event and quit if it returns false // note that we're only calling this on real mouse events, so // manual calls to fx.hover will always run. @@ -501,8 +499,7 @@ function _hover(gd, evt, subplot, noHoverEvent) { if('pointNumber' in selection) { pointData.index = selection.pointNumber; mode = 'closest'; - } - else { + } else { mode = ''; if('xval' in selection) { xval = selection.xval; @@ -513,8 +510,7 @@ function _hover(gd, evt, subplot, noHoverEvent) { mode = mode ? 'closest' : 'y'; } } - } - else { + } else { xval = xvalArray[subploti]; yval = yvalArray[subploti]; } @@ -532,8 +528,7 @@ function _hover(gd, evt, subplot, noHoverEvent) { } } } - } - else { + } else { Lib.log('Unrecognized trace type in hover:', trace); } } @@ -862,8 +857,7 @@ function createHoverText(hoverData, opts, gd) { label.attr('transform', 'translate(' + (xa._offset + (c0.x0 + c0.x1) / 2) + ',' + (ya._offset + (xa.side === 'top' ? 0 : ya._length)) + ')'); - } - else { + } else { ltext.attr('text-anchor', ya.side === 'right' ? 'start' : 'end') .call(svgTextUtils.positionText, (ya.side === 'right' ? 1 : -1) * (HOVERTEXTPAD + HOVERARROWSIZE), @@ -949,14 +943,11 @@ function createHoverText(hoverData, opts, gd) { if(d.xLabel !== undefined) text += 'x: ' + d.xLabel + '
'; if(d.yLabel !== undefined) text += 'y: ' + d.yLabel + '
'; text += (text ? 'z: ' : '') + d.zLabel; - } - else if(showCommonLabel && d[hovermode + 'Label'] === t0) { + } else if(showCommonLabel && d[hovermode + 'Label'] === t0) { text = d[(hovermode === 'x' ? 'y' : 'x') + 'Label'] || ''; - } - else if(d.xLabel === undefined) { + } else if(d.xLabel === undefined) { if(d.yLabel !== undefined && d.trace.type !== 'scattercarpet') text = d.yLabel; - } - else if(d.yLabel === undefined) text = d.xLabel; + } else if(d.yLabel === undefined) text = d.xLabel; else text = '(' + d.xLabel + ', ' + d.yLabel + ')'; if((d.text || d.text === 0) && !Array.isArray(d.text)) { @@ -1067,8 +1058,7 @@ function createHoverText(hoverData, opts, gd) { hty += dy / 2; d.anchor = 'start'; } else d.anchor = 'middle'; - } - else { + } else { d.pos = hty; anchorStartOK = htx + dx / 2 + txTotalWidth <= outerWidth; anchorEndOK = htx - dx / 2 - txTotalWidth >= 0; @@ -1258,8 +1248,7 @@ function hoverAvoidOverlaps(hoverLabels, ax, fullLayout) { bottomOverlap = sumdp / g0.length; for(j = g0.length - 1; j >= 0; j--) g0[j].dp -= bottomOverlap; donepositioning = false; - } - else i++; + } else i++; } // check if we're going off the plot on either side and fix @@ -1410,8 +1399,7 @@ function cleanPoint(d, hovermode) { if(d.xerrneg !== undefined) { d.xLabel += ' +' + xeText + ' / -' + Axes.tickText(d.xa, d.xa.c2l(d.xerrneg), 'hover').text; - } - else d.xLabel += ' ± ' + xeText; + } else d.xLabel += ' ± ' + xeText; // small distance penalty for error bars, so that if there are // traces with errors and some without, the error bar label will @@ -1423,8 +1411,7 @@ function cleanPoint(d, hovermode) { if(d.yerrneg !== undefined) { d.yLabel += ' +' + yeText + ' / -' + Axes.tickText(d.ya, d.ya.c2l(d.yerrneg), 'hover').text; - } - else d.yLabel += ' ± ' + yeText; + } else d.yLabel += ' ± ' + yeText; if(hovermode === 'y') d.distance += 1; } diff --git a/src/components/fx/layout_defaults.js b/src/components/fx/layout_defaults.js index 9c26962c242..e0f04bc0f23 100644 --- a/src/components/fx/layout_defaults.js +++ b/src/components/fx/layout_defaults.js @@ -31,8 +31,7 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) { layoutOut._isHoriz = isHoriz(fullData, layoutOut); hovermodeDflt = layoutOut._isHoriz ? 'y' : 'x'; } - } - else hovermodeDflt = 'closest'; + } else hovermodeDflt = 'closest'; var hoverMode = coerce('hovermode', hovermodeDflt); if(hoverMode) { diff --git a/src/components/grid/index.js b/src/components/grid/index.js index 43838dcedd4..f6a71e241a7 100644 --- a/src/components/grid/index.js +++ b/src/components/grid/index.js @@ -196,8 +196,7 @@ function sizeDefaults(layoutIn, layoutOut) { if(hasSubplotGrid) { dfltRows = gridIn.subplots.length; dfltColumns = gridIn.subplots[0].length; - } - else { + } else { if(hasYaxes) dfltRows = yAxes.length; if(hasXaxes) dfltColumns = xAxes.length; } @@ -287,8 +286,7 @@ function contentDefaults(layoutIn, layoutOut) { if(useDefaultSubplots) { subplotId = (index === 1) ? 'xy' : ('x' + index + 'y' + index); index++; - } - else subplotId = rowIn[j]; + } else subplotId = rowIn[j]; rowOut[j] = ''; @@ -308,8 +306,7 @@ function contentDefaults(layoutIn, layoutOut) { } } } - } - else { + } else { var xAxes = getAxes(layoutOut, gridIn, 'x'); var yAxes = getAxes(layoutOut, gridIn, 'y'); gridOut.xaxes = fillGridAxes(xAxes, subplots.xaxis, columns, axisMap, 'x'); @@ -329,14 +326,12 @@ function contentDefaults(layoutIn, layoutOut) { // grid edge - ie not "* plot" - make these as free axes // since we're not guaranteed to have a subplot there at all anchors[axisId] = 'free'; - } - else if(axLetter === 'x') { + } else if(axLetter === 'x') { if((side.charAt(0) === 't') === reversed) { i0 = 0; inc = 1; iFinal = rows; - } - else { + } else { i0 = rows - 1; inc = -1; iFinal = -1; @@ -352,8 +347,7 @@ function contentDefaults(layoutIn, layoutOut) { break; } } - } - else { + } else { for(i = i0; i !== iFinal; i += inc) { yId = gridOut.yaxes[i]; if(subplots.cartesian.indexOf(axisId + yId) !== -1) { @@ -362,14 +356,12 @@ function contentDefaults(layoutIn, layoutOut) { } } } - } - else { + } else { if((side.charAt(0) === 'l')) { i0 = 0; inc = 1; iFinal = columns; - } - else { + } else { i0 = columns - 1; inc = -1; iFinal = -1; @@ -385,8 +377,7 @@ function contentDefaults(layoutIn, layoutOut) { break; } } - } - else { + } else { for(i = i0; i !== iFinal; i += inc) { xId = gridOut.xaxes[i]; if(subplots.cartesian.indexOf(xId + axisId) !== -1) { @@ -407,16 +398,14 @@ function fillGridAxes(axesIn, axesAllowed, len, axisMap, axLetter) { if(axesAllowed.indexOf(axisId) !== -1 && axisMap[axisId] === undefined) { out[i] = axisId; axisMap[axisId] = i; - } - else out[i] = ''; + } else out[i] = ''; } if(Array.isArray(axesIn)) { for(i = 0; i < len; i++) { fillOneAxis(i, axesIn[i]); } - } - else { + } else { // default axis list is the first `len` axis ids fillOneAxis(0, axLetter); for(i = 1; i < len; i++) { diff --git a/src/components/images/convert_coords.js b/src/components/images/convert_coords.js index 5377539dc4d..b0be0ce819b 100644 --- a/src/components/images/convert_coords.js +++ b/src/components/images/convert_coords.js @@ -61,8 +61,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { // is like sinh, and this one looks like arcsinh) var dx = currentSize / Math.pow(10, newPos) / 2; newSize = 2 * Math.log(dx + Math.sqrt(1 + dx * dx)) / Math.LN10; - } - else { + } else { newPos = Math.pow(10, currentPos); newSize = newPos * (Math.pow(10, currentSize / 2) - Math.pow(10, -currentSize / 2)); } @@ -71,8 +70,7 @@ module.exports = function convertCoords(gd, ax, newType, doExtra) { if(!isNumeric(newPos)) { newPos = null; newSize = null; - } - else if(!isNumeric(newSize)) newSize = null; + } else if(!isNumeric(newSize)) newSize = null; doExtra(attrPrefix + axLetter, newPos); doExtra(attrPrefix + 'size' + axLetter, newSize); diff --git a/src/components/legend/defaults.js b/src/components/legend/defaults.js index bb69af92f4b..c56da87077a 100644 --- a/src/components/legend/defaults.js +++ b/src/components/legend/defaults.js @@ -91,8 +91,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { defaultXAnchor = 'left'; defaultY = 1.1; defaultYAnchor = 'bottom'; - } - else { + } else { defaultX = 0; defaultXAnchor = 'left'; defaultY = -0.1; diff --git a/src/components/legend/draw.js b/src/components/legend/draw.js index b84ac666e17..1ded8cba129 100644 --- a/src/components/legend/draw.js +++ b/src/components/legend/draw.js @@ -158,15 +158,13 @@ module.exports = function draw(gd) { if(Lib.isRightAnchor(opts)) { lx -= opts._width; - } - else if(Lib.isCenterAnchor(opts)) { + } else if(Lib.isCenterAnchor(opts)) { lx -= opts._width / 2; } if(Lib.isBottomAnchor(opts)) { ly -= opts._height; - } - else if(Lib.isMiddleAnchor(opts)) { + } else if(Lib.isMiddleAnchor(opts)) { ly -= opts._height / 2; } @@ -177,8 +175,7 @@ module.exports = function draw(gd) { if(legendWidth > legendWidthMax) { lx = gs.l; legendWidth = legendWidthMax; - } - else { + } else { if(lx + legendWidth > lxMax) lx = lxMax - legendWidth; if(lx < lxMin) lx = lxMin; legendWidth = Math.min(lxMax - lx, opts._width); @@ -193,8 +190,7 @@ module.exports = function draw(gd) { if(legendHeight > legendHeightMax) { ly = gs.t; legendHeight = legendHeightMax; - } - else { + } else { if(ly + legendHeight > lyMax) ly = lyMax - legendHeight; if(ly < lyMin) ly = lyMin; legendHeight = Math.min(lyMax - ly, opts._height); @@ -230,8 +226,7 @@ module.exports = function draw(gd) { Drawing.setRect(scrollBar, 0, 0, 0, 0); delete opts._scrollY; - } - else { + } else { var scrollBarHeight = Math.max(constants.scrollBarMinHeight, legendHeight * legendHeight / opts._height); var scrollBarYMax = legendHeight - @@ -391,8 +386,7 @@ function clickOrDoubleClick(gd, legend, legendItem, numClicks, evt) { legend._clickTimeout = setTimeout(function() { handleClick(legendItem, gd, numClicks); }, DBLCLICKDELAY); - } - else if(numClicks === 2) { + } else if(numClicks === 2) { if(legend._clickTimeout) clearTimeout(legend._clickTimeout); gd._legendMouseDownTime = 0; @@ -489,8 +483,7 @@ function setupTraceToggle(g, gd) { if(newMouseDownTime - gd._legendMouseDownTime < DBLCLICKDELAY) { // in a click train numClicks += 1; - } - else { + } else { // new click train numClicks = 1; gd._legendMouseDownTime = newMouseDownTime; @@ -589,8 +582,7 @@ function computeLegendDimensions(gd, groups, traces) { } extraWidth = 40; - } - else if(isGrouped) { + } else if(isGrouped) { var maxHeight = 0; var maxWidth = 0; var groupData = groups.data(); @@ -663,8 +655,7 @@ function computeLegendDimensions(gd, groups, traces) { var maxOffset = Math.max.apply(null, groupXOffsets); opts._width = maxOffset + maxWidth + 40; opts._width += borderwidth * 2; - } - else { + } else { var rowHeight = 0; var maxTraceHeight = 0; var maxTraceWidth = 0; @@ -742,16 +733,14 @@ function expandMargin(gd) { var xanchor = 'left'; if(Lib.isRightAnchor(opts)) { xanchor = 'right'; - } - else if(Lib.isCenterAnchor(opts)) { + } else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } var yanchor = 'top'; if(Lib.isBottomAnchor(opts)) { yanchor = 'bottom'; - } - else if(Lib.isMiddleAnchor(opts)) { + } else if(Lib.isMiddleAnchor(opts)) { yanchor = 'middle'; } @@ -773,8 +762,7 @@ function expandHorizontalMargin(gd) { var xanchor = 'left'; if(Lib.isRightAnchor(opts)) { xanchor = 'right'; - } - else if(Lib.isCenterAnchor(opts)) { + } else if(Lib.isCenterAnchor(opts)) { xanchor = 'center'; } diff --git a/src/components/legend/get_legend_data.js b/src/components/legend/get_legend_data.js index b51e0326917..2c2c7cd1190 100644 --- a/src/components/legend/get_legend_data.js +++ b/src/components/legend/get_legend_data.js @@ -29,13 +29,11 @@ module.exports = function getLegendData(calcdata, opts) { lgroups.push(uniqueGroup); lgroupToTraces[uniqueGroup] = [[legendItem]]; lgroupi++; - } - else if(lgroups.indexOf(legendGroup) === -1) { + } else if(lgroups.indexOf(legendGroup) === -1) { lgroups.push(legendGroup); hasOneNonBlankGroup = true; lgroupToTraces[legendGroup] = [[legendItem]]; - } - else lgroupToTraces[legendGroup].push([legendItem]); + } else lgroupToTraces[legendGroup].push([legendItem]); } // build an { legendgroup: [cd0, cd0], ... } object @@ -65,9 +63,7 @@ module.exports = function getLegendData(calcdata, opts) { slicesShown[lgroup][labelj] = true; } } - } - - else addOneItem(lgroup, cd0); + } else addOneItem(lgroup, cd0); } // won't draw a legend in this case @@ -85,8 +81,7 @@ module.exports = function getLegendData(calcdata, opts) { ltraces = lgroupToTraces[lgroups[i]]; legendData[i] = helpers.isReversed(opts) ? ltraces.reverse() : ltraces; } - } - else { + } else { // collapse all groups into one if all groups are blank legendData = [new Array(lgroupsLength)]; diff --git a/src/components/modebar/buttons.js b/src/components/modebar/buttons.js index 9c554d328a6..654d2868939 100644 --- a/src/components/modebar/buttons.js +++ b/src/components/modebar/buttons.js @@ -209,8 +209,7 @@ function handleCartesian(gd, ev) { else if(val === 'reset') { if(ax._rangeInitial === undefined) { aobj[axName + '.autorange'] = true; - } - else { + } else { var rangeInitial = ax._rangeInitial.slice(); aobj[axName + '.range[0]'] = rangeInitial[0]; aobj[axName + '.range[1]'] = rangeInitial[1]; @@ -221,8 +220,7 @@ function handleCartesian(gd, ev) { allSpikesEnabled = 'off'; } } - } - else { + } else { var rangeNow = [ ax.r2l(ax.range[0]), ax.r2l(ax.range[1]), @@ -239,8 +237,7 @@ function handleCartesian(gd, ev) { } } fullLayout._cartesianSpikesEnabled = allSpikesEnabled; - } - else { + } else { // if ALL traces have orientation 'h', 'hovermode': 'x' otherwise: 'y' if(astr === 'hovermode' && (val === 'x' || val === 'y')) { val = fullLayout._isHoriz ? 'y' : 'x'; @@ -385,8 +382,7 @@ function getNextHover3d(gd, ev) { if(val) { layoutUpdate = val; button._previousVal = null; - } - else { + } else { for(var i = 0; i < sceneIds.length; i++) { var sceneId = sceneIds[i]; var sceneLayout = fullLayout[sceneId]; diff --git a/src/components/modebar/manage.js b/src/components/modebar/manage.js index bf7ac7dc255..7a22f8f40a9 100644 --- a/src/components/modebar/manage.js +++ b/src/components/modebar/manage.js @@ -56,11 +56,9 @@ module.exports = function manageModeBar(gd) { if(Array.isArray(customButtons) && customButtons.length) { buttonGroups = fillCustomButton(customButtons); - } - else if(!context.displayModeBar && context.watermark) { + } else if(!context.displayModeBar && context.watermark) { buttonGroups = []; - } - else { + } else { buttonGroups = getButtonGroups( gd, context.modeBarButtonsToRemove, @@ -120,31 +118,24 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) { // which reset the view or toggle hover labels across all subplots. hoverGroup = ['toggleHover']; resetGroup = ['resetViews']; - } - else if(hasGeo) { + } else if(hasGeo) { zoomGroup = ['zoomInGeo', 'zoomOutGeo']; hoverGroup = ['hoverClosestGeo']; resetGroup = ['resetGeo']; - } - else if(hasGL3D) { + } else if(hasGL3D) { hoverGroup = ['hoverClosest3d']; resetGroup = ['resetCameraDefault3d', 'resetCameraLastSave3d']; - } - else if(hasMapbox) { + } else if(hasMapbox) { hoverGroup = ['toggleHover']; resetGroup = ['resetViewMapbox']; - } - else if(hasGL2D) { + } else if(hasGL2D) { hoverGroup = ['hoverClosestGl2d']; - } - else if(hasPie) { + } else if(hasPie) { hoverGroup = ['hoverClosestPie']; - } - else if(hasSankey) { + } else if(hasSankey) { hoverGroup = ['hoverClosestCartesian', 'hoverCompareCartesian']; resetGroup = ['resetViewSankey']; - } - else { // hasPolar, hasTernary + } else { // hasPolar, hasTernary // always show at least one hover icon. hoverGroup = ['toggleHover']; } @@ -162,14 +153,11 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd, showSendToCloud) { if(hasGL3D) { dragModeGroup = ['zoom3d', 'pan3d', 'orbitRotation', 'tableRotation']; - } - else if(((hasCartesian || hasGL2D) && !allAxesFixed) || hasTernary) { + } else if(((hasCartesian || hasGL2D) && !allAxesFixed) || hasTernary) { dragModeGroup = ['zoom2d', 'pan2d']; - } - else if(hasMapbox || hasGeo) { + } else if(hasMapbox || hasGeo) { dragModeGroup = ['pan2d']; - } - else if(hasPolar) { + } else if(hasPolar) { dragModeGroup = ['zoom2d']; } if(isSelectable(fullData)) { @@ -215,11 +203,13 @@ function isSelectable(fullData) { if(trace.boxpoints === 'all' || trace.points === 'all') { selectable = true; } + } else { + // assume that in general if the trace module has selectPoints, + // then it's selectable. Scatter is an exception to this because it must + // have markers or text, not just be a scatter type. + + selectable = true; } - // assume that in general if the trace module has selectPoints, - // then it's selectable. Scatter is an exception to this because it must - // have markers or text, not just be a scatter type. - else selectable = true; } return selectable; @@ -231,8 +221,7 @@ function appendButtonsToGroups(groups, buttons) { for(var i = 0; i < buttons.length; i++) { groups.push(buttons[i]); } - } - else groups.push(buttons); + } else groups.push(buttons); } return groups; @@ -249,8 +238,7 @@ function fillCustomButton(customButtons) { if(typeof button === 'string') { if(modeBarButtons[button] !== undefined) { customButtons[i][j] = modeBarButtons[button]; - } - else { + } else { throw new Error([ '*modeBarButtons* configuration options', 'invalid button name' diff --git a/src/components/modebar/modebar.js b/src/components/modebar/modebar.js index 679218fadec..de02f8b7091 100644 --- a/src/components/modebar/modebar.js +++ b/src/components/modebar/modebar.js @@ -169,8 +169,7 @@ proto.createButton = function(config) { var click = config.click; if(typeof click !== 'function') { throw new Error('must provide button \'click\' function in button config'); - } - else { + } else { button.addEventListener('click', function(ev) { config.click(_this.graphInfo, ev); @@ -185,8 +184,7 @@ proto.createButton = function(config) { var icon = config.icon; if(typeof icon === 'function') { button.appendChild(icon()); - } - else { + } else { button.appendChild(this.createIcon(icon || Icons.question)); } button.setAttribute('data-gravity', config.gravity || 'n'); @@ -219,8 +217,7 @@ proto.createIcon = function(thisIcon) { if(thisIcon.transform) { path.setAttribute('transform', thisIcon.transform); - } - else if(thisIcon.ascent !== undefined) { + } else if(thisIcon.ascent !== undefined) { // Legacy icon transform calculation path.setAttribute('transform', 'matrix(1 0 0 -1 0 ' + thisIcon.ascent + ')'); } @@ -262,8 +259,7 @@ proto.updateActiveButton = function(buttonClicked) { if(dataAttr === dataAttrClicked) { button3.classed('active', !button3.classed('active')); } - } - else { + } else { var val = (dataAttr === null) ? dataAttr : Lib.nestedProperty(fullLayout, dataAttr).get(); diff --git a/src/components/rangeselector/defaults.js b/src/components/rangeselector/defaults.js index 8942a65c501..17cc116c010 100644 --- a/src/components/rangeselector/defaults.js +++ b/src/components/rangeselector/defaults.js @@ -64,8 +64,7 @@ function buttonDefaults(buttonIn, buttonOut, selectorOut, opts) { if(step !== 'all') { if(calendar && calendar !== 'gregorian' && (step === 'month' || step === 'year')) { buttonOut.stepmode = 'backward'; - } - else { + } else { coerce('stepmode'); } diff --git a/src/components/rangeselector/draw.js b/src/components/rangeselector/draw.js index 79378a4f5fa..927e982516b 100644 --- a/src/components/rangeselector/draw.js +++ b/src/components/rangeselector/draw.js @@ -107,8 +107,7 @@ function selectorKeyFunc(d) { function isActive(axisLayout, opts, update) { if(opts.step === 'all') { return axisLayout.autorange === true; - } - else { + } else { var keys = Object.keys(update); return ( diff --git a/src/components/rangeselector/get_update_object.js b/src/components/rangeselector/get_update_object.js index 4ab487cce08..cbc7d4d7254 100644 --- a/src/components/rangeselector/get_update_object.js +++ b/src/components/rangeselector/get_update_object.js @@ -17,8 +17,7 @@ module.exports = function getUpdateObject(axisLayout, buttonLayout) { if(buttonLayout.step === 'all') { update[axName + '.autorange'] = true; - } - else { + } else { var xrange = getXRange(axisLayout, buttonLayout); update[axName + '.range[0]'] = xrange[0]; diff --git a/src/components/shapes/defaults.js b/src/components/shapes/defaults.js index 5e645650826..1d16342b4bc 100644 --- a/src/components/shapes/defaults.js +++ b/src/components/shapes/defaults.js @@ -64,8 +64,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { ax._shapeIndices.push(shapeOut._index); r2pos = helpers.rangeToShapePosition(ax); pos2r = helpers.shapePositionToRange(ax); - } - else { + } else { pos2r = r2pos = Lib.identity; } @@ -116,8 +115,7 @@ function handleShapeDefaults(shapeIn, shapeOut, fullLayout) { if(shapeType === 'path') { coerce('path'); - } - else { + } else { Lib.noneOrAll(shapeIn, shapeOut, ['x0', 'x1', 'y0', 'y1']); } } diff --git a/src/components/shapes/draw.js b/src/components/shapes/draw.js index 9af5c7cf27e..556920c80a9 100644 --- a/src/components/shapes/draw.js +++ b/src/components/shapes/draw.js @@ -74,17 +74,14 @@ function drawOne(gd, index) { if(options.layer !== 'below') { drawShape(gd._fullLayout._shapeUpperLayer); - } - else if(options.xref === 'paper' || options.yref === 'paper') { + } else if(options.xref === 'paper' || options.yref === 'paper') { drawShape(gd._fullLayout._shapeLowerLayer); - } - else { + } else { var plotinfo = gd._fullLayout._plots[options.xref + options.yref]; if(plotinfo) { var mainPlot = plotinfo.mainplotinfo || plotinfo; drawShape(mainPlot.shapelayer); - } - else { + } else { // Fall back to _shapeLowerLayer in case the requested subplot doesn't exist. // This can happen if you reference the shape to an x / y axis combination // that doesn't have any data on it (and layer is below) @@ -257,8 +254,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { if(shapeOptions.type === 'path') { pathIn = shapeOptions.path; - } - else { + } else { x0 = xPixelSized ? shapeOptions.x0 : x2p(shapeOptions.x0); y0 = yPixelSized ? shapeOptions.y0 : y2p(shapeOptions.y0); x1 = xPixelSized ? shapeOptions.x1 : x2p(shapeOptions.x1); @@ -270,8 +266,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { optW = 'x0'; e0 = x1; optE = 'x1'; - } - else { + } else { w0 = x1; optW = 'x1'; e0 = x0; @@ -285,8 +280,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { optN = 'y0'; s0 = y1; optS = 'y1'; - } - else { + } else { n0 = y1; optN = 'y1'; s0 = y0; @@ -334,8 +328,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { } modifyItem('path', shapeOptions.path = movePath(pathIn, moveX, moveY)); - } - else { + } else { if(xPixelSized) { modifyItem('xanchor', shapeOptions.xanchor = p2x(xAnchor + dx)); } else { @@ -377,8 +370,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { } modifyItem('path', shapeOptions.path = movePath(pathIn, moveX, moveY)); - } - else if(isLine) { + } else if(isLine) { if(dragMode === 'resize-over-start-point') { var newX0 = x0 + dx; var newY0 = yPixelSized ? y0 - dy : y0 + dy; @@ -390,8 +382,7 @@ function setupDragElement(gd, shapePath, shapeOptions, index, shapeLayer) { modifyItem('x1', shapeOptions.x1 = xPixelSized ? newX1 : p2x(newX1)); modifyItem('y1', shapeOptions.y1 = yPixelSized ? newY1 : p2y(newY1)); } - } - else { + } else { var newN = (~dragMode.indexOf('n')) ? n0 + dy : n0; var newS = (~dragMode.indexOf('s')) ? s0 + dy : s0; var newW = (~dragMode.indexOf('w')) ? w0 + dx : w0; @@ -512,16 +503,14 @@ function getPathString(gd, options) { if(xa) { x2r = helpers.shapePositionToRange(xa); x2p = function(v) { return xa._offset + xa.r2p(x2r(v, true)); }; - } - else { + } else { x2p = function(v) { return gs.l + gs.w * v; }; } if(ya) { y2r = helpers.shapePositionToRange(ya); y2p = function(v) { return ya._offset + ya.r2p(y2r(v, true)); }; - } - else { + } else { y2p = function(v) { return gs.t + gs.h * (1 - v); }; } @@ -535,8 +524,7 @@ function getPathString(gd, options) { var xAnchorPos = x2p(options.xanchor); x0 = xAnchorPos + options.x0; x1 = xAnchorPos + options.x1; - } - else { + } else { x0 = x2p(options.x0); x1 = x2p(options.x1); } @@ -545,8 +533,7 @@ function getPathString(gd, options) { var yAnchorPos = y2p(options.yanchor); y0 = yAnchorPos - options.y0; y1 = yAnchorPos - options.y1; - } - else { + } else { y0 = y2p(options.y0); y1 = y2p(options.y1); } @@ -585,8 +572,7 @@ function convertPath(options, x2p, y2p) { if(xParams[paramNumber]) { if(xSizemode === 'pixel') param = x2p(xAnchor) + Number(param); else param = x2p(param); - } - else if(yParams[paramNumber]) { + } else if(yParams[paramNumber]) { if(ySizemode === 'pixel') param = y2p(yAnchor) - Number(param); else param = y2p(param); } diff --git a/src/components/shapes/helpers.js b/src/components/shapes/helpers.js index b2e754d4448..61016b293ae 100644 --- a/src/components/shapes/helpers.js +++ b/src/components/shapes/helpers.js @@ -70,11 +70,9 @@ exports.getDataToPixel = function(gd, axis, isVertical) { }; if(axis.type === 'date') dataToPixel = exports.decodeDate(dataToPixel); - } - else if(isVertical) { + } else if(isVertical) { dataToPixel = function(v) { return gs.t + gs.h * (1 - v); }; - } - else { + } else { dataToPixel = function(v) { return gs.l + gs.w * v; }; } @@ -88,11 +86,9 @@ exports.getPixelToData = function(gd, axis, isVertical) { if(axis) { var r2d = exports.rangeToShapePosition(axis); pixelToData = function(p) { return r2d(axis.p2r(p - axis._offset)); }; - } - else if(isVertical) { + } else if(isVertical) { pixelToData = function(p) { return 1 - (p - gs.t) / gs.h; }; - } - else { + } else { pixelToData = function(p) { return (p - gs.l) / gs.w; }; } diff --git a/src/components/sliders/defaults.js b/src/components/sliders/defaults.js index ddbf355046d..099784bf0ae 100644 --- a/src/components/sliders/defaults.js +++ b/src/components/sliders/defaults.js @@ -101,8 +101,7 @@ function stepDefaults(valueIn, valueOut) { var visible; if(valueIn.method !== 'skip' && !Array.isArray(valueIn.args)) { visible = valueOut.visible = false; - } - else visible = coerce('visible'); + } else visible = coerce('visible'); if(visible) { coerce('method'); diff --git a/src/components/sliders/draw.js b/src/components/sliders/draw.js index 53a35a94678..f411ce7f909 100644 --- a/src/components/sliders/draw.js +++ b/src/components/sliders/draw.js @@ -241,8 +241,7 @@ function findDimensions(gd, sliderOpts) { marginOpts.xl = sliderOpts.x - sliderOpts.len * FROM_TL[xanchor]; marginOpts.r = 0; marginOpts.xr = sliderOpts.x + sliderOpts.len * FROM_BR[xanchor]; - } - else { + } else { marginOpts.x = sliderOpts.x; marginOpts.l = dims.outerLength * FROM_TL[xanchor]; marginOpts.r = dims.outerLength * FROM_BR[xanchor]; diff --git a/src/components/updatemenus/draw.js b/src/components/updatemenus/draw.js index d72332f679a..d5737704bf2 100644 --- a/src/components/updatemenus/draw.js +++ b/src/components/updatemenus/draw.js @@ -162,8 +162,7 @@ function setActive(gd, menuOpts, buttonOpts, gHeader, gButton, scrollBox, button if(menuOpts.type === 'buttons') { drawButtons(gd, gHeader, null, null, menuOpts); - } - else if(menuOpts.type === 'dropdown') { + } else if(menuOpts.type === 'dropdown') { // fold up buttons and redraw header gButton.attr(constants.menuIndexAttrName, '-1'); @@ -331,8 +330,7 @@ function drawButtons(gd, gHeader, gButton, scrollBox, menuOpts) { if(isVertical) { scrollBoxPosition.w = Math.max(dims.openWidth, dims.headerWidth); scrollBoxPosition.h = posOpts.y - scrollBoxPosition.t; - } - else { + } else { scrollBoxPosition.w = posOpts.x - scrollBoxPosition.l; scrollBoxPosition.h = Math.max(dims.openHeight, dims.headerHeight); } @@ -342,8 +340,7 @@ function drawButtons(gd, gHeader, gButton, scrollBox, menuOpts) { if(scrollBox) { if(buttons.size()) { drawScrollBox(gd, gHeader, gButton, scrollBox, menuOpts, scrollBoxPosition); - } - else { + } else { hideScrollBox(scrollBox); } } @@ -363,8 +360,7 @@ function drawScrollBox(gd, gHeader, gButton, scrollBox, menuOpts, position) { for(i = 0; i < active; i++) { translateY += dims.heights[i] + constants.gapButton; } - } - else { + } else { translateX = 0; for(i = 0; i < active; i++) { translateX += dims.widths[i] + constants.gapButton; diff --git a/src/components/updatemenus/scrollbox.js b/src/components/updatemenus/scrollbox.js index f34921ae0ab..d43b2516608 100644 --- a/src/components/updatemenus/scrollbox.js +++ b/src/components/updatemenus/scrollbox.js @@ -115,15 +115,13 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { boxT = t; boxB = Math.min(boxT + boxH, fullHeight); boxH = boxB - boxT; - } - else { + } else { // anchor to bottom side boxB = t + boxH; boxT = Math.max(boxB - boxH, 0); boxH = boxB - boxT; } - } - else { + } else { boxT = t; boxB = boxT + boxH; @@ -132,8 +130,7 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { boxR = l + boxW; boxL = Math.max(boxR - boxW, 0); boxW = boxR - boxL; - } - else { + } else { // anchor to left side boxL = l; boxR = Math.min(boxL + boxW, fullWidth); @@ -182,8 +179,7 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { // hbar center moves between hbarXMin and hbarXMin + hbarTranslateMax this._hbarXMin = hbarL + hbarW / 2; this._hbarTranslateMax = boxW - hbarW; - } - else { + } else { delete this.hbar; delete this._hbarXMin; delete this._hbarTranslateMax; @@ -223,8 +219,7 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { // vbar center moves between vbarYMin and vbarYMin + vbarTranslateMax this._vbarYMin = vbarT + vbarH / 2; this._vbarTranslateMax = boxH - vbarH; - } - else { + } else { delete this.vbar; delete this._vbarYMin; delete this._vbarTranslateMax; @@ -262,8 +257,7 @@ ScrollBox.prototype.enable = function enable(position, translateX, translateY) { width: w, height: h }); - } - else { + } else { this.bg.attr({ width: 0, height: 0 diff --git a/src/lib/array.js b/src/lib/array.js index 925fe01de1a..927c8fa83b5 100644 --- a/src/lib/array.js +++ b/src/lib/array.js @@ -89,13 +89,11 @@ exports.concat = function() { if(isArray(argi)) { _constructor = false; - } - else { + } else { allArray = false; if(!totalLen) { _constructor = argi.constructor; - } - else if(_constructor !== argi.constructor) { + } else if(_constructor !== argi.constructor) { // TODO: in principle we could upgrade here, // ie keep typed array but convert all to Float64Array? _constructor = false; diff --git a/src/lib/coerce.js b/src/lib/coerce.js index e470f5b4dc2..ce23b33763f 100644 --- a/src/lib/coerce.js +++ b/src/lib/coerce.js @@ -86,8 +86,7 @@ exports.valObjectMeta = { (opts.min !== undefined && v < opts.min) || (opts.max !== undefined && v > opts.max)) { propOut.set(dflt); - } - else propOut.set(+v); + } else propOut.set(+v); } }, integer: { @@ -103,8 +102,7 @@ exports.valObjectMeta = { (opts.min !== undefined && v < opts.min) || (opts.max !== undefined && v > opts.max)) { propOut.set(dflt); - } - else propOut.set(+v); + } else propOut.set(+v); } }, string: { @@ -122,8 +120,7 @@ exports.valObjectMeta = { if(opts.strict === true || !okToCoerce) propOut.set(dflt); else propOut.set(String(v)); - } - else if(opts.noBlank && !v) propOut.set(dflt); + } else if(opts.noBlank && !v) propOut.set(dflt); else propOut.set(v); } }, @@ -239,8 +236,7 @@ exports.valObjectMeta = { var vi = vParts[i]; if(opts.flags.indexOf(vi) === -1 || vParts.indexOf(vi) < i) { vParts.splice(i, 1); - } - else i++; + } else i++; } if(!vParts.length) propOut.set(dflt); else propOut.set(vParts.join('+')); @@ -314,8 +310,7 @@ exports.valObjectMeta = { if(vNew !== undefined) vOut[i][j] = vNew; } } - } - else { + } else { for(i = 0; i < len; i++) { vNew = coercePart(v[i], arrayItems ? items[i] : items, dflt[i]); if(vNew !== undefined) vOut[i] = vNew; @@ -345,8 +340,7 @@ exports.valObjectMeta = { return false; } } - } - else if(!validate(v[i], arrayItems ? items[i] : items)) return false; + } else if(!validate(v[i], arrayItems ? items[i] : items)) return false; } return true; diff --git a/src/lib/dates.js b/src/lib/dates.js index 5a159a84d3c..1000378878f 100644 --- a/src/lib/dates.js +++ b/src/lib/dates.js @@ -52,8 +52,7 @@ exports.dateTick0 = function(calendar, sunday) { return sunday ? Registry.getComponentMethod('calendars', 'CANONICAL_SUNDAY')[calendar] : Registry.getComponentMethod('calendars', 'CANONICAL_TICK')[calendar]; - } - else { + } else { return sunday ? '2000-01-02' : '2000-01-01'; } }; @@ -64,8 +63,7 @@ exports.dateTick0 = function(calendar, sunday) { exports.dfltRange = function(calendar) { if(isWorldCalendar(calendar)) { return Registry.getComponentMethod('calendars', 'DFLTRANGE')[calendar]; - } - else { + } else { return ['2000-01-01', '2001-01-01']; } }; @@ -189,12 +187,10 @@ exports.dateTime2ms = function(s, calendar) { var isIntercalary = m.charAt(m.length - 1) === 'i'; m = parseInt(m, 10); cDate = calInstance.newDate(y, calInstance.toMonthIndex(y, m, isIntercalary), d); - } - else { + } else { cDate = calInstance.newDate(y, Number(m), d); } - } - catch(e) { return BADNUM; } // Invalid ... date + } catch(e) { return BADNUM; } // Invalid ... date if(!cDate) return BADNUM; @@ -204,8 +200,7 @@ exports.dateTime2ms = function(s, calendar) { if(y.length === 2) { y = (Number(y) + 2000 - YFIRST) % 100 + YFIRST; - } - else y = Number(y); + } else y = Number(y); // new Date uses months from 0; subtract 1 here just so we // don't have to do it again during the validity test below @@ -282,8 +277,7 @@ exports.ms2DateTime = function(ms, r, calendar) { m = (r < NINETYDAYS) ? Math.floor((timeMs % ONEHOUR) / ONEMIN) : 0; s = (r < THREEHOURS) ? Math.floor((timeMs % ONEMIN) / ONESEC) : 0; msec10 = (r < FIVEMIN) ? (timeMs % ONESEC) * 10 + msecTenths : 0; - } - else { + } else { d = new Date(msRounded); dateStr = utcFormat('%Y-%m-%d')(d); @@ -358,8 +352,7 @@ exports.cleanDate = function(v, dflt, calendar) { // that is: '2012' -> Jan. 1, 2012, but 2012 -> 2012 epoch milliseconds v = exports.ms2DateTimeLocal(+v); if(!v && dflt !== undefined) return dflt; - } - else if(!exports.isDateTime(v, calendar)) { + } else if(!exports.isDateTime(v, calendar)) { Loggers.error('unrecognized date', v); return dflt; } @@ -390,8 +383,7 @@ function modDateFormat(fmt, x, formatter, calendar) { if(isWorldCalendar(calendar)) { try { fmt = Registry.getComponentMethod('calendars', 'worldCalFmt')(fmt, x, calendar); - } - catch(e) { + } catch(e) { return 'Invalid'; } } @@ -466,8 +458,7 @@ exports.formatDate = function(x, fmt, tr, formatter, calendar, extraFormat) { else if(tr === 'm') fmt = extraFormat.month; else if(tr === 'd') { fmt = extraFormat.dayMonth + '\n' + extraFormat.year; - } - else { + } else { return formatTime(x, tr) + '\n' + modDateFormat(extraFormat.dayMonthYear, x, formatter, calendar); } } @@ -568,20 +559,16 @@ exports.findExactDates = function(data, calendar) { if(d.day() === 1) { if(d.month() === 1) exactYears++; else exactMonths++; - } - else exactDays++; - } - catch(e) { + } else exactDays++; + } catch(e) { // invalid date in this calendar - ignore it here. } - } - else { + } else { d = new Date(di); if(d.getUTCDate() === 1) { if(d.getUTCMonth() === 0) exactYears++; else exactMonths++; - } - else exactDays++; + } else exactDays++; } } exactMonths += exactYears; diff --git a/src/lib/extend.js b/src/lib/extend.js index a9e7c12b810..d6748f3da3b 100644 --- a/src/lib/extend.js +++ b/src/lib/extend.js @@ -84,13 +84,13 @@ function _extend(inputs, isDeep, keepAllKeys, noArrayCopies) { src = target[key]; copy = input[key]; - // Stop early and just transfer the array if array copies are disallowed: if(noArrayCopies && isArray(copy)) { + // Stop early and just transfer the array if array copies are disallowed: + target[key] = copy; - } + } else if(isDeep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { + // recurse if we're merging plain objects or arrays - // recurse if we're merging plain objects or arrays - else if(isDeep && copy && (isPlainObject(copy) || (copyIsArray = isArray(copy)))) { if(copyIsArray) { copyIsArray = false; clone = src && isArray(src) ? src : []; @@ -100,10 +100,9 @@ function _extend(inputs, isDeep, keepAllKeys, noArrayCopies) { // never move original objects, clone them target[key] = _extend([clone, copy], isDeep, keepAllKeys, noArrayCopies); - } + } else if(typeof copy !== 'undefined' || keepAllKeys) { + // don't bring in undefined values, except for extendDeepAll - // don't bring in undefined values, except for extendDeepAll - else if(typeof copy !== 'undefined' || keepAllKeys) { target[key] = copy; } } diff --git a/src/lib/geometry2d.js b/src/lib/geometry2d.js index 5a343e21fb7..2bb298f626b 100644 --- a/src/lib/geometry2d.js +++ b/src/lib/geometry2d.js @@ -70,14 +70,12 @@ function perpDistance2(xab, yab, llab, xac, yac) { if(fcAB < 0) { // point c is closer to point a return xac * xac + yac * yac; - } - else if(fcAB > llab) { + } else if(fcAB > llab) { // point c is closer to point b var xbc = xac - xab; var ybc = yac - yab; return xbc * xbc + ybc * ybc; - } - else { + } else { // perpendicular distance is the shortest var crossProduct = xac * yab - yac * xab; return crossProduct * crossProduct / llab; diff --git a/src/lib/get_graph_div.js b/src/lib/get_graph_div.js index cc91ab80994..ea7e614cce3 100644 --- a/src/lib/get_graph_div.js +++ b/src/lib/get_graph_div.js @@ -27,8 +27,7 @@ module.exports = function(gd) { } return gdElement; - } - else if(gd === null || gd === undefined) { + } else if(gd === null || gd === undefined) { throw new Error('DOM element provided is null or undefined'); } diff --git a/src/lib/gl_format_color.js b/src/lib/gl_format_color.js index 35be62a2b7e..cfa7a587aa6 100644 --- a/src/lib/gl_format_color.js +++ b/src/lib/gl_format_color.js @@ -50,8 +50,7 @@ function formatColor(containerIn, opacityIn, len) { sclFunc = Colorscale.makeColorScaleFunc( Colorscale.extractScale(containerIn, {cLetter: 'c'}) ); - } - else { + } else { sclFunc = validateColor; } @@ -60,15 +59,13 @@ function formatColor(containerIn, opacityIn, len) { // FIXME: there is double work, considering that sclFunc does the opposite return c[i] === undefined ? colorDfltRgba : rgba(sclFunc(c[i])); }; - } - else getColor = validateColor; + } else getColor = validateColor; if(isArrayOpacityIn) { getOpacity = function(o, i) { return o[i] === undefined ? opacityDflt : validateOpacity(o[i]); }; - } - else getOpacity = validateOpacity; + } else getOpacity = validateOpacity; if(isArrayColorIn || isArrayOpacityIn) { for(var i = 0; i < len; i++) { @@ -76,8 +73,7 @@ function formatColor(containerIn, opacityIn, len) { opacityi = getOpacity(opacityIn, i); colorOut[i] = calculateColor(colori, opacityi); } - } - else colorOut = calculateColor(rgba(colorIn), opacityIn); + } else colorOut = calculateColor(rgba(colorIn), opacityIn); return colorOut; } diff --git a/src/lib/index.js b/src/lib/index.js index 9c9ef6094d7..772ff06f34b 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -302,8 +302,7 @@ lib.randstr = function randstr(existing, bits, base, _recursion) { return res; } return randstr(existing, bits, base, (_recursion || 0) + 1); - } - else return res; + } else return res; }; lib.OptionControl = function(opt, optname) { @@ -649,8 +648,7 @@ lib.minExtend = function(obj1, obj2) { } else { objOut[k] = v.slice(0, arrayLen); } - } - else if(v && (typeof v === 'object')) objOut[k] = lib.minExtend(obj1[k], obj2[k]); + } else if(v && (typeof v === 'object')) objOut[k] = lib.minExtend(obj1[k], obj2[k]); else objOut[k] = v; } @@ -716,11 +714,9 @@ lib.addRelatedStyleRule = function(uid, selector, styleString) { if(styleSheet.insertRule) { styleSheet.insertRule(selector + '{' + styleString + '}', 0); - } - else if(styleSheet.addRule) { + } else if(styleSheet.addRule) { styleSheet.addRule(selector, styleString, 0); - } - else lib.warn('addStyleRule failed'); + } else lib.warn('addStyleRule failed'); }; /** diff --git a/src/lib/loggers.js b/src/lib/loggers.js index ad6e8f756a4..0e4e4706ef6 100644 --- a/src/lib/loggers.js +++ b/src/lib/loggers.js @@ -67,16 +67,14 @@ function apply(f, args) { // applying a method of the console object. f.apply(console, args); return; - } - catch(e) { /* in case apply failed, fall back on the code below */ } + } catch(e) { /* in case apply failed, fall back on the code below */ } } // no apply - just try calling the function on each arg independently for(var i = 0; i < args.length; i++) { try { f(args[i]); - } - catch(e) { + } catch(e) { // still fails - last resort simple console.log console.log(args[i]); } diff --git a/src/lib/matrix.js b/src/lib/matrix.js index a0a7c93b310..20f9fec3e47 100644 --- a/src/lib/matrix.js +++ b/src/lib/matrix.js @@ -49,14 +49,12 @@ exports.dot = function(x, y) { // mat-vec or mat-mat out = new Array(len); for(i = 0; i < len; i++) out[i] = exports.dot(x[i], y); - } - else if(y[0].length) { + } else if(y[0].length) { // vec-mat var yTranspose = exports.transposeRagged(y); out = new Array(yTranspose.length); for(i = 0; i < yTranspose.length; i++) out[i] = exports.dot(x, yTranspose[i]); - } - else { + } else { // vec-vec out = 0; for(i = 0; i < len; i++) out += x[i] * y[i]; diff --git a/src/lib/nested_property.js b/src/lib/nested_property.js index 54dd28dc590..e02cd923de3 100644 --- a/src/lib/nested_property.js +++ b/src/lib/nested_property.js @@ -181,8 +181,7 @@ function npSet(cont, parts, propStr) { } } } - } - else curCont[parts[i]] = val; + } else curCont[parts[i]] = val; }; } diff --git a/src/lib/override_cursor.js b/src/lib/override_cursor.js index 5a4a7fae2d4..29933459614 100644 --- a/src/lib/override_cursor.js +++ b/src/lib/override_cursor.js @@ -37,8 +37,7 @@ module.exports = function overrideCursor(el3, csr) { } } setCursor(el3, csr); - } - else if(savedCursor) { + } else if(savedCursor) { el3.attr(STASHATTR, null); if(savedCursor === NO_CURSOR) setCursor(el3); diff --git a/src/lib/polygon.js b/src/lib/polygon.js index 4c0742ac101..ee28750d2fe 100644 --- a/src/lib/polygon.js +++ b/src/lib/polygon.js @@ -60,8 +60,7 @@ polygon.tester = function tester(ptsIn) { isRect = true; rectFirstEdgeTest = function(pt) { return pt[0] === pts[0][0]; }; } - } - else if(pts[0][1] === pts[1][1]) { // horz, vert, horz, vert + } else if(pts[0][1] === pts[1][1]) { // horz, vert, horz, vert if(pts[2][1] === pts[3][1] && pts[0][0] === pts[3][0] && pts[1][0] === pts[2][0]) { @@ -114,21 +113,21 @@ polygon.tester = function tester(ptsIn) { y1 = pts[i][1]; xmini = Math.min(x0, x1); - // outside the bounding box of this segment, it's only a crossing - // if it's below the box. if(x < xmini || x > Math.max(x0, x1) || y > Math.max(y0, y1)) { + // outside the bounding box of this segment, it's only a crossing + // if it's below the box. + continue; - } - else if(y < Math.min(y0, y1)) { + } else if(y < Math.min(y0, y1)) { // don't count the left-most point of the segment as a crossing // because we don't want to double-count adjacent crossings // UNLESS the polygon turns past vertical at exactly this x // Note that this is repeated below, but we can't factor it out // because if(x !== xmini) crossings++; - } - // inside the bounding box, check the actual line intercept - else { + } else { + // inside the bounding box, check the actual line intercept + // vertical segment - we know already that the point is exactly // on the segment, so mark the crossing as exactly at the point. if(x1 === x0) ycross = y; diff --git a/src/lib/push_unique.js b/src/lib/push_unique.js index 33874cbfe07..64bcbaeab0c 100644 --- a/src/lib/push_unique.js +++ b/src/lib/push_unique.js @@ -30,8 +30,7 @@ module.exports = function pushUnique(array, item) { } } array.push(item); - } - else if((item || item === 0) && array.indexOf(item) === -1) array.push(item); + } else if((item || item === 0) && array.indexOf(item) === -1) array.push(item); return array; }; diff --git a/src/lib/queue.js b/src/lib/queue.js index eb94df6f67d..f86a1c10b93 100644 --- a/src/lib/queue.js +++ b/src/lib/queue.js @@ -30,8 +30,7 @@ function copyArgArray(gd, args) { copy[i] = Array.isArray(arg) ? Lib.extendDeep([], arg) : Lib.extendDeepAll({}, arg); - } - else copy[i] = arg; + } else copy[i] = arg; } return copy; diff --git a/src/lib/relink_private.js b/src/lib/relink_private.js index eb27df034e0..22981cb094f 100644 --- a/src/lib/relink_private.js +++ b/src/lib/relink_private.js @@ -33,8 +33,7 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { if(k in toContainer) continue; toContainer[k] = fromVal; - } - else if(isArrayOrTypedArray(fromVal) && isArrayOrTypedArray(toVal) && isPlainObject(fromVal[0])) { + } else if(isArrayOrTypedArray(fromVal) && isArrayOrTypedArray(toVal) && isPlainObject(fromVal[0])) { // filter out data_array items that can contain user objects // most of the time the toVal === fromVal check will catch these early // but if the user makes new ones we also don't want to recurse in. @@ -47,8 +46,7 @@ module.exports = function relinkPrivateKeys(toContainer, fromContainer) { relinkPrivateKeys(toVal[j], fromVal[j]); } } - } - else if(isPlainObject(fromVal) && isPlainObject(toVal)) { + } else if(isPlainObject(fromVal) && isPlainObject(toVal)) { // recurse into objects, but only if they still exist relinkPrivateKeys(toVal, fromVal); diff --git a/src/lib/search.js b/src/lib/search.js index abddadec392..96b1148a2ac 100644 --- a/src/lib/search.js +++ b/src/lib/search.js @@ -34,8 +34,7 @@ exports.findBin = function(val, bins, linelow) { return linelow ? Math.ceil((val - bins.start) / bins.size - roundingError) - 1 : Math.floor((val - bins.start) / bins.size + roundingError); - } - else { + } else { var n1 = 0; var n2 = bins.length; var c = 0; diff --git a/src/lib/svg_text_utils.js b/src/lib/svg_text_utils.js index b73ef04658a..3100c222170 100644 --- a/src/lib/svg_text_utils.js +++ b/src/lib/svg_text_utils.js @@ -130,14 +130,11 @@ exports.convertToTspans = function(_context, gd, _callback) { ') translate(' + [-newSvgW / 2, dy - newSvgH / 2] + ')' }); newSvg.attr({x: +_context.attr('x'), y: +_context.attr('y')}); - } - else if(svgClass[0] === 'l') { + } else if(svgClass[0] === 'l') { newSvg.attr({x: _context.attr('x'), y: dy - (newSvgH / 2)}); - } - else if(svgClass[0] === 'a' && svgClass.indexOf('atitle') !== 0) { + } else if(svgClass[0] === 'a' && svgClass.indexOf('atitle') !== 0) { newSvg.attr({x: 0, y: dy}); - } - else { + } else { newSvg.attr({x: newX, y: (+_context.attr('y') + dy - newSvgH / 2)}); } @@ -145,8 +142,7 @@ exports.convertToTspans = function(_context, gd, _callback) { resolve(mathjaxGroup); }); })); - } - else showText(); + } else showText(); return _context; }; @@ -209,8 +205,7 @@ function texToSVG(_texString, _config, _callback) { if(tmpDiv.select('.MathJax_SVG').empty() || !tmpDiv.select('svg').node()) { Lib.log('There was an error in the tex syntax.', _texString); _callback(); - } - else { + } else { var svgBBox = tmpDiv.select('svg').node().getBoundingClientRect(); _callback(tmpDiv.select('.MathJax_SVG'), glyphDefs, svgBBox); } @@ -413,8 +408,7 @@ function convertEntities(_str) { parseInt(innerMatch.substr(2), 16) : parseInt(innerMatch.substr(1), 10) ); - } - else outChar = entityToUnicode[innerMatch]; + } else outChar = entityToUnicode[innerMatch]; // as in regular HTML, if we didn't decode the entity just // leave the raw text in place. @@ -514,8 +508,7 @@ function buildSVGText(containerNode, str) { popup + '");return false;'; } } - } - else nodeType = 'tspan'; + } else nodeType = 'tspan'; if(nodeSpec.style) nodeAttrs.style = nodeSpec.style; @@ -532,8 +525,7 @@ function buildSVGText(containerNode, str) { currentNode.appendChild(newNode); currentNode.appendChild(resetter); - } - else { + } else { currentNode.appendChild(newNode); } @@ -581,16 +573,13 @@ function buildSVGText(containerNode, str) { if(tagType === 'br') { newLine(); - } - else if(tagStyle === undefined) { + } else if(tagStyle === undefined) { addTextNode(currentNode, convertEntities(parti)); - } - else { + } else { // tag - open or close if(match[1]) { exitNode(tagType); - } - else { + } else { var extra = match[4]; var nodeSpec = {type: tagType}; @@ -602,8 +591,7 @@ function buildSVGText(containerNode, str) { if(css) { css = css.replace(COLORMATCH, '$1 fill:'); if(tagStyle) css += ';' + tagStyle; - } - else if(tagStyle) css = tagStyle; + } else if(tagStyle) css = tagStyle; if(css) nodeSpec.style = css; @@ -650,8 +638,7 @@ exports.positionText = function positionText(s, x, y) { text.attr(attr, 0); val = 0; } - } - else text.attr(attr, val); + } else text.attr(attr, val); return val; } @@ -807,8 +794,7 @@ exports.makeEditable = function(context, options) { .on('blur', function() { return false; }) .transition().remove(); dispatch.cancel.call(context, this.textContent); - } - else { + } else { dispatch.input.call(context, this.textContent); d3.select(this).call(alignHTMLWith(context, container, options)); } diff --git a/src/lib/throttle.js b/src/lib/throttle.js index bf6e42ba7c7..1603d3b0812 100644 --- a/src/lib/throttle.js +++ b/src/lib/throttle.js @@ -88,8 +88,7 @@ exports.clear = function(id) { if(id) { _clearTimeout(timerCache[id]); delete timerCache[id]; - } - else { + } else { for(var idi in timerCache) exports.clear(idi); } }; diff --git a/src/plot_api/edit_types.js b/src/plot_api/edit_types.js index f18a076fe7c..6f849283de0 100644 --- a/src/plot_api/edit_types.js +++ b/src/plot_api/edit_types.js @@ -139,8 +139,7 @@ function overrideOne(attr, editTypeOverride, overrideContainers, key) { } } return out; - } - else { + } else { // don't provide an editType for the _deprecated container return overrideAll(attr, editTypeOverride, (key.charAt(0) === '_') ? 'nested' : 'from-root'); diff --git a/src/plot_api/helpers.js b/src/plot_api/helpers.js index 5ef7e4bc384..72fb27472d4 100644 --- a/src/plot_api/helpers.js +++ b/src/plot_api/helpers.js @@ -62,8 +62,9 @@ exports.cleanLayout = function(layout) { for(i = 0; i < keys.length; i++) { var key = keys[i]; - // modifications to cartesian axes if(axisAttrRegex && axisAttrRegex.test(key)) { + // modifications to cartesian axes + var ax = layout[key]; if(ax.anchor && ax.anchor !== 'free') { ax.anchor = cleanId(ax.anchor); @@ -96,26 +97,21 @@ exports.cleanLayout = function(layout) { } cleanTitle(ax); - } + } else if(polarAttrRegex && polarAttrRegex.test(key)) { + // modifications for polar - // modifications for polar - else if(polarAttrRegex && polarAttrRegex.test(key)) { var polar = layout[key]; - cleanTitle(polar.radialaxis); - } + } else if(ternaryAttrRegex && ternaryAttrRegex.test(key)) { + // modifications for ternary - // modifications for ternary - else if(ternaryAttrRegex && ternaryAttrRegex.test(key)) { var ternary = layout[key]; - cleanTitle(ternary.aaxis); cleanTitle(ternary.baxis); cleanTitle(ternary.caxis); - } + } else if(sceneAttrRegex && sceneAttrRegex.test(key)) { + // modifications for 3D scenes - // modifications for 3D scenes - else if(sceneAttrRegex && sceneAttrRegex.test(key)) { var scene = layout[key]; // clean old Camera coords @@ -158,8 +154,7 @@ exports.cleanLayout = function(layout) { if(ann.ref === 'paper') { ann.xref = 'paper'; ann.yref = 'paper'; - } - else if(ann.ref === 'data') { + } else if(ann.ref === 'data') { ann.xref = 'x'; ann.yref = 'y'; } @@ -186,8 +181,7 @@ exports.cleanLayout = function(layout) { if(legend.x > 3) { legend.x = 1.02; legend.xanchor = 'left'; - } - else if(legend.x < -2) { + } else if(legend.x < -2) { legend.x = -0.02; legend.xanchor = 'right'; } @@ -195,8 +189,7 @@ exports.cleanLayout = function(layout) { if(legend.y > 3) { legend.y = 1.02; legend.yanchor = 'bottom'; - } - else if(legend.y < -2) { + } else if(legend.y < -2) { legend.y = -0.02; legend.yanchor = 'top'; } @@ -340,8 +333,7 @@ exports.cleanData = function(data) { for(i = 0; i < trace.textposition.length; i++) { trace.textposition[i] = cleanTextPosition(trace.textposition[i]); } - } - else if(trace.textposition) { + } else if(trace.textposition) { trace.textposition = cleanTextPosition(trace.textposition); } } @@ -397,8 +389,7 @@ exports.cleanData = function(data) { ); // if no common part, leave whatever name was (or wasn't) there if(newName) trace.name = newName; - } - else if((increasingName || decreasingName) && !trace.name) { + } else if((increasingName || decreasingName) && !trace.name) { // one sub-name existed but not the base name - just use the sub-name trace.name = increasingName || decreasingName; } @@ -570,11 +561,9 @@ exports.swapXYData = function(trace) { exports.coerceTraceIndices = function(gd, traceIndices) { if(isNumeric(traceIndices)) { return [traceIndices]; - } - else if(!Array.isArray(traceIndices) || !traceIndices.length) { + } else if(!Array.isArray(traceIndices) || !traceIndices.length) { return gd.data.map(function(_, i) { return i; }); - } - else if(Array.isArray(traceIndices)) { + } else if(Array.isArray(traceIndices)) { var traceIndicesOut = []; for(var i = 0; i < traceIndices.length; i++) { if(Lib.isIndex(traceIndices[i], gd.data.length)) { @@ -609,8 +598,9 @@ exports.manageArrayContainers = function(np, newVal, undoit) { var pLastIsNumber = isNumeric(pLast); - // delete item if(pLastIsNumber && newVal === null) { + // delete item + // Clear item in array container when new value is null var contPath = parts.slice(0, pLength - 1).join('.'); var cont = Lib.nestedProperty(obj, contPath).get(); @@ -618,16 +608,16 @@ exports.manageArrayContainers = function(np, newVal, undoit) { // Note that nested property clears null / undefined at end of // array container, but not within them. - } - // create item - else if(pLastIsNumber && np.get() === undefined) { + } else if(pLastIsNumber && np.get() === undefined) { + // create item + // When adding a new item, make sure undo command will remove it if(np.get() === undefined) undoit[np.astr] = null; np.set(newVal); - } - // update item - else { + } else { + // update item + // If the last part of attribute string isn't a number, // np.set is all we need. np.set(newVal); diff --git a/src/plot_api/manage_arrays.js b/src/plot_api/manage_arrays.js index c879b8df7c6..3bea13ca6a7 100644 --- a/src/plot_api/manage_arrays.js +++ b/src/plot_api/manage_arrays.js @@ -147,20 +147,17 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, if(isRemoveVal(objVal)) { deletes.push(componentNum); - } - else if(adding) { + } else if(adding) { if(objVal === 'add') objVal = {}; componentArray.splice(componentNum, 0, objVal); if(componentArrayFull) componentArrayFull.splice(componentNum, 0, {}); - } - else { + } else { Loggers.warn('Unrecognized full object edit value', componentType, componentNum, objVal); } if(firstIndexChange === -1) firstIndexChange = componentNum; - } - else { + } else { for(j = 0; j < objKeys.length; j++) { prefix = componentType + '[' + componentNum + '].'; _nestedProperty(componentArray[componentNum], objKeys[j], prefix) @@ -191,8 +188,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, if(firstIndexChange === -1) { // there's no re-indexing to do, so only redraw components that changed indicesToDraw = componentNums; - } - else { + } else { // in case the component array was shortened, we still need do call // drawOne on the latter items so they get properly removed maxIndex = Math.max(componentArray.length, maxIndex); @@ -209,8 +205,7 @@ exports.applyContainerArrayChanges = function applyContainerArrayChanges(gd, np, for(i = 0; i < indicesToDraw.length; i++) { drawOne(gd, indicesToDraw[i]); } - } - else draw(gd); + } else draw(gd); return true; }; diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 35c66506311..ad064ee5d7b 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -302,8 +302,7 @@ exports.plot = function(gd, data, layout, config) { var colorbarOpts = trace._module.colorbar; if(trace.visible !== true || !colorbarOpts) { Plots.autoMargin(gd, 'cb' + trace.uid); - } - else connectColorbar(gd, cd, colorbarOpts); + } else connectColorbar(gd, cd, colorbarOpts); } Plots.doAutoMargin(gd); @@ -1152,8 +1151,7 @@ exports.addTraces = function addTraces(gd, traces, newIndices) { try { // this is redundant, but necessary to not catch later possible errors! checkMoveTracesArgs(gd, currentIndices, newIndices); - } - catch(error) { + } catch(error) { // something went wrong, reset gd to be safe and rethrow error gd.data.splice(gd.data.length - traces.length, traces.length); throw error; @@ -1347,8 +1345,7 @@ function restyle(gd, astr, val, _traces) { // the 3-arg form aobj = Lib.extendFlat({}, astr); if(_traces === undefined) _traces = val; - } - else { + } else { Lib.warn('Restyle fail.', astr, val, _traces); return Promise.reject(); } @@ -1445,16 +1442,14 @@ function storeCurrent(attr, val, newVal, preGUI) { for(var i = 0; i < maxLen; i++) { storeCurrent(attr + '[' + i + ']', arrayVal[i], arrayNew[i], preGUI); } - } - else if(Lib.isPlainObject(val) || Lib.isPlainObject(newVal)) { + } else if(Lib.isPlainObject(val) || Lib.isPlainObject(newVal)) { var objVal = Lib.isPlainObject(val) ? val : {}; var objNew = Lib.isPlainObject(newVal) ? newVal : {}; var objBoth = Lib.extendFlat({}, objVal, objNew); for(var key in objBoth) { storeCurrent(attr + '.' + key, objVal[key], objNew[key], preGUI); } - } - else if(preGUI[attr] === undefined) { + } else if(preGUI[attr] === undefined) { preGUI[attr] = undefinedToNull(val); } } @@ -1630,18 +1625,17 @@ function _restyle(gd, aobj, traces) { for(var impliedKey in valObject.impliedEdits) { doextra(Lib.relativeAttr(ai, impliedKey), valObject.impliedEdits[impliedKey], i); } - } - - // changing colorbar size modes, - // make the resulting size not change - // note that colorbar fractional sizing is based on the - // original plot size, before anything (like a colorbar) - // increases the margins - else if((finalPart === 'thicknessmode' || finalPart === 'lenmode') && + } else if((finalPart === 'thicknessmode' || finalPart === 'lenmode') && oldVal !== newVal && (newVal === 'fraction' || newVal === 'pixels') && innerContFull ) { + // changing colorbar size modes, + // make the resulting size not change + // note that colorbar fractional sizing is based on the + // original plot size, before anything (like a colorbar) + // increases the margins + var gs = fullLayout._size; var orient = innerContFull.orient; var topOrBottom = (orient === 'top') || (orient === 'bottom'); @@ -1649,15 +1643,12 @@ function _restyle(gd, aobj, traces) { var thicknorm = topOrBottom ? gs.h : gs.w; doextra(prefixDot + 'thickness', innerContFull.thickness * (newVal === 'fraction' ? 1 / thicknorm : thicknorm), i); - } - else { + } else { var lennorm = topOrBottom ? gs.w : gs.h; doextra(prefixDot + 'len', innerContFull.len * (newVal === 'fraction' ? 1 / lennorm : lennorm), i); } - } - - else if(ai === 'type' && (newVal === 'pie') !== (oldVal === 'pie')) { + } else if(ai === 'type' && (newVal === 'pie') !== (oldVal === 'pie')) { var labelsTo = 'x'; var valuesTo = 'y'; if((newVal === 'bar' || oldVal === 'bar') && cont.orientation === 'h') { @@ -1698,22 +1689,20 @@ function _restyle(gd, aobj, traces) { if((param.get() || defaultOrientation) === contFull.orientation) { continue; } - } - // orientationaxes has no value, - // it flips everything and the axes - else if(ai === 'orientationaxes') { + } else if(ai === 'orientationaxes') { + // orientationaxes has no value, + // it flips everything and the axes + cont.orientation = {v: 'h', h: 'v'}[contFull.orientation]; } helpers.swapXYData(cont); flags.calc = flags.clearAxisTypes = true; - } - else if(Plots.dataArrayContainers.indexOf(param.parts[0]) !== -1) { + } else if(Plots.dataArrayContainers.indexOf(param.parts[0]) !== -1) { // TODO: use manageArrays.applyContainerArrayChanges here too helpers.manageArrayContainers(param, newVal, undoit); flags.calc = true; - } - else { + } else { if(valObject) { // must redo calcdata when restyling array values of arrayOk attributes // ... but no need to this for regl-based traces @@ -1722,10 +1711,8 @@ function _restyle(gd, aobj, traces) { (Lib.isArrayOrTypedArray(newVal) || Lib.isArrayOrTypedArray(oldVal)) ) { flags.calc = true; - } - else editTypes.update(flags, valObject); - } - else { + } else editTypes.update(flags, valObject); + } else { /* * if we couldn't find valObject, assume a full recalc. * This can happen if you're changing type and making @@ -1888,8 +1875,7 @@ function relayout(gd, astr, val) { if(flags.layoutReplot) { seq.push(subroutines.layoutReplot); - } - else if(Object.keys(aobj).length) { + } else if(Object.keys(aobj).length) { axRangeSupplyDefaultsByPass(gd, flags, specs) || Plots.supplyDefaults(gd); if(flags.legend) seq.push(subroutines.doLegend); @@ -2119,22 +2105,19 @@ function _relayout(gd, aobj) { // ignore this if the same relayout call also provides oppositeAttr var oppositeAttr = ai === 'height' ? 'width' : 'height'; doextra(oppositeAttr, fullLayout[oppositeAttr]); - } - else { + } else { fullLayout[ai] = gd._initialAutoSize[ai]; } - } - else if(ai === 'autosize') { + } else if(ai === 'autosize') { // depends on vi here too, so again can't use impliedEdits doextra('width', vi ? null : fullLayout.width); doextra('height', vi ? null : fullLayout.height); - } - // check autorange vs range - else if(pleafPlus.match(AX_RANGE_RE)) { + } else if(pleafPlus.match(AX_RANGE_RE)) { + // check autorange vs range + recordAlteredAxis(pleafPlus); nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); - } - else if(pleafPlus.match(AX_AUTORANGE_RE)) { + } else if(pleafPlus.match(AX_AUTORANGE_RE)) { recordAlteredAxis(pleafPlus); nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); var axFull = nestedProperty(fullLayout, ptrunk).get(); @@ -2143,8 +2126,7 @@ function _relayout(gd, aobj) { // reset it so we don't get locked into a shrunken size axFull._input.domain = axFull._inputDomain.slice(); } - } - else if(pleafPlus.match(AX_DOMAIN_RE)) { + } else if(pleafPlus.match(AX_DOMAIN_RE)) { nestedProperty(fullLayout, ptrunk + '._inputDomain').set(null); } @@ -2164,8 +2146,7 @@ function _relayout(gd, aobj) { // I don't think this is needed, but left here in case there // are edge cases I'm not thinking of. doextra(ptrunk + '.autorange', true); - } - else if(!parentFull.autorange) { + } else if(!parentFull.autorange) { // toggling log without autorange: need to also recalculate ranges // because log axes use linearized values for range endpoints var r0 = ax.range[0]; @@ -2181,13 +2162,11 @@ function _relayout(gd, aobj) { // now set the range values as appropriate doextra(ptrunk + '.range[0]', Math.log(r0) / Math.LN10); doextra(ptrunk + '.range[1]', Math.log(r1) / Math.LN10); - } - else { + } else { doextra(ptrunk + '.range[0]', Math.pow(10, r0)); doextra(ptrunk + '.range[1]', Math.pow(10, r1)); } - } - else if(toLog) { + } else if(toLog) { // just make sure the range is positive and in the right // order, it'll get recalculated later ax.range = (ax.range[1] > ax.range[0]) ? [1, 2] : [2, 1]; @@ -2207,16 +2186,14 @@ function _relayout(gd, aobj) { // Shapes do not need this :) Registry.getComponentMethod('annotations', 'convertCoords')(gd, parentFull, vi, doextra); Registry.getComponentMethod('images', 'convertCoords')(gd, parentFull, vi, doextra); - } - else { + } else { // any other type changes: the range from the previous type // will not make sense, so autorange it. doextra(ptrunk + '.autorange', true); doextra(ptrunk + '.range', null); } nestedProperty(fullLayout, ptrunk + '._inputRange').set(null); - } - else if(pleaf.match(AX_NAME_PATTERN)) { + } else if(pleaf.match(AX_NAME_PATTERN)) { var fullProp = nestedProperty(fullLayout, ai).get(); var newType = (vi || {}).type; @@ -2262,9 +2239,9 @@ function _relayout(gd, aobj) { objEdits[propStr] = vi; delete aobj[ai]; - } - // handle axis reversal explicitly, as there's no 'reverse' attribute - else if(pleaf === 'reverse') { + } else if(pleaf === 'reverse') { + // handle axis reversal explicitly, as there's no 'reverse' attribute + if(parentIn.range) parentIn.range.reverse(); else { doextra(ptrunk + '.autorange', true); @@ -2273,19 +2250,16 @@ function _relayout(gd, aobj) { if(parentFull.autorange) flags.calc = true; else flags.plot = true; - } - else { + } else { if((fullLayout._has('scatter-like') && fullLayout._has('regl')) && (ai === 'dragmode' && (vi === 'lasso' || vi === 'select') && !(vOld === 'lasso' || vOld === 'select')) ) { flags.plot = true; - } - else if(fullLayout._has('gl2d')) { + } else if(fullLayout._has('gl2d')) { flags.plot = true; - } - else if(valObject) editTypes.update(flags, valObject); + } else if(valObject) editTypes.update(flags, valObject); else flags.calc = true; p.set(vi); @@ -2412,14 +2386,11 @@ function update(gd, traceUpdate, layoutUpdate, _traces) { gd.layout = undefined; seq.push(function() { return exports.plot(gd, data, layout); }); - } - else if(restyleFlags.fullReplot) { + } else if(restyleFlags.fullReplot) { seq.push(exports.plot); - } - else if(relayoutFlags.layoutReplot) { + } else if(relayoutFlags.layoutReplot) { seq.push(subroutines.layoutReplot); - } - else { + } else { seq.push(Plots.previousPromises); axRangeSupplyDefaultsByPass(gd, relayoutFlags, relayoutSpecs) || Plots.supplyDefaults(gd); @@ -2597,8 +2568,7 @@ function applyUIRevisions(data, layout, oldFullData, oldFullLayout) { continue; } } - } - else { + } else { Lib.warn('unrecognized GUI edit: ' + key); } // if we got this far, the new value was accepted as the new starting @@ -2658,8 +2628,7 @@ function applyUIRevisions(data, layout, oldFullData, oldFullLayout) { if(match.attr) { oldRev = nestedProperty(oldFullLayout, match.attr).get(); newRev = oldRev && getNewRev(match.attr, layout); - } - else { + } else { oldRev = fullInput.uirevision; // inheritance for trace.uirevision is simple, just layout.uirevision newRev = newTrace.uirevision; @@ -2676,8 +2645,7 @@ function applyUIRevisions(data, layout, oldFullData, oldFullLayout) { continue; } } - } - else { + } else { Lib.warn('unrecognized GUI edit: ' + key + ' in trace uid ' + uid); } delete tracePreGUI[key]; @@ -2721,8 +2689,7 @@ exports.react = function(gd, data, layout, config) { // you can use this as the initial draw as well as to update if(!Lib.isPlotDiv(gd) || !oldFullData || !oldFullLayout) { plotDone = exports.newPlot(gd, data, layout, config); - } - else { + } else { if(Lib.isPlainObject(data)) { var obj = data; data = obj.data; @@ -2801,12 +2768,10 @@ exports.react = function(gd, data, layout, config) { seq.push(function() { return Plots.transitionFromReact(gd, restyleFlags, relayoutFlags, oldFullLayout); }); - } - else if(restyleFlags.fullReplot || relayoutFlags.layoutReplot || configChanged) { + } else if(restyleFlags.fullReplot || relayoutFlags.layoutReplot || configChanged) { gd._fullLayout._skipDefaults = true; seq.push(exports.plot); - } - else { + } else { for(var componentType in relayoutFlags.arrays) { var indices = relayoutFlags.arrays[componentType]; if(indices.length) { @@ -2815,8 +2780,7 @@ exports.react = function(gd, data, layout, config) { for(var i = 0; i < indices.length; i++) { drawOne(gd, indices[i]); } - } - else { + } else { var draw = Registry.getComponentMethod(componentType, 'draw'); if(draw === Lib.noop) { throw new Error('cannot draw components: ' + componentType); @@ -3035,8 +2999,7 @@ function getDiffFlags(oldContainer, newContainer, outerparts, opts) { if(newVal === undefined) { if(canBeDataArray && wasArray) flags.calc = true; else changed(); - } - else if(valObject._isLinkedToArray) { + } else if(valObject._isLinkedToArray) { var arrayEditIndices = []; var extraIndices = false; if(!inArray) flags.arrays[key] = arrayEditIndices; @@ -3046,8 +3009,7 @@ function getDiffFlags(oldContainer, newContainer, outerparts, opts) { if(minLen !== maxLen) { if(valObject.editType === 'arraydraw') { extraIndices = true; - } - else { + } else { changed(); continue; } @@ -3067,11 +3029,9 @@ function getDiffFlags(oldContainer, newContainer, outerparts, opts) { arrayEditIndices.push(i); } } - } - else if(!valType && Lib.isPlainObject(oldVal)) { + } else if(!valType && Lib.isPlainObject(oldVal)) { getDiffFlags(oldVal, newVal, parts, opts); - } - else if(canBeDataArray) { + } else if(canBeDataArray) { if(wasArray && nowArray) { // don't try to diff two data arrays. If immutable we know the data changed, // if not, assume it didn't and let `layout.datarevision` tell us if it did @@ -3083,13 +3043,10 @@ function getDiffFlags(oldContainer, newContainer, outerparts, opts) { if(immutable || opts.newDataRevision) { changed(); } - } - else if(wasArray !== nowArray) { + } else if(wasArray !== nowArray) { flags.calc = true; - } - else changed(); - } - else if(wasArray && nowArray) { + } else changed(); + } else if(wasArray && nowArray) { // info array, colorscale, 'any' - these are short, just stringify. // I don't *think* that covers up any real differences post-validation, does it? // otherwise we need to dive in 1 (info_array) or 2 (colorscale) levels and compare @@ -3097,8 +3054,7 @@ function getDiffFlags(oldContainer, newContainer, outerparts, opts) { if(oldVal.length !== newVal.length || String(oldVal) !== String(newVal)) { changed(); } - } - else { + } else { changed(); } } @@ -3110,8 +3066,7 @@ function getDiffFlags(oldContainer, newContainer, outerparts, opts) { if(valObjectCanBeDataArray(valObject) && Array.isArray(newContainer[key])) { flags.calc = true; return; - } - else changed(); + } else changed(); } } } @@ -3131,8 +3086,7 @@ function diffConfig(oldConfig, newConfig) { if(diffConfig(oldVal, newVal)) { return true; } - } - else if(Array.isArray(oldVal) && Array.isArray(newVal)) { + } else if(Array.isArray(oldVal) && Array.isArray(newVal)) { if(oldVal.length !== newVal.length) { return true; } @@ -3142,14 +3096,12 @@ function diffConfig(oldConfig, newConfig) { if(diffConfig(oldVal[i], newVal[i])) { return true; } - } - else { + } else { return true; } } } - } - else { + } else { return true; } } diff --git a/src/plot_api/plot_schema.js b/src/plot_api/plot_schema.js index 092c0020485..5dbe3fb4774 100644 --- a/src/plot_api/plot_schema.js +++ b/src/plot_api/plot_schema.js @@ -207,8 +207,7 @@ exports.findArrayAttributes = function(trace) { if(Lib.isArrayOrTypedArray(item)) { arrayAttributes.push(baseAttrName + newAstrPartial); } - } - else { + } else { if(isArrayStack[i]) { if(Array.isArray(item)) { for(var j = 0; j < item.length; j++) { @@ -217,8 +216,7 @@ exports.findArrayAttributes = function(trace) { } } } - } - else if(Lib.isPlainObject(item)) { + } else if(Lib.isPlainObject(item)) { crawlIntoTrace(item, i + 1, newAstrPartial + '.'); } } @@ -282,11 +280,9 @@ exports.getTraceValObject = function(trace, parts) { moduleAttrs = (Registry.transformsRegistry[transforms[tNum].type] || {}).attributes; valObject = moduleAttrs && moduleAttrs[parts[2]]; i = 3; // start recursing only inside the transform - } - else if(trace.type === 'area') { + } else if(trace.type === 'area') { valObject = polarAreaAttrs[head]; - } - else { + } else { // first look in the module for this trace // components have already merged their trace attributes in here var _module = trace._module; @@ -414,8 +410,7 @@ function recurseIntoValObject(valObject, parts, i) { if(valObject._isLinkedToArray) { i++; if(!isIndex(parts[i])) return false; - } - else if(valObject.valType === 'info_array') { + } else if(valObject.valType === 'info_array') { i++; var index = parts[i]; if(!isIndex(index)) return false; @@ -429,10 +424,8 @@ function recurseIntoValObject(valObject, parts, i) { var index2 = parts[i]; if(!isIndex(index2)) return false; valObject = items[index][index2]; - } - else valObject = items[index]; - } - else { + } else valObject = items[index]; + } else { valObject = items; } } @@ -550,6 +543,7 @@ function getLayoutAttributes() { _module = Registry.componentsRegistry[key]; var schema = _module.schema; + if(schema && (schema.subplots || schema.layout)) { /* * Components with defined schema have already been merged in at register time * but a few components define attributes that apply only to xaxis @@ -560,14 +554,14 @@ function getLayoutAttributes() { * we will need to extend both this code and mergeComponentAttrsToSubplot * (which will not find yaxis only for example) */ - if(schema && (schema.subplots || schema.layout)) { + var subplots = schema.subplots; if(subplots && subplots.xaxis && !subplots.yaxis) { for(var xkey in subplots.xaxis) delete layoutAttributes.yaxis[xkey]; } - } + } else if(_module.layoutAttributes) { // older style without schema need to be explicitly merged in now - else if(_module.layoutAttributes) { + insertAttrs(layoutAttributes, _module.layoutAttributes, _module.name); } } @@ -635,13 +629,11 @@ function mergeValTypeAndRole(attrs) { attr.role = 'data'; // all 'data_array' attrs have a corresponding 'src' attr attrs[attrName + 'src'] = makeSrcAttr(attrName); - } - else if(attr.arrayOk === true) { + } else if(attr.arrayOk === true) { // all 'arrayOk' attrs have a corresponding 'src' attr attrs[attrName + 'src'] = makeSrcAttr(attrName); } - } - else if(isPlainObject(attr)) { + } else if(isPlainObject(attr)) { // all attrs container objects get role 'object' attr.role = 'object'; } diff --git a/src/plot_api/plot_template.js b/src/plot_api/plot_template.js index bf96588d3ba..1a4a7bed569 100644 --- a/src/plot_api/plot_template.js +++ b/src/plot_api/plot_template.js @@ -96,8 +96,7 @@ exports.traceTemplater = function(dataTemplate) { var typei = traceCounts[traceType] % typeTemplates.length; traceCounts[traceType]++; traceOut._template = typeTemplates[typei]; - } - else { + } else { // TODO: anything we should do for types missing from the template? // try to apply some other type? Or just bail as we do here? // Actually I think yes, we should apply other types; would be nice @@ -298,8 +297,7 @@ exports.arrayEditor = function(parentIn, containerStr, itemOut) { if(templateItemName) { // we're making a new object: edit that object Lib.nestedProperty(update[itemStr], attr).set(value); - } - else { + } else { // we're editing an existing object: include *just* the edit update[itemStr + '.' + attr] = value; } diff --git a/src/plot_api/template_api.js b/src/plot_api/template_api.js index 18fd5830009..7f9aaddc977 100644 --- a/src/plot_api/template_api.js +++ b/src/plot_api/template_api.js @@ -133,8 +133,7 @@ function mergeTemplates(oldTemplate, newTemplate) { function mergeOne(oldVal, newVal, key) { if(isPlainObject(newVal) && isPlainObject(oldVal)) { mergeTemplates(oldVal, newVal); - } - else if(Array.isArray(newVal) && Array.isArray(oldVal)) { + } else if(Array.isArray(newVal) && Array.isArray(oldVal)) { // Note: omitted `inclusionAttr` from arrayTemplater here, // it's irrelevant as we only want the resulting `_template`. var templater = Template.arrayTemplater({_template: oldTemplate}, key); @@ -156,8 +155,7 @@ function mergeTemplates(oldTemplate, newTemplate) { var oldVal = oldTemplate[key]; if(key in newTemplate) { mergeOne(oldVal, newTemplate[key], key); - } - else newTemplate[key] = oldVal; + } else newTemplate[key] = oldVal; // if this is a base key from the old template (eg xaxis), look for // extended keys (eg xaxis2) in the new template to merge into @@ -204,8 +202,7 @@ function walkStyleKeys(parent, templateOut, getAttributeInfo, path, basePath) { if(!attr.valType && isPlainObject(child)) { walkStyleKeys(child, templateOut, getAttributeInfo, nextPath, nextBasePath); - } - else if(attr._isLinkedToArray && Array.isArray(child)) { + } else if(attr._isLinkedToArray && Array.isArray(child)) { var dfltDone = false; var namedIndex = 0; var usedNames = {}; @@ -222,8 +219,7 @@ function walkStyleKeys(parent, templateOut, getAttributeInfo, path, basePath) { namedIndex++; usedNames[name] = 1; } - } - else if(!dfltDone) { + } else if(!dfltDone) { var dfltKey = Template.arrayDefaultKey(key); var dfltPath = getNextPath(parent, dfltKey, path); @@ -242,8 +238,7 @@ function walkStyleKeys(parent, templateOut, getAttributeInfo, path, basePath) { } } } - } - else { + } else { var templateProp = Lib.nestedProperty(templateOut, nextPath); templateProp.set(child); } @@ -333,8 +328,7 @@ exports.validateTemplate = function(figureIn, template) { var nextPath = getNextPath(obj, key, path); if(layoutPaths[nextPath]) { crawlLayoutTemplateForContainers(obj[key], nextPath); - } - else { + } else { errorList.push({code: 'unused', path: nextPath}); } } @@ -343,16 +337,14 @@ exports.validateTemplate = function(figureIn, template) { if(!isPlainObject(layoutTemplate)) { errorList.push({code: 'layout'}); - } - else { + } else { crawlLayoutForContainers(fullLayout, ['layout']); crawlLayoutTemplateForContainers(layoutTemplate, 'layout'); } if(!isPlainObject(dataTemplate)) { errorList.push({code: 'data'}); - } - else { + } else { var typeCount = {}; var traceType; for(var i = 0; i < fullData.length; i++) { @@ -379,8 +371,7 @@ exports.validateTemplate = function(figureIn, template) { templateCount: templateCount, dataCount: dataCount }); - } - else if(dataCount > templateCount) { + } else if(dataCount > templateCount) { errorList.push({ code: 'reused', traceType: traceType, @@ -407,8 +398,7 @@ exports.validateTemplate = function(figureIn, template) { }); } crawlForMissingTemplates(val, nextPath); - } - else if(Array.isArray(val) && hasPlainObject(val)) { + } else if(Array.isArray(val) && hasPlainObject(val)) { crawlForMissingTemplates(val, nextPath); } } @@ -437,8 +427,7 @@ function format(opts) { if(opts.path) { msg = 'There are no templates for item ' + opts.path + ' with name ' + opts.templateitemname; - } - else { + } else { msg = 'There are no templates for trace ' + opts.index + ', of type ' + opts.traceType + '.'; } @@ -447,14 +436,12 @@ function format(opts) { if(opts.path) { msg = 'The template item at ' + opts.path + ' was not used in constructing the plot.'; - } - else if(opts.dataCount) { + } else if(opts.dataCount) { msg = 'Some of the templates of type ' + opts.traceType + ' were not used. The template has ' + opts.templateCount + ' traces, the data only has ' + opts.dataCount + ' of this type.'; - } - else { + } else { msg = 'The template has ' + opts.templateCount + ' traces of type ' + opts.traceType + ' but there are none in the data.'; diff --git a/src/plot_api/validate.js b/src/plot_api/validate.js index 123214bf4d0..9b3164941d4 100644 --- a/src/plot_api/validate.js +++ b/src/plot_api/validate.js @@ -48,8 +48,7 @@ module.exports = function validate(data, layout) { if(isArray(data)) { gd.data = Lib.extendDeep([], data); dataIn = data; - } - else { + } else { gd.data = []; dataIn = []; errorList.push(format('array', 'data')); @@ -58,8 +57,7 @@ module.exports = function validate(data, layout) { if(isPlainObject(layout)) { gd.layout = Lib.extendDeep({}, layout); layoutIn = layout; - } - else { + } else { gd.layout = {}; layoutIn = {}; if(arguments.length > 1) { @@ -169,11 +167,9 @@ function crawl(objIn, objOut, schema, list, base, path) { if(!isInSchema(schema, k)) { list.push(format('schema', base, p)); - } - else if(isPlainObject(valIn) && isPlainObject(valOut)) { + } else if(isPlainObject(valIn) && isPlainObject(valOut)) { crawl(valIn, valOut, nestedSchema, list, base, p); - } - else if(isInfoArray && isArray(valIn)) { + } else if(isInfoArray && isArray(valIn)) { if(valIn.length > valOut.length) { list.push(format('unused', base, p.concat(valOut.length))); } @@ -194,32 +190,27 @@ function crawl(objIn, objOut, schema, list, base, path) { valOutPart = valOut[n][m]; if(!Lib.validate(valInPart, item)) { list.push(format('value', base, p.concat(n, m), valInPart)); - } - else if(valOutPart !== valInPart && valOutPart !== +valInPart) { + } else if(valOutPart !== valInPart && valOutPart !== +valInPart) { list.push(format('dynamic', base, p.concat(n, m), valInPart, valOutPart)); } } - } - else { + } else { list.push(format('array', base, p.concat(n), valIn[n])); } } - } - else { + } else { for(n = 0; n < len; n++) { item = arrayItems ? items[n] : items; valInPart = valIn[n]; valOutPart = valOut[n]; if(!Lib.validate(valInPart, item)) { list.push(format('value', base, p.concat(n), valInPart)); - } - else if(valOutPart !== valInPart && valOutPart !== +valInPart) { + } else if(valOutPart !== valInPart && valOutPart !== +valInPart) { list.push(format('dynamic', base, p.concat(n), valInPart, valOutPart)); } } } - } - else if(nestedSchema.items && !isInfoArray && isArray(valIn)) { + } else if(nestedSchema.items && !isInfoArray && isArray(valIn)) { var _nestedSchema = items[Object.keys(items)[0]]; var indexList = []; @@ -239,8 +230,7 @@ function crawl(objIn, objOut, schema, list, base, path) { var valOutj = valOut[j]; if(isPlainObject(valInj) && valInj.visible !== false && valOutj.visible === false) { list.push(format('invisible', base, _p)); - } - else crawl(valInj, valOutj, _nestedSchema, list, base, _p); + } else crawl(valInj, valOutj, _nestedSchema, list, base, _p); } } @@ -251,25 +241,19 @@ function crawl(objIn, objOut, schema, list, base, path) { if(!isPlainObject(valIn[j])) { list.push(format('object', base, _p, valIn[j])); - } - else if(indexList.indexOf(j) === -1) { + } else if(indexList.indexOf(j) === -1) { list.push(format('unused', base, _p)); } } - } - else if(!isPlainObject(valIn) && isPlainObject(valOut)) { + } else if(!isPlainObject(valIn) && isPlainObject(valOut)) { list.push(format('object', base, p, valIn)); - } - else if(!isArrayOrTypedArray(valIn) && isArrayOrTypedArray(valOut) && !isInfoArray && !isColorscale) { + } else if(!isArrayOrTypedArray(valIn) && isArrayOrTypedArray(valOut) && !isInfoArray && !isColorscale) { list.push(format('array', base, p, valIn)); - } - else if(!(k in objOut)) { + } else if(!(k in objOut)) { list.push(format('unused', base, p, valIn)); - } - else if(!Lib.validate(valIn, nestedSchema)) { + } else if(!Lib.validate(valIn, nestedSchema)) { list.push(format('value', base, p, valIn)); - } - else if(nestedSchema.valType === 'enumerated' && + } else if(nestedSchema.valType === 'enumerated' && ((nestedSchema.coerceNumber && valIn !== +valOut) || valIn !== valOut) ) { list.push(format('dynamic', base, p, valIn, valOut)); @@ -308,8 +292,7 @@ var code2msgFunc = { if(base === 'layout' && astr === '') prefix = 'The layout argument'; else if(base[0] === 'data' && astr === '') { prefix = 'Trace ' + base[1] + ' in the data argument'; - } - else prefix = inBase(base) + 'key ' + astr; + } else prefix = inBase(base) + 'key ' + astr; return prefix + ' must be linked to an object container'; }, @@ -369,8 +352,7 @@ function format(code, base, path, valIn, valOut) { if(isArray(base)) { container = base[0]; trace = base[1]; - } - else { + } else { container = base; trace = null; } @@ -432,8 +414,7 @@ function convertPathToAttributeString(path) { if(typeof p === 'number') { astr = astr.substr(0, astr.length - 1) + '[' + p + ']'; - } - else { + } else { astr += p; } diff --git a/src/plots/array_container_defaults.js b/src/plots/array_container_defaults.js index eb70791d319..89581e2045f 100644 --- a/src/plots/array_container_defaults.js +++ b/src/plots/array_container_defaults.js @@ -59,8 +59,7 @@ module.exports = function handleArrayContainerDefaults(parentObjIn, parentObjOut if(!Lib.isPlainObject(itemIn)) { itemOut = templater.newItem({}); itemOut[inclusionAttr] = false; - } - else { + } else { itemOut = templater.newItem(itemIn); } diff --git a/src/plots/cartesian/autorange.js b/src/plots/cartesian/autorange.js index 153ac9f3f52..2b8a176d747 100644 --- a/src/plots/cartesian/autorange.js +++ b/src/plots/cartesian/autorange.js @@ -111,8 +111,7 @@ function getAutoRange(gd, ax) { maxbest = maxpt; mbest = dv / dp; } - } - else if(dv / axLen > mbest) { + } else if(dv / axLen > mbest) { // in case of padding longer than the axis // at least include the unpadded data values. minbest = {val: minpt.val, pad: 0}; @@ -137,8 +136,7 @@ function getAutoRange(gd, ax) { // In principle this could be [0, 1] or [-1, 0] but usually // 'tozero' pins 0 to the low end, so follow that. newRange = [0, 1]; - } - else { + } else { var maxPad = (minmin > 0 ? maxArray : minArray).reduce(getMaxPad, 0); // we're pushing a single value away from the edge due to its // padding, with the other end clamped at zero @@ -151,8 +149,7 @@ function getAutoRange(gd, ax) { } else { newRange = [lower, upper]; } - } - else { + } else { if(toZero) { if(minbest.val >= 0) { minbest = {val: 0, pad: 0}; @@ -160,8 +157,7 @@ function getAutoRange(gd, ax) { if(maxbest.val <= 0) { maxbest = {val: 0, pad: 0}; } - } - else if(nonNegative) { + } else if(nonNegative) { if(minbest.val - mbest * getPad(minbest) < 0) { minbest = {val: 0, pad: 0}; } @@ -330,8 +326,7 @@ function findExtremes(ax, data, opts) { if(Array.isArray(item)) { hasArrayOption = true; return function(i) { return Math.max(Number(item[i]||0), 0); }; - } - else { + } else { var v = Math.max(Number(item||0), 0); return function() { return v; }; } diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index 50ab0006933..e56537802dc 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -233,26 +233,26 @@ axes.minDtick = function(ax, newDiff, newFirst, allow) { // and the plot itself may decide to cancel (ie non-grouped bars) if(['log', 'category', 'multicategory'].indexOf(ax.type) !== -1 || !allow) { ax._minDtick = 0; - } - // undefined means there's nothing there yet - else if(ax._minDtick === undefined) { + } else if(ax._minDtick === undefined) { + // undefined means there's nothing there yet + ax._minDtick = newDiff; ax._forceTick0 = newFirst; - } - else if(ax._minDtick) { - // existing minDtick is an integer multiple of newDiff - // (within rounding err) - // and forceTick0 can be shifted to newFirst + } else if(ax._minDtick) { if((ax._minDtick / newDiff + 1e-6) % 1 < 2e-6 && + // existing minDtick is an integer multiple of newDiff + // (within rounding err) + // and forceTick0 can be shifted to newFirst + (((newFirst - ax._forceTick0) / newDiff % 1) + 1.000001) % 1 < 2e-6) { ax._minDtick = newDiff; ax._forceTick0 = newFirst; - } - // if the converse is true (newDiff is a multiple of minDtick and - // newFirst can be shifted to forceTick0) then do nothing - same - // forcing stands. Otherwise, cancel forced minimum - else if((newDiff / ax._minDtick + 1e-6) % 1 > 2e-6 || + } else if((newDiff / ax._minDtick + 1e-6) % 1 > 2e-6 || + // if the converse is true (newDiff is a multiple of minDtick and + // newFirst can be shifted to forceTick0) then do nothing - same + // forcing stands. Otherwise, cancel forced minimum + (((newFirst - ax._forceTick0) / ax._minDtick % 1) + 1.000001) % 1 > 2e-6) { ax._minDtick = 0; @@ -343,8 +343,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { if(size) { dummyAx.dtick = size; dummyAx.tick0 = cleanTicks.tick0(undefined, dummyAx.type, calendar); - } - else { + } else { var size0; if(nbins) size0 = ((dataMax - dataMin) / nbins); else { @@ -383,8 +382,7 @@ axes.autoBin = function(data, ax, nbins, is2d, calendar, size) { bincount = 1 + Math.floor((dataMax - binStart) / finalSize); binEnd = binStart + bincount * finalSize; - } - else { + } else { // month ticks - should be the only nonlinear kind we have at this point. // dtick (as supplied by axes.autoTick) only has nonlinear values on // date and log axes, but even if you display a histogram on a log axis @@ -434,22 +432,22 @@ function autoShiftNumericBins(binStart, data, ax, dataMin, dataMax) { var dataCount = data.length - blankCount; if(intcount === dataCount && ax.type !== 'date') { - // all integers: if bin size is <1, it's because - // that was specifically requested (large nbins) - // so respect that... but center the bins containing - // integers on those integers if(ax.dtick < 1) { + // all integers: if bin size is <1, it's because + // that was specifically requested (large nbins) + // so respect that... but center the bins containing + // integers on those integers + binStart = dataMin - 0.5 * ax.dtick; - } - // otherwise start half an integer down regardless of - // the bin size, just enough to clear up endpoint - // ambiguity about which integers are in which bins. - else { + } else { + // otherwise start half an integer down regardless of + // the bin size, just enough to clear up endpoint + // ambiguity about which integers are in which bins. + binStart -= 0.5; if(binStart + ax.dtick < dataMin) binStart += ax.dtick; } - } - else if(midcount < dataCount * 0.1) { + } else if(midcount < dataCount * 0.1) { if(edgecount > dataCount * 0.3 || nearEdge(dataMin) || nearEdge(dataMax)) { // lots of points at the edge, not many in the middle @@ -476,15 +474,13 @@ function autoShiftMonthBins(binStart, data, dtick, dataMin, calendar) { // so if we start the bins here, all but leap years will // get hover-labeled as exact years. binStart = axes.tickIncrement(binStart, 'M6', 'reverse') + ONEDAY * 1.5; - } - else if(stats.exactMonths > threshold) { + } else if(stats.exactMonths > threshold) { // Months are not as clean, but if we shift half the *longest* // month (31/2 days) then 31-day months will get labeled exactly // and shorter months will get labeled with the correct month // but shifted 12-36 hours into it. binStart = axes.tickIncrement(binStart, 'M1', 'reverse') + ONEDAY * 15.5; - } - else { + } else { // Shifting half a day is exact, but since these are month bins it // will always give a somewhat odd-looking label, until we do something // smarter like showing the bin boundaries (or the bounds of the actual @@ -708,42 +704,34 @@ axes.autoTicks = function(ax, roughDTick) { roughDTick /= ONEAVGYEAR; base = getBase(10); ax.dtick = 'M' + (12 * roundDTick(roughDTick, base, roundBase10)); - } - else if(roughX2 > ONEAVGMONTH) { + } else if(roughX2 > ONEAVGMONTH) { roughDTick /= ONEAVGMONTH; ax.dtick = 'M' + roundDTick(roughDTick, 1, roundBase24); - } - else if(roughX2 > ONEDAY) { + } else if(roughX2 > ONEDAY) { ax.dtick = roundDTick(roughDTick, ONEDAY, roundDays); // get week ticks on sunday // this will also move the base tick off 2000-01-01 if dtick is // 2 or 3 days... but that's a weird enough case that we'll ignore it. ax.tick0 = Lib.dateTick0(ax.calendar, true); - } - else if(roughX2 > ONEHOUR) { + } else if(roughX2 > ONEHOUR) { ax.dtick = roundDTick(roughDTick, ONEHOUR, roundBase24); - } - else if(roughX2 > ONEMIN) { + } else if(roughX2 > ONEMIN) { ax.dtick = roundDTick(roughDTick, ONEMIN, roundBase60); - } - else if(roughX2 > ONESEC) { + } else if(roughX2 > ONESEC) { ax.dtick = roundDTick(roughDTick, ONESEC, roundBase60); - } - else { + } else { // milliseconds base = getBase(10); ax.dtick = roundDTick(roughDTick, base, roundBase10); } - } - else if(ax.type === 'log') { + } else if(ax.type === 'log') { ax.tick0 = 0; var rng = Lib.simpleMap(ax.range, ax.r2l); if(roughDTick > 0.7) { // only show powers of 10 ax.dtick = Math.ceil(roughDTick); - } - else if(Math.abs(rng[1] - rng[0]) < 1) { + } else if(Math.abs(rng[1] - rng[0]) < 1) { // span is less than one power of 10 var nt = 1.5 * Math.abs((rng[1] - rng[0]) / roughDTick); @@ -752,24 +740,20 @@ axes.autoTicks = function(ax, roughDTick) { Math.pow(10, rng[0])) / nt; base = getBase(10); ax.dtick = 'L' + roundDTick(roughDTick, base, roundBase10); - } - else { + } else { // include intermediates between powers of 10, // labeled with small digits // ax.dtick = "D2" (show 2 and 5) or "D1" (show all digits) ax.dtick = (roughDTick > 0.3) ? 'D2' : 'D1'; } - } - else if(ax.type === 'category' || ax.type === 'multicategory') { + } else if(ax.type === 'category' || ax.type === 'multicategory') { ax.tick0 = 0; ax.dtick = Math.ceil(Math.max(roughDTick, 1)); - } - else if(isAngular(ax)) { + } else if(isAngular(ax)) { ax.tick0 = 0; base = 1; ax.dtick = roundDTick(roughDTick, base, roundAngles); - } - else { + } else { // auto ticks always start at 0 ax.tick0 = 0; base = getBase(10); @@ -817,8 +801,7 @@ function autoTickRound(ax) { if(tick0len > 10 || tick0str.substr(5) !== '01-01') ax._tickround = 'd'; // show the month unless ticks are full multiples of a year else ax._tickround = (+(dtick.substr(1)) % 12 === 0) ? 'y' : 'm'; - } - else if((dtick >= ONEDAY && tick0len <= 10) || (dtick >= ONEDAY * 15)) ax._tickround = 'd'; + } else if((dtick >= ONEDAY && tick0len <= 10) || (dtick >= ONEDAY * 15)) ax._tickround = 'd'; else if((dtick >= ONEMIN && tick0len <= 16) || (dtick >= ONEHOUR)) ax._tickround = 'M'; else if((dtick >= ONESEC && tick0len <= 19) || (dtick >= ONEMIN)) ax._tickround = 'S'; else { @@ -833,8 +816,7 @@ function autoTickRound(ax) { // something, fall back on maximum precision if(ax._tickround < 0) ax._tickround = 4; } - } - else if(isNumeric(dtick) || dtick.charAt(0) === 'L') { + } else if(isNumeric(dtick) || dtick.charAt(0) === 'L') { // linear or log (except D1, D2) var rng = ax.range.map(ax.r2d || Number); if(!isNumeric(dtick)) dtick = Number(dtick.substr(1)); @@ -847,12 +829,12 @@ function autoTickRound(ax) { if(Math.abs(rangeexp) > 3) { if(isSIFormat(ax.exponentformat) && !beyondSI(rangeexp)) { ax._tickexponent = 3 * Math.round((rangeexp - 1) / 3); - } - else ax._tickexponent = rangeexp; + } else ax._tickexponent = rangeexp; } + } else { + // D1 or D2 (log) + ax._tickround = null; } - // D1 or D2 (log) - else ax._tickround = null; } // months and years don't have constant millisecond values @@ -886,8 +868,7 @@ axes.tickIncrement = function(x, dtick, axrev, calendar) { return Math.floor(x2) + Math.log(d3.round(Math.pow(10, frac), 1)) / Math.LN10; - } - else throw 'unrecognized dtick ' + String(dtick); + } else throw 'unrecognized dtick ' + String(dtick); }; // calculate the first tick on an axis @@ -937,21 +918,18 @@ axes.tickFirst = function(ax) { } Lib.error('tickFirst did not converge', ax); return t0; - } + } else if(tType === 'L') { + // Log scales: Linear, Digits - // Log scales: Linear, Digits - else if(tType === 'L') { return Math.log(sRound( (Math.pow(10, r0) - tick0) / dtNum) * dtNum + tick0) / Math.LN10; - } - else if(tType === 'D') { + } else if(tType === 'D') { var tickset = (dtick === 'D2') ? roundLog2 : roundLog1; var frac = Lib.roundUp(Lib.mod(r0, 1), tickset, axrev); return Math.floor(r0) + Math.log(d3.round(Math.pow(10, frac), 1)) / Math.LN10; - } - else throw 'unrecognized dtick ' + String(dtick); + } else throw 'unrecognized dtick ' + String(dtick); }; // draw the text for one tick. @@ -1102,8 +1080,7 @@ function formatDate(ax, out, hover, extraPrecision) { if(dateStr === '00:00:00' || dateStr === '00:00') { dateStr = headStr; headStr = ''; - } - else if(dateStr.length === 8) { + } else if(dateStr.length === 8) { // strip off seconds if they're zero (zero fractional seconds // are already omitted) // but we never remove minutes and leave just hours @@ -1117,8 +1094,7 @@ function formatDate(ax, out, hover, extraPrecision) { // except for year headPart: turn this into "Jan 1, 2000" etc. if(tr === 'd') dateStr += ', ' + headStr; else dateStr = headStr + (dateStr ? ', ' + dateStr : ''); - } - else if(!ax._inCalcTicks || (headStr !== ax._prevDateHead)) { + } else if(!ax._inCalcTicks || (headStr !== ax._prevDateHead)) { dateStr += '
' + headStr; ax._prevDateHead = headStr; } @@ -1150,8 +1126,7 @@ function formatLog(ax, out, hover, extraPrecision, hideexp) { if(tickformat || (dtChar0 === 'L')) { out.text = numFormat(Math.pow(10, x), ax, hideexp, extraPrecision); - } - else if(isNumeric(dtick) || ((dtChar0 === 'D') && (Lib.mod(x + 0.01, 1) < 0.1))) { + } else if(isNumeric(dtick) || ((dtChar0 === 'D') && (Lib.mod(x + 0.01, 1) < 0.1))) { var p = Math.round(x); var absP = Math.abs(p); var exponentFormat = ax.exponentformat; @@ -1161,22 +1136,18 @@ function formatLog(ax, out, hover, extraPrecision, hideexp) { else out.text = '10' + (p > 1 ? '' : MINUS_SIGN) + absP + ''; out.fontSize *= 1.25; - } - else if((exponentFormat === 'e' || exponentFormat === 'E') && absP > 2) { + } else if((exponentFormat === 'e' || exponentFormat === 'E') && absP > 2) { out.text = '1' + exponentFormat + (p > 0 ? '+' : MINUS_SIGN) + absP; - } - else { + } else { out.text = numFormat(Math.pow(10, x), ax, '', 'fakehover'); if(dtick === 'D1' && ax._id.charAt(0) === 'y') { out.dy -= out.fontSize / 6; } } - } - else if(dtChar0 === 'D') { + } else if(dtChar0 === 'D') { out.text = String(Math.round(Math.pow(10, Lib.mod(x, 1)))); out.fontSize *= 0.75; - } - else throw 'unrecognized dtick ' + String(dtick); + } else throw 'unrecognized dtick ' + String(dtick); // if 9's are printed on log scale, move the 10's away a bit if(ax.dtick === 'D1') { @@ -1184,8 +1155,7 @@ function formatLog(ax, out, hover, extraPrecision, hideexp) { if(firstChar === '0' || firstChar === '1') { if(ax._id.charAt(0) === 'y') { out.dx -= out.fontSize / 4; - } - else { + } else { out.dy += out.fontSize / 2; out.dx += (ax.range[1] > ax.range[0] ? 1 : -1) * out.fontSize * (x < 0 ? 0.5 : 0.25); @@ -1370,8 +1340,7 @@ function numFormat(v, ax, fmtoverride, hover) { // 0 is just 0, but may get exponent if it's the last tick v = '0'; isNeg = false; - } - else { + } else { v += e; // take out a common exponent, if any if(exponent) { @@ -1384,8 +1353,7 @@ function numFormat(v, ax, fmtoverride, hover) { v = String(Math.round(v)); v = v.substr(0, v.length + tickRound); for(var i = tickRound; i < 0; i++) v += '0'; - } - else { + } else { v = String(v); var dp = v.indexOf('.') + 1; if(dp) v = v.substr(0, dp + tickRound).replace(/\.?0+$/, ''); @@ -1405,14 +1373,11 @@ function numFormat(v, ax, fmtoverride, hover) { if(exponentFormat === 'e' || exponentFormat === 'E') { v += exponentFormat + signedExponent; - } - else if(exponentFormat === 'power') { + } else if(exponentFormat === 'power') { v += '×10' + signedExponent + ''; - } - else if(exponentFormat === 'B' && exponent === 9) { + } else if(exponentFormat === 'B' && exponent === 9) { v += 'B'; - } - else if(isSIFormat(exponentFormat)) { + } else if(isSIFormat(exponentFormat)) { v += SIPREFIXES[exponent / 3 + 5]; } } @@ -2344,8 +2309,7 @@ axes.drawGrid = function(gd, ax, opts) { var counterAx = opts.counterAxis; if(ax.showgrid === false) { vals = []; - } - else if(counterAx && axes.shouldShowZeroLine(gd, ax, counterAx)) { + } else if(counterAx && axes.shouldShowZeroLine(gd, ax, counterAx)) { var isArrayMode = ax.tickmode === 'array'; for(var i = 0; i < vals.length; i++) { var xi = vals[i].x; @@ -2980,8 +2944,7 @@ function swapAxisGroup(gd, xIds, yIds) { // type is special - if we find a mixture of linear and log, // coerce them all to linear on flipping coerceLinearX = true; - } - else if(xVali !== xVal) allEqual = false; + } else if(xVali !== xVal) allEqual = false; } for(j = 1; j < yFullAxes.length && allEqual; j++) { var yVali = yFullAxes[j][keyi]; @@ -2990,8 +2953,7 @@ function swapAxisGroup(gd, xIds, yIds) { // type is special - if we find a mixture of linear and log, // coerce them all to linear on flipping coerceLinearY = true; - } - else if(yFullAxes[j][keyi] !== yVal) allEqual = false; + } else if(yFullAxes[j][keyi] !== yVal) allEqual = false; } if(allEqual) { if(coerceLinearX) layout[xFullAxes[0]._name].type = 'linear'; diff --git a/src/plots/cartesian/axis_ids.js b/src/plots/cartesian/axis_ids.js index eb36d1bf1c2..940dc9c2530 100644 --- a/src/plots/cartesian/axis_ids.js +++ b/src/plots/cartesian/axis_ids.js @@ -99,8 +99,7 @@ exports.getFromTrace = function(gd, fullTrace, type) { if(scene.substr(0, 5) === 'scene') { ax = fullLayout[scene][type + 'axis']; } - } - else { + } else { ax = exports.getFromId(gd, fullTrace[type + 'axis'] || type); } diff --git a/src/plots/cartesian/constraints.js b/src/plots/cartesian/constraints.js index 4cf2f1b70b1..a6d31d3dd8f 100644 --- a/src/plots/cartesian/constraints.js +++ b/src/plots/cartesian/constraints.js @@ -157,8 +157,7 @@ function updateConstraintGroups(constraintGroups, thisGroup, thisID, scaleanchor thisGroup[thisID] = 1; thisGroupIndex = constraintGroups.length; constraintGroups.push(thisGroup); - } - else { + } else { thisGroupIndex = constraintGroups.indexOf(thisGroup); } @@ -256,8 +255,7 @@ exports.enforce = function enforceAxisConstraints(gd) { if(mode === 'range') { scaleZoom(ax, factor); - } - else { + } else { // mode === 'domain' var inputDomain = ax._inputDomain; diff --git a/src/plots/cartesian/dragbox.js b/src/plots/cartesian/dragbox.js index 25be88e3862..937a3ebc034 100644 --- a/src/plots/cartesian/dragbox.js +++ b/src/plots/cartesian/dragbox.js @@ -164,13 +164,13 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { if(e.shiftKey) { if(dragModeNow === 'pan') dragModeNow = 'zoom'; else if(!isSelectOrLasso(dragModeNow)) dragModeNow = 'pan'; - } - else if(e.ctrlKey) { + } else if(e.ctrlKey) { dragModeNow = 'pan'; } + } else { + // all other draggers just pan + dragModeNow = 'pan'; } - // all other draggers just pan - else dragModeNow = 'pan'; } if(dragModeNow === 'lasso') dragOptions.minDrag = 1; @@ -255,8 +255,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { if(clickmode.indexOf('event') > -1) { Fx.click(gd, evt, plotinfo.id); } - } - else if(numClicks === 1 && singleEnd) { + } else if(numClicks === 1 && singleEnd) { var ax = ns ? ya0 : xa0; var end = (ns === 's' || ew === 'w') ? 0 : 1; var attrStr = ax._name + '.range[' + end + ']'; @@ -269,8 +268,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { if(ns) { vAlign = (ns === 'n') ? 'top' : 'bottom'; if(ax.side === 'right') hAlign = 'right'; - } - else if(ew === 'e') hAlign = 'right'; + } else if(ew === 'e') hAlign = 'right'; if(gd._context.showAxisRangeEntryBoxes) { d3.select(dragger) @@ -368,8 +366,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { } else { noZoom(); } - } - else if(matches.isSubplotConstrained) { + } else if(matches.isSubplotConstrained) { if(dx > MINZOOM || dy > MINZOOM) { zoomMode = 'xy'; @@ -384,10 +381,10 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { } else { noZoom(); } - } - // look for small drags in one direction or the other, - // and only drag the other axis - else if(!yActive || dy < Math.min(Math.max(dx * 0.6, MINDRAG), MINZOOM)) { + } else if(!yActive || dy < Math.min(Math.max(dx * 0.6, MINDRAG), MINZOOM)) { + // look for small drags in one direction or the other, + // and only drag the other axis + if(dx < MINDRAG || !xActive) { noZoom(); } else { @@ -396,14 +393,12 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { zoomMode = 'x'; corners.attr('d', xCorners(box, y0)); } - } - else if(!xActive || dx < Math.min(dy * 0.6, MINZOOM)) { + } else if(!xActive || dx < Math.min(dy * 0.6, MINZOOM)) { box.l = 0; box.r = pw; zoomMode = 'y'; corners.attr('d', yCorners(box, x0)); - } - else { + } else { zoomMode = 'xy'; corners.attr('d', xyCorners(box)); } @@ -738,8 +733,7 @@ function makeDragBox(gd, plotinfo, x, y, w, h, ns, ew) { ax = axList[i]; if(!ax.fixedrange) attrs[ax._name + '.autorange'] = true; } - } - else if(doubleClickConfig === 'reset') { + } else if(doubleClickConfig === 'reset') { // when we're resetting, reset all linked axes too, so we get back // to the fully-auto-with-constraints situation if(xActive || links.isSubplotConstrained) axList = axList.concat(links.xaxes); @@ -974,12 +968,10 @@ function getEndText(ax, end) { // rounding here... can we clean up at all? if(ax.type === 'date') { return initialVal; - } - else if(ax.type === 'log') { + } else if(ax.type === 'log') { dig = Math.ceil(Math.max(0, -Math.log(diff) / Math.LN10)) + 3; return d3.format('.' + dig + 'g')(Math.pow(10, initialVal)); - } - else { // linear numeric (or category... but just show numbers here) + } else { // linear numeric (or category... but just show numbers here) dig = Math.floor(Math.log(Math.abs(initialVal)) / Math.LN10) - Math.floor(Math.log(diff) / Math.LN10) + 4; return d3.format('.' + String(dig) + 'g')(initialVal); @@ -1212,8 +1204,7 @@ function attachWheelEventHandler(element, handler) { if(!supportsPassive) { if(element.onwheel !== undefined) element.onwheel = handler; else if(element.onmousewheel !== undefined) element.onmousewheel = handler; - } - else { + } else { var wheelEventName = element.onwheel !== undefined ? 'wheel' : 'mousewheel'; if(element._onwheel) { diff --git a/src/plots/cartesian/index.js b/src/plots/cartesian/index.js index 8ff5a4678cd..fa1dd76df26 100644 --- a/src/plots/cartesian/index.js +++ b/src/plots/cartesian/index.js @@ -108,8 +108,7 @@ exports.finalizeSubplots = function(layoutIn, layoutOut) { if(!xi || (+ki.substr(5) < +xi.substr(5))) { xi = ki; } - } - else if(!yi || (+ki.substr(5) < +yi.substr(5))) { + } else if(!yi || (+ki.substr(5) < +yi.substr(5))) { yi = ki; } } @@ -331,17 +330,18 @@ exports.clean = function(newFullData, newFullLayout, oldFullData, oldFullLayout) } } - // if we've gotten rid of all cartesian traces, remove all the subplot svg items var hadCartesian = (oldFullLayout._has && oldFullLayout._has('cartesian')); var hasCartesian = (newFullLayout._has && newFullLayout._has('cartesian')); if(hadCartesian && !hasCartesian) { + // if we've gotten rid of all cartesian traces, remove all the subplot svg items + purgeSubplotLayers(oldFullLayout._cartesianlayer.selectAll('.subplot'), oldFullLayout); oldFullLayout._defs.selectAll('.axesclip').remove(); delete oldFullLayout._axisConstraintGroups; - } - // otherwise look for subplots we need to remove - else if(oldSubplotList.cartesian) { + } else if(oldSubplotList.cartesian) { + // otherwise look for subplots we need to remove + for(i = 0; i < oldSubplotList.cartesian.length; i++) { var oldSubplotId = oldSubplotList.cartesian[i]; if(!newPlots[oldSubplotId]) { @@ -468,8 +468,7 @@ function makeSubplotLayer(gd, plotinfo) { plotinfo.ylines = ensureSingle(plotgroup, 'path', 'ylines-above'); plotinfo.xaxislayer = ensureSingle(plotgroup, 'g', 'xaxislayer-above'); plotinfo.yaxislayer = ensureSingle(plotgroup, 'g', 'yaxislayer-above'); - } - else { + } else { var backLayer = ensureSingle(plotgroup, 'g', 'layer-subplot'); plotinfo.shapelayer = ensureSingle(backLayer, 'g', 'shapelayer'); plotinfo.imagelayer = ensureSingle(backLayer, 'g', 'imagelayer'); @@ -502,8 +501,7 @@ function makeSubplotLayer(gd, plotinfo) { plotinfo.xaxislayer = plotgroup.select('.xaxislayer-' + xLayer); plotinfo.yaxislayer = plotgroup.select('.yaxislayer-' + yLayer); } - } - else { + } else { var mainplotinfo = plotinfo.mainplotinfo; var mainplotgroup = mainplotinfo.plotgroup; var xId = id + '-x'; diff --git a/src/plots/cartesian/select.js b/src/plots/cartesian/select.js index fd8d3479772..5eee4416ef3 100644 --- a/src/plots/cartesian/select.js +++ b/src/plots/cartesian/select.js @@ -138,8 +138,7 @@ function prepSelect(e, startX, startY, dragOptions, mode) { if(dy < Math.min(dx * 0.6, MINSELECT)) direction = 'h'; else if(dx < Math.min(dy * 0.6, MINSELECT)) direction = 'v'; else direction = 'd'; - } - else { + } else { direction = fullLayout.selectdirection; } @@ -155,8 +154,7 @@ function prepSelect(e, startX, startY, dragOptions, mode) { 'h-4v' + (2 * MINSELECT) + 'h4Z' + 'M' + (currentPolygon.xmax - 1) + ',' + (y0 - MINSELECT) + 'h4v' + (2 * MINSELECT) + 'h-4Z'); - } - else if(direction === 'v') { + } else if(direction === 'v') { // vertical motion: make a horizontal box currentPolygon = [[0, y0], [0, y1], [pw, y1], [pw, y0]]; currentPolygon.xmin = Math.min(0, pw); @@ -167,8 +165,7 @@ function prepSelect(e, startX, startY, dragOptions, mode) { 'v-4h' + (2 * MINSELECT) + 'v4Z' + 'M' + (x0 - MINSELECT) + ',' + (currentPolygon.ymax - 1) + 'v4h' + (2 * MINSELECT) + 'v-4Z'); - } - else if(direction === 'd') { + } else if(direction === 'd') { // diagonal motion currentPolygon = [[x0, y0], [x0, y1], [x1, y1], [x1, y0]]; currentPolygon.xmin = Math.min(x0, x1); @@ -177,8 +174,7 @@ function prepSelect(e, startX, startY, dragOptions, mode) { currentPolygon.ymax = Math.max(y0, y1); corners.attr('d', 'M0,0Z'); } - } - else if(mode === 'lasso') { + } else if(mode === 'lasso') { filterPoly.addPt([x1, y1]); currentPolygon = filterPoly.filtered; } @@ -188,8 +184,7 @@ function prepSelect(e, startX, startY, dragOptions, mode) { mergedPolygons = mergePolygons(dragOptions.mergedPolygons, currentPolygon, subtract); currentPolygon.subtract = subtract; selectionTester = multiTester(dragOptions.selectionDefs.concat([currentPolygon])); - } - else { + } else { mergedPolygons = [currentPolygon]; selectionTester = polygonTester(currentPolygon); } @@ -219,8 +214,7 @@ function prepSelect(e, startX, startY, dragOptions, mode) { for(var j = 0; j < thisSelection.length; j++) { selection.push(thisSelection[j]); } - } - else selection = thisSelection; + } else selection = thisSelection; } eventData = {points: selection}; @@ -315,8 +309,7 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli if(isBinnedTrace ? isOnlyThisBinSelected(searchTraces, clickedPtInfo) : isOnlyOnePointSelected(searchTraces) && - (pointOrBinSelected = isPointOrBinSelected(clickedPtInfo))) - { + (pointOrBinSelected = isPointOrBinSelected(clickedPtInfo))) { if(polygonOutlines) polygonOutlines.remove(); for(i = 0; i < searchTraces.length; i++) { searchInfo = searchTraces[i]; @@ -348,8 +341,7 @@ function selectOnClick(evt, gd, xAxes, yAxes, subplot, dragOptions, polygonOutli for(var j = 0; j < thisTracesSelection.length; j++) { selection.push(thisTracesSelection[j]); } - } - else selection = thisTracesSelection; + } else selection = thisTracesSelection; } eventData = {points: selection}; @@ -712,8 +704,7 @@ function updateSelectedState(gd, searchTraces, eventData) { } } } - } - else { + } else { for(i = 0; i < searchTraces.length; i++) { trace = searchTraces[i].cd[0].trace; delete trace.selectedpoints; diff --git a/src/plots/cartesian/set_convert.js b/src/plots/cartesian/set_convert.js index bc99687a750..55bb4bdcb98 100644 --- a/src/plots/cartesian/set_convert.js +++ b/src/plots/cartesian/set_convert.js @@ -74,9 +74,7 @@ module.exports = function setConvert(ax, fullLayout) { var r0 = ax.range[0]; var r1 = ax.range[1]; return 0.5 * (r0 + r1 - 2 * LOG_CLIP * Math.abs(r0 - r1)); - } - - else return BADNUM; + } else return BADNUM; } /* @@ -99,8 +97,7 @@ module.exports = function setConvert(ax, fullLayout) { var msecTenths = Math.floor(Lib.mod(v + 0.05, 1) * 10); var msRounded = Math.round(v - msecTenths / 10); ms = dateTime2ms(new Date(msRounded)) + msecTenths / 10; - } - else return BADNUM; + } else return BADNUM; } return ms; } @@ -206,8 +203,7 @@ module.exports = function setConvert(ax, fullLayout) { ax.p2d = ax.p2r = p2l; ax.cleanPos = ensureNumber; - } - else if(ax.type === 'log') { + } else if(ax.type === 'log') { // d and c are data vals, r and l are logged (but d and r need cleaning) ax.d2r = ax.d2l = function(v, clip) { return toLog(cleanNumber(v), clip); }; ax.r2d = ax.r2c = function(v) { return fromLog(cleanNumber(v)); }; @@ -225,8 +221,7 @@ module.exports = function setConvert(ax, fullLayout) { ax.p2r = p2l; ax.cleanPos = ensureNumber; - } - else if(ax.type === 'date') { + } else if(ax.type === 'date') { // r and d are date strings, l and c are ms /* @@ -246,8 +241,7 @@ module.exports = function setConvert(ax, fullLayout) { ax.p2d = ax.p2r = function(px, r, calendar) { return ms2dt(p2l(px), r, calendar); }; ax.cleanPos = function(v) { return Lib.cleanDate(v, BADNUM, ax.calendar); }; - } - else if(ax.type === 'category') { + } else if(ax.type === 'category') { // d is categories (string) // c and l are indices (numbers) // r is categories or numbers @@ -274,8 +268,7 @@ module.exports = function setConvert(ax, fullLayout) { if(typeof v === 'string' && v !== '') return v; return ensureNumber(v); }; - } - else if(ax.type === 'multicategory') { + } else if(ax.type === 'multicategory') { // N.B. multicategory axes don't define d2c and d2l, // as 'data-to-calcdata' conversion needs to take into // account all data array items as in ax.makeCalcdata. @@ -432,13 +425,11 @@ module.exports = function setConvert(ax, fullLayout) { range[1] = ax.l2r(linCenter + 1000); break; } - } - else { + } else { if(!isNumeric(range[i])) { if(isNumeric(range[1 - i])) { range[i] = range[1 - i] * (i ? 10 : 0.1); - } - else { + } else { ax[rangeAttr] = dflt; break; } @@ -532,8 +523,7 @@ module.exports = function setConvert(ax, fullLayout) { for(i = 0; i < len; i++) { arrayOut[i] = ax.d2c(arrayIn[i], 0, cal); } - } - else { + } else { var v0 = ((axLetter + '0') in trace) ? ax.d2c(trace[axLetter + '0'], 0, cal) : 0; var dv = (trace['d' + axLetter]) ? Number(trace['d' + axLetter]) : 1; diff --git a/src/plots/cartesian/type_defaults.js b/src/plots/cartesian/type_defaults.js index 2f4e620710c..16237397bf8 100644 --- a/src/plots/cartesian/type_defaults.js +++ b/src/plots/cartesian/type_defaults.js @@ -78,8 +78,7 @@ function setAutoType(ax, data) { } ax.type = autoType(boxPositions, calendar, opts); - } - else if(d0.type === 'splom') { + } else if(d0.type === 'splom') { var dimensions = d0.dimensions; var diag = d0._diag; for(i = 0; i < dimensions.length; i++) { @@ -89,8 +88,7 @@ function setAutoType(ax, data) { break; } } - } - else { + } else { ax.type = autoType(d0[axLetter] || [d0[axLetter + '0']], calendar, opts); } } @@ -109,8 +107,7 @@ function getFirstNonEmptyTrace(data, id, axLetter) { if((trace[axLetter + 'axis'] || axLetter) === id) { if(isBoxWithoutPositionCoords(trace, axLetter)) { return trace; - } - else if((trace[axLetter] || []).length || trace[axLetter + '0']) { + } else if((trace[axLetter] || []).length || trace[axLetter + '0']) { return trace; } } diff --git a/src/plots/geo/geo.js b/src/plots/geo/geo.js index df7a220aa54..c0aba22e870 100644 --- a/src/plots/geo/geo.js +++ b/src/plots/geo/geo.js @@ -423,8 +423,7 @@ proto.updateFx = function(fullLayout, geoLayout) { if(!gd._context._scrollZoom.geo) { bgRect.on('wheel.zoom', null); } - } - else if(dragMode === 'select' || dragMode === 'lasso') { + } else if(dragMode === 'select' || dragMode === 'lasso') { bgRect.on('.zoom', null); dragOptions.prepFn = function(e, startX, startY) { diff --git a/src/plots/geo/zoom.js b/src/plots/geo/zoom.js index 293ffed0127..ee632a22af9 100644 --- a/src/plots/geo/zoom.js +++ b/src/plots/geo/zoom.js @@ -155,8 +155,7 @@ function zoomNonClipped(geo, projection) { if(!zoomPoint) { mouse0 = mouse1; zoomPoint = position(mouse0); - } - else if(position(mouse1)) { + } else if(position(mouse1)) { point1 = position(mouse1); rotate1 = [lastRotate[0] + (point1[0] - zoomPoint[0]), rotate0[1], rotate0[2]]; projection.rotate(rotate1); @@ -221,12 +220,12 @@ function zoomClipped(geo, projection) { // maybe this point is the start... we'll find out next time! mouse0 = mouse1; zoomPoint = position(projection, mouse0); - } - // check if the point is on the map - // if not, don't do anything new but scale - // if it is, then we can assume between will exist below - // so we don't need the 'bank' function, whatever that is. - else if(position(projection, mouse1)) { + } else if(position(projection, mouse1)) { + // check if the point is on the map + // if not, don't do anything new but scale + // if it is, then we can assume between will exist below + // so we don't need the 'bank' function, whatever that is. + // go back to original projection temporarily // except for scale... that's kind of independent? projection diff --git a/src/plots/get_data.js b/src/plots/get_data.js index b46e53b3e06..b543c2f75bb 100644 --- a/src/plots/get_data.js +++ b/src/plots/get_data.js @@ -116,8 +116,7 @@ exports.getSubplotData = function getSubplotData(data, type, subplotId) { if(trace[attr[0]] === subplotX && trace[attr[1]] === subplotY) { subplotData.push(trace); } - } - else { + } else { if(trace[attr] === subplotId) subplotData.push(trace); } } diff --git a/src/plots/gl2d/camera.js b/src/plots/gl2d/camera.js index 19e3025da07..caad13024f5 100644 --- a/src/plots/gl2d/camera.js +++ b/src/plots/gl2d/camera.js @@ -107,8 +107,7 @@ function createCamera(scene) { dataBox[i0 + 2] = range1; result.dataBox = dataBox; scene.setRanges(dataBox); - } - else { + } else { scene.selectBox.selectBox = [0, 0, 1, 1]; scene.glplot.setDirty(); } @@ -165,14 +164,12 @@ function createCamera(scene) { result.boxEnd[1] = dataBox[1]; result.boxEnd[0] = result.boxStart[0] + (dataBox[1] - result.boxStart[1]) / Math.abs(dydx); - } - else if(result.boxEnd[1] > dataBox[3]) { + } else if(result.boxEnd[1] > dataBox[3]) { result.boxEnd[1] = dataBox[3]; result.boxEnd[0] = result.boxStart[0] + (dataBox[3] - result.boxStart[1]) / Math.abs(dydx); } - } - else { + } else { result.boxEnd[0] = result.boxStart[0] + Math.abs(dy) / dydx * (dx >= 0 ? 1 : -1); @@ -180,21 +177,19 @@ function createCamera(scene) { result.boxEnd[0] = dataBox[0]; result.boxEnd[1] = result.boxStart[1] + (dataBox[0] - result.boxStart[0]) * Math.abs(dydx); - } - else if(result.boxEnd[0] > dataBox[2]) { + } else if(result.boxEnd[0] > dataBox[2]) { result.boxEnd[0] = dataBox[2]; result.boxEnd[1] = result.boxStart[1] + (dataBox[2] - result.boxStart[0]) * Math.abs(dydx); } } - } - // otherwise clamp small changes to the origin so we get 1D zoom - else { + } else { + // otherwise clamp small changes to the origin so we get 1D zoom + if(smallDx) result.boxEnd[0] = result.boxStart[0]; if(smallDy) result.boxEnd[1] = result.boxStart[1]; } - } - else if(result.boxEnabled) { + } else if(result.boxEnabled) { dx = result.boxStart[0] !== result.boxEnd[0]; dy = result.boxStart[1] !== result.boxEnd[1]; if(dx || dy) { @@ -207,15 +202,14 @@ function createCamera(scene) { scene.yaxis.autorange = false; } scene.relayoutCallback(); - } - else { + } else { scene.glplot.setDirty(); } result.boxEnabled = false; result.boxInited = false; - } - // if box was inited but button released then - reset the box - else if(result.boxInited) { + } else if(result.boxInited) { + // if box was inited but button released then - reset the box + result.boxInited = false; } break; @@ -250,8 +244,7 @@ function createCamera(scene) { unSetAutoRange(); scene.cameraChanged(); scene.handleAnnotations(); - } - else if(result.panning) { + } else if(result.panning) { result.panning = false; scene.relayoutCallback(); } diff --git a/src/plots/gl2d/convert.js b/src/plots/gl2d/convert.js index 0aaaa1fceb1..e0ae34e2211 100644 --- a/src/plots/gl2d/convert.js +++ b/src/plots/gl2d/convert.js @@ -214,8 +214,7 @@ proto.getLabelPad = function(axisName, ax) { return (ax.side === 'top') ? -10 + fontSize * (offsetBase + (showticklabels ? 1 : 0)) : -10 + fontSize * (offsetBase + (showticklabels ? 0.5 : 0)); - } - else if(axisName === 'yaxis') { + } else if(axisName === 'yaxis') { return (ax.side === 'right') ? 10 + fontSize * (offsetBase + (showticklabels ? 1 : 0.5)) : 10 + fontSize * (offsetBase + (showticklabels ? 0.5 : 0)); diff --git a/src/plots/gl2d/scene2d.js b/src/plots/gl2d/scene2d.js index 475a67eac70..e1561508b66 100644 --- a/src/plots/gl2d/scene2d.js +++ b/src/plots/gl2d/scene2d.js @@ -110,8 +110,7 @@ proto.makeFramework = function() { this.canvas = STATIC_CANVAS; this.gl = STATIC_CONTEXT; - } - else { + } else { var liveCanvas = this.container.querySelector('.gl-canvas-focus'); var gl = getContext({ @@ -537,11 +536,9 @@ proto.updateFx = function(dragmode) { // set proper cursor if(dragmode === 'pan') { this.mouseContainer.style.cursor = 'move'; - } - else if(dragmode === 'zoom') { + } else if(dragmode === 'zoom') { this.mouseContainer.style.cursor = 'crosshair'; - } - else { + } else { this.mouseContainer.style.cursor = null; } }; @@ -612,8 +609,7 @@ proto.draw = function() { } glplot.setDirty(); - } - else if(!camera.panning && this.isMouseOver) { + } else if(!camera.panning && this.isMouseOver) { this.selectBox.enabled = false; var size = fullLayout._size; diff --git a/src/plots/gl3d/scene.js b/src/plots/gl3d/scene.js index 972b28ccc71..b15ef824713 100644 --- a/src/plots/gl3d/scene.js +++ b/src/plots/gl3d/scene.js @@ -232,8 +232,7 @@ function tryCreatePlot(scene, cameraObject, pixelRatio, canvas, gl) { try { scene.glplot = createPlot(glplotOptions); - } - catch(e) { + } catch(e) { return false; } @@ -578,8 +577,7 @@ proto.plot = function(sceneData, fullLayout, layout) { if(axisType in axisTypeRatios) { axisTypeRatios[axisType].acc *= dataScale[i]; axisTypeRatios[axisType].count += 1; - } - else { + } else { axisTypeRatios[axisType] = { acc: dataScale[i], count: 1 diff --git a/src/plots/plots.js b/src/plots/plots.js index 119fb6e06dc..3ac177d31bc 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -161,8 +161,7 @@ plots.addLinks = function(gd) { // Align the text at the left attrs['text-anchor'] = 'start'; attrs.x = 5; - } - else { + } else { // Align the text at the right attrs['text-anchor'] = 'end'; attrs.x = fullLayout._paper.attr('width') - 7; @@ -199,8 +198,7 @@ function positionPlayWithData(gd, container) { link.on('click', function() { plots.sendDataToCloud(gd); }); - } - else { + } else { var path = window.location.pathname.split('/'); var query = window.location.search; link.attr({ @@ -347,8 +345,7 @@ plots.supplyDefaults = function(gd, opts) { if(!newLayout.width) newFullLayout.width = oldWidth; if(!newLayout.height) newFullLayout.height = oldHeight; plots.sanitizeMargins(newFullLayout); - } - else { + } else { // coerce the updated layout and autosize if needed plots.supplyLayoutGlobalDefaults(newLayout, newFullLayout, formatObj); @@ -649,8 +646,7 @@ function getFormatObj(gd, formatKeys) { if(!formatObj[formatKey]) { if(newFormat[formatKey]) { formatObj[formatKey] = newFormat[formatKey]; - } - else formatFinished = false; + } else formatFinished = false; } } if(formatFinished) formatDone = true; @@ -1068,8 +1064,7 @@ plots.supplyDataDefaults = function(dataIn, dataOut, layout, fullLayout) { pushModule(fullExpandedTrace); } - } - else { + } else { // add identify refs for consistency with transformed traces fullTrace._fullInput = fullTrace; fullTrace._expandedInput = fullTrace; @@ -1341,8 +1336,7 @@ plots.supplyTransformDefaults = function(traceIn, traceOut, layout) { transformOut._module = _module; Lib.pushUnique(transformModules, _module); - } - else { + } else { transformOut = Lib.extendFlat({}, transformIn); } @@ -1488,8 +1482,7 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) { // somehow we get a few extra px height sometimes... // just hide it document.body.style.overflow = 'hidden'; - } - else { + } else { // plotly.js - let the developers do what they want, either // provide height and width for the container div, // specify size in layout, or take the defaults, @@ -1781,8 +1774,7 @@ plots.autoMargin = function(gd, id, o) { if(!o) { delete pushMargin[id]; delete pushMarginIds[id]; - } - else { + } else { var pad = o.pad; if(pad === undefined) { var margin = fullLayout.margin; @@ -1967,8 +1959,7 @@ plots.graphJson = function(gd, dataonly, mode, output, useDefaults) { if(v.substr(v.length - 3) === 'src') { continue; } - } - else if(mode === 'keepstream') { + } else if(mode === 'keepstream') { // keep sourced data if it's being streamed. // similar to keepref, but if the 'stream' object exists // in a trace, we will keep the data array. @@ -1978,8 +1969,7 @@ plots.graphJson = function(gd, dataonly, mode, output, useDefaults) { continue; } } - } - else if(mode !== 'keepall') { + } else if(mode !== 'keepall') { // keepref: remove sourced data but only // if the source tag is well-formed src = d[v + 'src']; @@ -2215,8 +2205,7 @@ plots.extendObjectWithContainers = function(dest, src, containerPaths) { if(containerVal === undefined) { Lib.nestedProperty(containerObj, containerPaths[i]).set(null); - } - else { + } else { containerProp.set(null); Lib.nestedProperty(containerObj, containerPaths[i]).set(containerVal); } @@ -2884,8 +2873,7 @@ function doCrossTraceCalc(gd) { methods[j](gd, spInfo, sp); } } - } - else { + } else { for(j = 0; j < methods.length; j++) { methods[j](gd); } diff --git a/src/plots/ternary/ternary.js b/src/plots/ternary/ternary.js index f0511d7dda5..59d0245ce93 100644 --- a/src/plots/ternary/ternary.js +++ b/src/plots/ternary/ternary.js @@ -187,8 +187,7 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { if(wmax > whRatio * hmax) { h = hmax; w = h * whRatio; - } - else { + } else { w = wmax; h = w / whRatio; } @@ -520,15 +519,13 @@ proto.initInteractions = function() { dragOptions.clickFn = clickZoomPan; dragOptions.doneFn = zoomDone; zoomPrep(e, startX, startY); - } - else if(dragModeNow === 'pan') { + } else if(dragModeNow === 'pan') { dragOptions.moveFn = plotDrag; dragOptions.clickFn = clickZoomPan; dragOptions.doneFn = dragDone; panPrep(); clearSelect(gd); - } - else if(dragModeNow === 'select' || dragModeNow === 'lasso') { + } else if(dragModeNow === 'select' || dragModeNow === 'lasso') { prepSelect(e, startX, startY, dragOptions, dragModeNow); } } @@ -622,8 +619,7 @@ proto.initInteractions = function() { mins = mins0; zb.attr('d', path0); corners.attr('d', 'M0,0Z'); - } - else { + } else { mins = { a: mins0.a + afrac * span0, b: mins0.b + bfrac * span0, @@ -690,8 +686,7 @@ proto.initInteractions = function() { if(minsorted[1] + minsorted[0] / 2 < 0) { minsorted[2] += minsorted[0] + minsorted[1]; minsorted[0] = minsorted[1] = 0; - } - else { + } else { minsorted[2] += minsorted[0] / 2; minsorted[1] += minsorted[0] / 2; minsorted[0] = 0; diff --git a/src/snapshot/tosvg.js b/src/snapshot/tosvg.js index eec1305544c..507bab751fd 100644 --- a/src/snapshot/tosvg.js +++ b/src/snapshot/tosvg.js @@ -100,8 +100,7 @@ module.exports = function toSVG(gd, format, scale) { if(this.style.visibility === 'hidden' || this.style.display === 'none') { txt.remove(); return; - } - else { + } else { // clear other visibility/display values to default // to not potentially confuse non-browser SVG implementations txt.style({visibility: null, display: null}); diff --git a/src/traces/bar/cross_trace_calc.js b/src/traces/bar/cross_trace_calc.js index a6f58fa6a27..e98728a384d 100644 --- a/src/traces/bar/cross_trace_calc.js +++ b/src/traces/bar/cross_trace_calc.js @@ -139,8 +139,7 @@ function initBase(gd, pa, sa, calcTraces) { if(isNumeric(b)) { cd[j].b = +b; cd[j].hasB = 1; - } - else cd[j].b = 0; + } else cd[j].b = 0; } for(; j < cd.length; j++) { cd[j].b = 0; diff --git a/src/traces/bar/hover.js b/src/traces/bar/hover.js index 841d3ba00ab..2edcc6884e3 100644 --- a/src/traces/bar/hover.js +++ b/src/traces/bar/hover.js @@ -95,8 +95,7 @@ function hoverOnBars(pointData, xval, yval, hovermode) { sizeLetter = 'x'; dx = sizeFn; dy = positionFn; - } - else { + } else { posVal = xval; sizeVal = yval; posLetter = 'x'; diff --git a/src/traces/carpet/axis_defaults.js b/src/traces/carpet/axis_defaults.js index a14341c2943..063b43c1bc1 100644 --- a/src/traces/carpet/axis_defaults.js +++ b/src/traces/carpet/axis_defaults.js @@ -57,8 +57,7 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, options) if(containerOut.type === '-') { containerOut.type = 'linear'; - } - else { + } else { // copy autoType back to input axis // note that if this object didn't exist // in the input layout, we have to put it in diff --git a/src/traces/carpet/xy_defaults.js b/src/traces/carpet/xy_defaults.js index f24d4dcc73b..947c1b096e9 100644 --- a/src/traces/carpet/xy_defaults.js +++ b/src/traces/carpet/xy_defaults.js @@ -26,8 +26,7 @@ module.exports = function handleXYDefaults(traceIn, traceOut, coerce) { if(traceOut.a && traceOut.a.length) len = Math.min(len, traceOut.a.length); if(traceOut.b && traceOut.b.length) len = Math.min(len, traceOut.b.length); traceOut._length = len; - } - else traceOut._length = null; + } else traceOut._length = null; return true; }; diff --git a/src/traces/contour/constraint_defaults.js b/src/traces/contour/constraint_defaults.js index 36f35ecd80a..9eba7a16534 100644 --- a/src/traces/contour/constraint_defaults.js +++ b/src/traces/contour/constraint_defaults.js @@ -31,8 +31,7 @@ module.exports = function handleConstraintDefaults(traceIn, traceOut, coerce, la if(operation === '=') { showLines = contours.showlines = true; - } - else { + } else { showLines = coerce('contours.showlines'); fillColor = coerce('fillcolor', addOpacity( (traceIn.line || {}).color || defaultColor, 0.5 diff --git a/src/traces/contour/defaults.js b/src/traces/contour/defaults.js index 1dddb34d561..62c904c99a1 100644 --- a/src/traces/contour/defaults.js +++ b/src/traces/contour/defaults.js @@ -41,8 +41,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout if(isConstraint) { handleConstraintDefaults(traceIn, traceOut, coerce, layout, defaultColor); - } - else { + } else { handleContoursDefaults(traceIn, traceOut, coerce, coerce2); handleStyleDefaults(traceIn, traceOut, coerce, layout); } diff --git a/src/traces/contour/find_all_paths.js b/src/traces/contour/find_all_paths.js index 17ac8cd9469..f6104f28b6f 100644 --- a/src/traces/contour/find_all_paths.js +++ b/src/traces/contour/find_all_paths.js @@ -69,8 +69,7 @@ function makePath(pi, loc, edgeflag, xtol, ytol) { if(mi > 20) { mi = constants.CHOOSESADDLE[mi][(marchStep[0] || marchStep[1]) < 0 ? 0 : 1]; pi.crossings[locStr] = constants.SADDLEREMAINDER[mi]; - } - else { + } else { delete pi.crossings[locStr]; } @@ -134,8 +133,7 @@ function makePath(pi, loc, edgeflag, xtol, ytol) { for(cnt2 = cnt - 1; cnt2 >= cropstart; cnt2--) { if(distgroup + alldists[cnt2] < distThreshold) { distgroup += alldists[cnt2]; - } - else break; + } else break; } // closed path with close points wrapping around the boundary? @@ -143,8 +141,7 @@ function makePath(pi, loc, edgeflag, xtol, ytol) { for(cnt3 = 0; cnt3 < cnt2; cnt3++) { if(distgroup + alldists[cnt3] < distThreshold) { distgroup += alldists[cnt3]; - } - else break; + } else break; } } ptcnt = cnt - cnt2 + cnt3 + 1; @@ -184,8 +181,7 @@ function makePath(pi, loc, edgeflag, xtol, ytol) { else if(closedpath) { pts.pop(); pi.paths.push(pts); - } - else { + } else { if(!edgeflag) { Lib.log('Unclosed interior contour?', pi.level, startLocStr, pts.join('L')); @@ -210,8 +206,7 @@ function makePath(pi, loc, edgeflag, xtol, ytol) { if(j === i) { // the path is now closed pi.paths.push(pts.concat(edgepathj)); - } - else { + } else { if(j > i) j--; pi.edgepaths[j] = edgepathj.concat(pts, edgepathi); } @@ -247,13 +242,11 @@ function startStep(mi, edgeflag, loc) { if(mi === 208 || mi === 1114) { // if we're starting at the left side, we must be going right dx = loc[0] === 0 ? 1 : -1; - } - else { + } else { // if we're starting at the bottom, we must be going up dy = loc[1] === 0 ? 1 : -1; } - } - else if(constants.BOTTOMSTART.indexOf(mi) !== -1) dy = 1; + } else if(constants.BOTTOMSTART.indexOf(mi) !== -1) dy = 1; else if(constants.LEFTSTART.indexOf(mi) !== -1) dx = 1; else if(constants.TOPSTART.indexOf(mi) !== -1) dy = -1; else dx = -1; @@ -288,8 +281,7 @@ function getInterpPx(pi, loc, step) { return [xa.c2p((1 - dx) * pi.x[locx] + dx * pi.x[locx + 1], true), ya.c2p(pi.y[locy], true), locx + dx, locy]; - } - else { + } else { var dy = (pi.level - zxy) / (pi.z[locy + 1][locx] - zxy); return [xa.c2p(pi.x[locx], true), ya.c2p((1 - dy) * pi.y[locy] + dy * pi.y[locy + 1], true), diff --git a/src/traces/contour/hover.js b/src/traces/contour/hover.js index d9c75f392db..aebc36e86eb 100644 --- a/src/traces/contour/hover.js +++ b/src/traces/contour/hover.js @@ -22,8 +22,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay if(trace.contours.type === 'constraint') { if(trace.fillcolor && Color.opacity(trace.fillcolor)) { hoverPt.color = Color.addOpacity(trace.fillcolor, 1); - } - else if(trace.contours.showlines && Color.opacity(trace.line.color)) { + } else if(trace.contours.showlines && Color.opacity(trace.line.color)) { hoverPt.color = Color.addOpacity(trace.line.color, 1); } } diff --git a/src/traces/contour/make_color_map.js b/src/traces/contour/make_color_map.js index 4641aff2024..74c1ca90889 100644 --- a/src/traces/contour/make_color_map.js +++ b/src/traces/contour/make_color_map.js @@ -69,8 +69,7 @@ module.exports = function makeColorMap(trace) { domain.push(zmax); range.push(range[range.length - 1]); } - } - else { + } else { for(i = 0; i < len; i++) { si = scl[i]; diff --git a/src/traces/contour/plot.js b/src/traces/contour/plot.js index 9f49c10403a..0411e864695 100644 --- a/src/traces/contour/plot.js +++ b/src/traces/contour/plot.js @@ -173,15 +173,13 @@ function joinAllPaths(pi, perimeter) { newendpt = ptNew; nexti = possiblei; } - } - else if(Math.abs(endpt[1] - newendpt[1]) < 0.01) { + } else if(Math.abs(endpt[1] - newendpt[1]) < 0.01) { if(Math.abs(endpt[1] - ptNew[1]) < 0.01 && (ptNew[0] - endpt[0]) * (newendpt[0] - ptNew[0]) >= 0) { newendpt = ptNew; nexti = possiblei; } - } - else { + } else { Lib.log('endpt to newendpt is not vert. or horz.', endpt, newendpt, ptNew); } @@ -397,13 +395,11 @@ exports.createLineClip = function(lineContainer, clipLinesForLabels, gd, uid) { exports.labelFormatter = function(contours, colorbar, fullLayout) { if(contours.labelformat) { return fullLayout._d3locale.numberFormat(contours.labelformat); - } - else { + } else { var formatAxis; if(colorbar) { formatAxis = colorbar.axis; - } - else { + } else { formatAxis = { type: 'linear', _id: 'ycontour', @@ -415,10 +411,8 @@ exports.labelFormatter = function(contours, colorbar, fullLayout) { var value = contours.value; if(Array.isArray(value)) { formatAxis.range = [value[0], value[value.length - 1]]; - } - else formatAxis.range = [value, value]; - } - else { + } else formatAxis.range = [value, value]; + } else { formatAxis.range = [contours.start, contours.end]; formatAxis.nticks = (contours.end - contours.start) / contours.size; } @@ -462,8 +456,7 @@ exports.findBestTextLocation = function(path, pathBounds, textOpts, labelData, p dp = pathBounds.len / costConstants.INITIALSEARCHPOINTS; p0 = pathBounds.min + dp / 2; pMax = pathBounds.max; - } - else { + } else { dp = (pathBounds.len - textWidth) / (costConstants.INITIALSEARCHPOINTS + 1); p0 = pathBounds.min + dp + textWidth / 2; pMax = pathBounds.max - (dp + textWidth) / 2; @@ -657,8 +650,7 @@ function clipGaps(plotGroup, plotinfo, gd, cd0, perimeter) { var path = Lib.ensureSingle(clipPath, 'path', ''); path.attr('d', fullpath); - } - else clipId = null; + } else clipId = null; Drawing.setClipUrl(plotGroup, clipId, gd); } diff --git a/src/traces/contour/set_contours.js b/src/traces/contour/set_contours.js index 97ade1252dc..0804413a4a3 100644 --- a/src/traces/contour/set_contours.js +++ b/src/traces/contour/set_contours.js @@ -52,8 +52,7 @@ module.exports = function setContours(trace) { size: contours.size }); trace._input.autocontour = true; - } - else if(contours.type !== 'constraint') { + } else if(contours.type !== 'constraint') { // sanity checks on manually-supplied start/end/size var start = contours.start; var end = contours.end; diff --git a/src/traces/contour/style.js b/src/traces/contour/style.js index 0df7110bbbc..af966873b3f 100644 --- a/src/traces/contour/style.js +++ b/src/traces/contour/style.js @@ -59,8 +59,7 @@ module.exports = function style(gd) { if(isConstraintType) { c.selectAll('g.contourfill path') .style('fill', trace.fillcolor); - } - else if(colorFills) { + } else if(colorFills) { var firstFill; c.selectAll('g.contourfill path') diff --git a/src/traces/heatmap/calc.js b/src/traces/heatmap/calc.js index 9b362500b05..f86bb23ed37 100644 --- a/src/traces/heatmap/calc.js +++ b/src/traces/heatmap/calc.js @@ -54,8 +54,7 @@ module.exports = function calc(gd, trace) { y0 = binned.y0; dy = binned.dy; z = binned.z; - } - else { + } else { var zIn = trace.z; if(Lib.isArray1D(zIn)) { convertColumnData(trace, xa, ya, 'x', 'y', ['z']); @@ -89,8 +88,7 @@ module.exports = function calc(gd, trace) { if(zsmooth === 'fast') { if(xa.type === 'log' || ya.type === 'log') { noZsmooth('log axis found'); - } - else if(!isHist) { + } else if(!isHist) { if(x.length) { var avgdx = (x[x.length - 1] - x[0]) / (x.length - 1); var maxErrX = Math.abs(avgdx / 100); diff --git a/src/traces/heatmap/clean_2d_array.js b/src/traces/heatmap/clean_2d_array.js index b386051ec65..74d6fa84db4 100644 --- a/src/traces/heatmap/clean_2d_array.js +++ b/src/traces/heatmap/clean_2d_array.js @@ -24,8 +24,7 @@ module.exports = function clean2dArray(zOld, transpose) { if(rowlen === 0) return false; getCollen = function(zOld) { return zOld.length; }; old2new = function(zOld, i, j) { return zOld[j][i]; }; - } - else { + } else { rowlen = zOld.length; getCollen = function(zOld, i) { return zOld[i].length; }; old2new = function(zOld, i, j) { return zOld[i][j]; }; diff --git a/src/traces/heatmap/find_empties.js b/src/traces/heatmap/find_empties.js index c8fd3faccfb..43e010e5dce 100644 --- a/src/traces/heatmap/find_empties.js +++ b/src/traces/heatmap/find_empties.js @@ -60,8 +60,7 @@ module.exports = function findEmpties(z) { } empties.push([i, j, neighborCount]); - } - else noNeighborList.push([i, j]); + } else noNeighborList.push([i, j]); } } } diff --git a/src/traces/heatmap/hover.js b/src/traces/heatmap/hover.js index 0105156f1ca..cfc2e72f0c2 100644 --- a/src/traces/heatmap/hover.js +++ b/src/traces/heatmap/hover.js @@ -35,8 +35,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay try { nx = Math.round(pointData.index[1]); ny = Math.round(pointData.index[0]); - } - catch(e) { + } catch(e) { Lib.error('Error hovering on heatmap, ' + 'pointNumber must be [row,col], found:', pointData.index); return; @@ -44,12 +43,10 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay if(nx < 0 || nx >= z[0].length || ny < 0 || ny > z.length) { return; } - } - else if(Fx.inbox(xval - x[0], xval - x[x.length - 1], 0) > 0 || + } else if(Fx.inbox(xval - x[0], xval - x[x.length - 1], 0) > 0 || Fx.inbox(yval - y[0], yval - y[y.length - 1], 0) > 0) { return; - } - else { + } else { if(contour) { var i2; x2 = [2 * x[0] - x[1]]; @@ -79,8 +76,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, hoverLay xl = x[nx]; y1 = y0; yl = y[ny]; - } - else { + } else { xl = xc ? xc[nx] : ((x[nx] + x[nx + 1]) / 2); yl = yc ? yc[ny] : ((y[ny] + y[ny + 1]) / 2); if(trace.zsmooth) { diff --git a/src/traces/heatmap/interp2d.js b/src/traces/heatmap/interp2d.js index 0c5498197f4..a3a5e231989 100644 --- a/src/traces/heatmap/interp2d.js +++ b/src/traces/heatmap/interp2d.js @@ -93,8 +93,7 @@ function iterateInterp2d(z, emptyPoints, overshoot) { if(neighborVal !== undefined) { if(neighborSum === 0) { minNeighbor = maxNeighbor = neighborVal; - } - else { + } else { minNeighbor = Math.min(minNeighbor, neighborVal); maxNeighbor = Math.max(maxNeighbor, neighborVal); } @@ -116,8 +115,7 @@ function iterateInterp2d(z, emptyPoints, overshoot) { if(initialVal === undefined) { if(neighborCount < 4) maxFractionalChange = 1; - } - else { + } else { // we can make large empty regions converge faster // if we overshoot the change vs the previous value z[i][j] = (1 + overshoot) * z[i][j] - overshoot * initialVal; diff --git a/src/traces/heatmap/make_bound_array.js b/src/traces/heatmap/make_bound_array.js index 7abc1f6cd2e..6a020ae44dc 100644 --- a/src/traces/heatmap/make_bound_array.js +++ b/src/traces/heatmap/make_bound_array.js @@ -33,8 +33,7 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, if(isContour || isGL2D) arrayOut = arrayIn.slice(0, numbricks); else if(numbricks === 1) { arrayOut = [arrayIn[0] - 0.5, arrayIn[0] + 0.5]; - } - else { + } else { arrayOut = [1.5 * arrayIn[0] - 0.5 * arrayIn[1]]; for(i = 1; i < len; i++) { @@ -53,16 +52,14 @@ module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, arrayOut.push(lastPt); } } - } - else { + } else { // hopefully length === numbricks+1, but do something regardless: // given vals are brick boundaries return isContour ? arrayIn.slice(0, numbricks) : // we must be strict for contours arrayIn.slice(0, numbricks + 1); } - } - else { + } else { var calendar = trace[ax._id.charAt(0) + 'calendar']; if(isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) { diff --git a/src/traces/heatmap/plot.js b/src/traces/heatmap/plot.js index cb89284139c..190d56e2a4b 100644 --- a/src/traces/heatmap/plot.js +++ b/src/traces/heatmap/plot.js @@ -155,8 +155,7 @@ module.exports = function(gd, plotinfo, cdheatmaps, heatmapLayer) { ypx = yrev ? function(index) { return m - 1 - index; } : Lib.identity; - } - else { + } else { xpx = function(index) { return Lib.constrain(Math.round(xa.c2p(x[index]) - left), 0, imageWidth); @@ -217,12 +216,10 @@ module.exports = function(gd, plotinfo, cdheatmaps, heatmapLayer) { if(z11 === undefined) dxy = 0; else if(z10 === undefined) dxy = 2 * (z11 - z00); else dxy = (2 * z11 - z10 - z00) * 2 / 3; - } - else if(z11 === undefined) { + } else if(z11 === undefined) { if(z10 === undefined) dxy = 0; else dxy = (2 * z00 - z01 - z10) * 2 / 3; - } - else if(z10 === undefined) dxy = (2 * z11 - z01 - z00) * 2 / 3; + } else if(z10 === undefined) dxy = (2 * z11 - z01 - z00) * 2 / 3; else dxy = (z11 + z00 - z01 - z10); return setColor(z00 + xinterp.frac * dx + yinterp.frac * (dy + xinterp.frac * dxy)); @@ -266,8 +263,7 @@ module.exports = function(gd, plotinfo, cdheatmaps, heatmapLayer) { putColor(pixels, pxIndex, c); } } - } - else { // zsmooth = fast + } else { // zsmooth = fast for(j = 0; j < m; j++) { row = z[j]; yb = ypx(j); diff --git a/src/traces/heatmap/xyz_defaults.js b/src/traces/heatmap/xyz_defaults.js index 115f5c3f8ee..d84de5861db 100644 --- a/src/traces/heatmap/xyz_defaults.js +++ b/src/traces/heatmap/xyz_defaults.js @@ -32,8 +32,7 @@ module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, x if(xlen === 0 || ylen === 0) return 0; traceOut._length = Math.min(xlen, ylen, z.length); - } - else { + } else { x = coordDefaults(xName, coerce); y = coordDefaults(yName, coerce); diff --git a/src/traces/histogram/average.js b/src/traces/histogram/average.js index ac1e2c40b4e..c52617eef0f 100644 --- a/src/traces/histogram/average.js +++ b/src/traces/histogram/average.js @@ -17,8 +17,7 @@ module.exports = function doAvg(size, counts) { if(counts[i]) { size[i] /= counts[i]; total += size[i]; - } - else size[i] = null; + } else size[i] = null; } return total; }; diff --git a/src/traces/histogram/bin_functions.js b/src/traces/histogram/bin_functions.js index 99b20ed0334..7399a9ac644 100644 --- a/src/traces/histogram/bin_functions.js +++ b/src/traces/histogram/bin_functions.js @@ -45,8 +45,7 @@ module.exports = { if(!isNumeric(size[n])) { size[n] = v; return v; - } - else if(size[n] > v) { + } else if(size[n] > v) { var delta = v - size[n]; size[n] = v; return delta; @@ -62,8 +61,7 @@ module.exports = { if(!isNumeric(size[n])) { size[n] = v; return v; - } - else if(size[n] < v) { + } else if(size[n] < v) { var delta = v - size[n]; size[n] = v; return delta; diff --git a/src/traces/histogram/bin_label_vals.js b/src/traces/histogram/bin_label_vals.js index 3499c3f081d..c6422ff62a9 100644 --- a/src/traces/histogram/bin_label_vals.js +++ b/src/traces/histogram/bin_label_vals.js @@ -58,8 +58,7 @@ module.exports = function getBinSpanLabelRound(leftGap, rightGap, binEdges, pa, if(leftDigit > rightDigit && rightDigit < Math.abs(edge1 - edge0) / 4000) { digit = leftDigit; disambiguateEdges = false; - } - else { + } else { digit = Math.min(leftDigit, rightDigit); disambiguateEdges = true; } diff --git a/src/traces/histogram/calc.js b/src/traces/histogram/calc.js index 179795bbfff..c4388db82e2 100644 --- a/src/traces/histogram/calc.js +++ b/src/traces/histogram/calc.js @@ -179,8 +179,7 @@ module.exports = function calc(gd, trace) { cdi.pts = inputPoints[i]; if(uniqueValsPerBin) { cdi.ph0 = cdi.ph1 = (inputPoints[i].length) ? pos0[inputPoints[i][0]] : pos[i]; - } - else { + } else { cdi.ph0 = roundFn(binEdges[i]); cdi.ph1 = roundFn(binEdges[i + 1], true); } @@ -225,8 +224,7 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { if(bins[attr + 'Found']) { bins[attr] = cleanBound(bins[attr]); if(bins[attr] === null) bins[attr] = newBins[attr]; - } - else { + } else { autoVals[attr] = bins[attr] = newBins[attr]; Lib.nestedProperty(traces[0], binAttr + '.' + attr).set(newBins[attr]); } @@ -238,8 +236,7 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { // clear this flag, so next time we run calc we will run autobin again if(trace._autoBinFinished) { delete trace._autoBinFinished; - } - else { + } else { traces = binOpts.traces; var sizeFound = binOpts.sizeFound; var allPos = []; @@ -258,8 +255,7 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { if(trace.visible === true) { if(isFirstVisible) { isFirstVisible = false; - } - else { + } else { delete tracei._autoBin; tracei._autoBinFinished = 1; } @@ -290,8 +286,7 @@ function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) { pa.r2c(newBinSpec.start, 0, calendar), newBinSpec.size, true, calendar )); - } - else { + } else { newBinSpec.end = pa.c2r(Axes.tickIncrement( pa.r2c(newBinSpec.end, 0, calendar), newBinSpec.size, false, calendar @@ -395,8 +390,7 @@ function handleSingleValueOverlays(gd, trace, pa, mainData, binAttr) { // This trace has already had its autobins calculated // (so must not have been single-valued). minSize = Math.min(minSize, tracei[binAttr].size); - } - else { + } else { var resulti = calcAllAutoBins(gd, tracei, pa, mainData, true); var binSpeci = resulti[0]; var isSingleValued = resulti[2]; @@ -408,8 +402,7 @@ function handleSingleValueOverlays(gd, trace, pa, mainData, binAttr) { if(isSingleValued) { singleValuedTraces.push(tracei); - } - else { + } else { minSize = Math.min(minSize, binSpeci.size); } } @@ -498,15 +491,13 @@ function cdf(size, direction, currentBin) { for(i = 1; i < size.length; i++) { nextHalfPoint(i); } - } - else { + } else { firstHalfPoint(size.length - 1); for(i = size.length - 2; i >= 0; i--) { nextHalfPoint(i); } } - } - else if(direction === 'increasing') { + } else if(direction === 'increasing') { for(i = 1; i < size.length; i++) { size[i] += size[i - 1]; } @@ -516,8 +507,7 @@ function cdf(size, direction, currentBin) { size.unshift(0); size.pop(); } - } - else { + } else { for(i = size.length - 2; i >= 0; i--) { size[i] += size[i + 1]; } diff --git a/src/traces/histogram2d/calc.js b/src/traces/histogram2d/calc.js index ddadc9d5549..4ca78cee96c 100644 --- a/src/traces/histogram2d/calc.js +++ b/src/traces/histogram2d/calc.js @@ -232,8 +232,7 @@ function makeIncrements(len, bins, dv, nonuniform) { var i; if(nonuniform) { for(i = 0; i < len; i++) out[i] = 1 / (bins[i + 1] - bins[i]); - } - else { + } else { var inc = 1 / dv; for(i = 0; i < len; i++) out[i] = inc; } @@ -254,8 +253,7 @@ function getRanges(edges, uniqueVals, gapLow, gapHigh, ax, calendar) { var out = new Array(len); if(uniqueVals) { for(i = 0; i < len; i++) out[i] = [uniqueVals[i], uniqueVals[i]]; - } - else { + } else { var roundFn = getBinSpanLabelRound(gapLow, gapHigh, edges, ax, calendar); for(i = 0; i < len; i++) out[i] = [roundFn(edges[i]), roundFn(edges[i + 1], true)]; } diff --git a/src/traces/histogram2d/cross_trace_defaults.js b/src/traces/histogram2d/cross_trace_defaults.js index 8b655ebbf0c..24b78826a0b 100644 --- a/src/traces/histogram2d/cross_trace_defaults.js +++ b/src/traces/histogram2d/cross_trace_defaults.js @@ -74,11 +74,9 @@ function cleanBins(trace, binDirection, fullLayout, autoBins) { if(isNumeric(binSize)) { bins.size = (binSize > 0) ? Number(binSize) : sizeDflt; - } - else if(typeof binSize !== 'string') { + } else if(typeof binSize !== 'string') { bins.size = sizeDflt; - } - else { + } else { // date special case: "M" gives bins every (integer) n months var prefix = binSize.charAt(0); var sizeNum = binSize.substr(1); diff --git a/src/traces/ohlc/calc.js b/src/traces/ohlc/calc.js index 094e7384b40..f6ad3bfa74e 100644 --- a/src/traces/ohlc/calc.js +++ b/src/traces/ohlc/calc.js @@ -75,8 +75,7 @@ function calcCommon(gd, trace, x, ya, ptFunc) { // if open == close, look for a change from the previous close if(cPrev !== null && ci !== cPrev) increasing = ci > cPrev; // else (c === cPrev or cPrev is null) no change - } - else increasing = ci > oi; + } else increasing = ci > oi; cPrev = ci; diff --git a/src/traces/ohlc/hover.js b/src/traces/ohlc/hover.js index 312f6b17004..58e67165e6a 100644 --- a/src/traces/ohlc/hover.js +++ b/src/traces/ohlc/hover.js @@ -133,8 +133,7 @@ function hoverSplit(pointData, xval, yval, hovermode) { if(val in usedVals) { pointData2 = usedVals[val]; pointData2.yLabel += '
' + t.labels[attr] + Axes.hoverLabelText(ya, val); - } - else { + } else { // copy out to a new object for each new y-value to label pointData2 = Lib.extendFlat({}, closestPoint); diff --git a/src/traces/parcats/defaults.js b/src/traces/parcats/defaults.js index e2495572a9b..a4edf1d82ba 100644 --- a/src/traces/parcats/defaults.js +++ b/src/traces/parcats/defaults.js @@ -27,8 +27,7 @@ function handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce) { coerce('line.colorscale'); colorscaleDefaults(traceIn, traceOut, layout, coerce, {prefix: 'line.', cLetter: 'c'}); return lineColor.length; - } - else { + } else { traceOut.line.color = defaultColor; } } diff --git a/src/traces/parcats/parcats.js b/src/traces/parcats/parcats.js index 7805a8f0970..1b7ee644da0 100644 --- a/src/traces/parcats/parcats.js +++ b/src/traces/parcats/parcats.js @@ -1344,7 +1344,8 @@ function updateSvgCategories(parcatsViewModel, hasTransition) { // Update binding parcatsViewModel.dimensionSelection .data(function(d) { - return d.dimensions;}, key); + return d.dimensions; + }, key); var categorySelection = parcatsViewModel.dimensionSelection .selectAll('g.category') diff --git a/src/traces/parcoords/axisbrush.js b/src/traces/parcoords/axisbrush.js index a978734d528..e84c53c4438 100644 --- a/src/traces/parcoords/axisbrush.js +++ b/src/traces/parcoords/axisbrush.js @@ -175,8 +175,7 @@ function getInterval(d, y) { if(isNaN(closestInterval)) { if(isNaN(previousInterval) || isNaN(nextInterval)) { closestInterval = isNaN(previousInterval) ? nextInterval : previousInterval; - } - else { + } else { closestInterval = (y - pixIntervals[previousInterval][1] < pixIntervals[nextInterval][0] - y) ? previousInterval : nextInterval; } @@ -306,13 +305,11 @@ function attachDragBehavior(selection) { if(s.clickableOrdinalRange) { if(brush.filterSpecified && d.multiselect) { s.extent.push(s.clickableOrdinalRange); - } - else { + } else { s.extent = [s.clickableOrdinalRange]; brush.filterSpecified = true; } - } - else if(grabbingBar) { + } else if(grabbingBar) { s.extent = s.stayingIntervals; if(s.extent.length === 0) { brushClear(brush); @@ -348,8 +345,7 @@ function attachDragBehavior(selection) { if(hasNewExtent) { // merging intervals post the snap tween renderHighlight(this.parentNode, mergeIntervals); - } - else { + } else { // if no new interval, don't animate, just redraw the highlight immediately mergeIntervals(); renderHighlight(this.parentNode); @@ -502,8 +498,7 @@ function cleanRanges(ranges, dimension) { if(!dimension.multiselect) ranges = [ranges[0]]; else ranges = dedupeRealRanges(ranges.sort(startAsc)); - } - else ranges = [ranges.sort(sortAsc)]; + } else ranges = [ranges.sort(sortAsc)]; // ordinal snapping if(dimension.tickvals) { diff --git a/src/traces/parcoords/defaults.js b/src/traces/parcoords/defaults.js index dfb4b7d3fe7..5d96dd4c8e4 100644 --- a/src/traces/parcoords/defaults.js +++ b/src/traces/parcoords/defaults.js @@ -30,8 +30,7 @@ function handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce) { // but I'm not sure what color to give these lines - probably black or white // depending on the background color? return lineColor.length; - } - else { + } else { traceOut.line.color = defaultColor; } } diff --git a/src/traces/parcoords/lines.js b/src/traces/parcoords/lines.js index 6536bb42ed5..f7a5a927e50 100644 --- a/src/traces/parcoords/lines.js +++ b/src/traces/parcoords/lines.js @@ -382,8 +382,7 @@ module.exports = function(canvasGL, d) { var lim; if(dimP < initialDims.length) { lim = initialDims[dimP].brush.filter.getBounds()[loHi]; - } - else lim = loHi; + } else lim = loHi; lims[loHi][abcd][d] = lim + (2 * loHi - 1) * filterEpsilon; } } diff --git a/src/traces/parcoords/parcoords.js b/src/traces/parcoords/parcoords.js index 3c8cd815182..cef0756d81e 100644 --- a/src/traces/parcoords/parcoords.js +++ b/src/traces/parcoords/parcoords.js @@ -242,11 +242,9 @@ function viewModel(state, callbacks, model) { // ensure ticktext and tickvals have same length if(!Array.isArray(ticktext) || !ticktext.length) { ticktext = tickvals.map(d3.format(dimension.tickformat)); - } - else if(ticktext.length > tickvals.length) { + } else if(ticktext.length > tickvals.length) { ticktext = ticktext.slice(0, tickvals.length); - } - else if(tickvals.length > ticktext.length) { + } else if(tickvals.length > ticktext.length) { tickvals = tickvals.slice(0, ticktext.length); } @@ -261,8 +259,7 @@ function viewModel(state, callbacks, model) { break; } } - } - else tickvals = undefined; + } else tickvals = undefined; return { key: key, diff --git a/src/traces/parcoords/plot.js b/src/traces/parcoords/plot.js index 7d0137a429f..4a30b185fa3 100644 --- a/src/traces/parcoords/plot.js +++ b/src/traces/parcoords/plot.js @@ -59,8 +59,7 @@ module.exports = function plot(gd, cdparcoords) { delete gdDimension.constraintrange; delete fullDimension.constraintrange; newConstraints = null; - } - else { + } else { if(newConstraints.length === 1) newConstraints = newConstraints[0]; gdDimension.constraintrange = newConstraints; fullDimension.constraintrange = newConstraints.slice(); diff --git a/src/traces/pie/calc.js b/src/traces/pie/calc.js index c5d1700e3ee..f918f51ba30 100644 --- a/src/traces/pie/calc.js +++ b/src/traces/pie/calc.js @@ -46,8 +46,7 @@ function calc(gd, trace) { if(!isNumeric(v)) continue; v = +v; if(v < 0) continue; - } - else v = 1; + } else v = 1; label = labels[i]; if(label === undefined || label === '') label = i; @@ -69,8 +68,7 @@ function calc(gd, trace) { pts: [i], hidden: hidden }); - } - else { + } else { pt = cd[thisLabelIndex]; pt.v += v; pt.pts.push(i); diff --git a/src/traces/pie/defaults.js b/src/traces/pie/defaults.js index 2d23a4a93f4..52aea7bfc7b 100644 --- a/src/traces/pie/defaults.js +++ b/src/traces/pie/defaults.js @@ -26,8 +26,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout if(Array.isArray(labels)) { len = labels.length; if(hasVals) len = Math.min(len, vals.length); - } - else if(hasVals) { + } else if(hasVals) { len = vals.length; coerce('label0'); diff --git a/src/traces/pie/plot.js b/src/traces/pie/plot.js index 7dd3929b157..d940a5ecfb6 100644 --- a/src/traces/pie/plot.js +++ b/src/traces/pie/plot.js @@ -100,8 +100,7 @@ function plot(gd, cdpie) { arc(pt.px0, pt.pxmid, false, hole) + arc(pt.pxmid, pt.px0, false, hole) + 'Z' + outerCircle); - } - else slicePath.attr('d', outerCircle); + } else slicePath.attr('d', outerCircle); } else { var outerArc = arc(pt.px0, pt.px1, true, 1); @@ -632,8 +631,7 @@ function positionTitleOutside(cd0, plotSize) { if(trace.title.position.indexOf('top') !== -1) { topMiddle.y -= (1 + maxPull) * cd0.r; translate.ty -= cd0.titleBox.height; - } - else if(trace.title.position.indexOf('bottom') !== -1) { + } else if(trace.title.position.indexOf('bottom') !== -1) { topMiddle.y += (1 + maxPull) * cd0.r; } diff --git a/src/traces/sankey/render.js b/src/traces/sankey/render.js index da6498bb51c..4cf93a539fc 100644 --- a/src/traces/sankey/render.js +++ b/src/traces/sankey/render.js @@ -561,7 +561,8 @@ function textGuidePath(d) { return d3.svg.line()([ [d.horizontal ? (d.left ? -d.sizeAcross : d.visibleWidth + c.nodeTextOffsetHorizontal) : c.nodeTextOffsetHorizontal, 0], [d.horizontal ? (d.left ? - c.nodeTextOffsetHorizontal : d.sizeAcross) : d.visibleHeight - c.nodeTextOffsetHorizontal, 0] - ]);} + ]); +} function sankeyInverseTransform(d) {return d.horizontal ? 'matrix(1 0 0 1 0 0)' : 'matrix(0 1 1 0 0 0)';} function textFlip(d) {return d.horizontal ? 'scale(1 1)' : 'scale(-1 1)';} diff --git a/src/traces/scatter/calc.js b/src/traces/scatter/calc.js index d9aefebf385..0185eb864d3 100644 --- a/src/traces/scatter/calc.js +++ b/src/traces/scatter/calc.js @@ -45,14 +45,12 @@ function calc(gd, trace) { if(isV) { yAttr = 's'; posAttr = 'x'; - } - else { + } else { xAttr = 's'; posAttr = 'y'; } interpolate = stackGroupOpts.stackgaps === 'interpolate'; - } - else { + } else { var ppad = calcMarkerSize(trace, serieslen); calcAxisExpansion(gd, trace, xa, ya, x, y, ppad); } @@ -64,21 +62,19 @@ function calc(gd, trace) { if(xValid && yValid) { cdi[xAttr] = x[i]; cdi[yAttr] = y[i]; - } - // if we're stacking we need to hold on to all valid positions - // even with invalid sizes - else if(stackGroupOpts && (isV ? xValid : yValid)) { + } else if(stackGroupOpts && (isV ? xValid : yValid)) { + // if we're stacking we need to hold on to all valid positions + // even with invalid sizes + cdi[posAttr] = isV ? x[i] : y[i]; cdi.gap = true; if(interpolate) { cdi.s = BADNUM; interpolateGaps = true; - } - else { + } else { cdi.s = 0; } - } - else { + } else { cdi[xAttr] = cdi[yAttr] = BADNUM; } @@ -98,8 +94,7 @@ function calc(gd, trace) { while(i < cd.length) { if(cd[i][posAttr] === BADNUM) { cd.splice(i, 1); - } - else i++; + } else i++; } Lib.sort(cd, function(a, b) { @@ -175,17 +170,17 @@ function calcAxisExpansion(gd, trace, xa, ya, x, y, ppad) { var openEnded = serieslen < 2 || (x[0] !== x[serieslen - 1]) || (y[0] !== y[serieslen - 1]); - // include zero (tight) and extremes (padded) if fill to zero - // (unless the shape is closed, then it's just filling the shape regardless) if(openEnded && ( (fill === 'tozerox') || ((fill === 'tonextx') && (firstScatter || stackOrientation === 'h')) )) { + // include zero (tight) and extremes (padded) if fill to zero + // (unless the shape is closed, then it's just filling the shape regardless) + xOptions.tozero = true; - } + } else if(!(trace.error_y || {}).visible && ( + // if no error bars, markers or text, or fill to y=0 remove x padding - // if no error bars, markers or text, or fill to y=0 remove x padding - else if(!(trace.error_y || {}).visible && ( (fill === 'tonexty' || fill === 'tozeroy') || (!subTypes.hasMarkers(trace) && !subTypes.hasText(trace)) )) { @@ -193,18 +188,18 @@ function calcAxisExpansion(gd, trace, xa, ya, x, y, ppad) { xOptions.ppad = 0; } - // now check for y - rather different logic, though still mostly padded both ends - // include zero (tight) and extremes (padded) if fill to zero - // (unless the shape is closed, then it's just filling the shape regardless) if(openEnded && ( (fill === 'tozeroy') || ((fill === 'tonexty') && (firstScatter || stackOrientation === 'v')) )) { + // now check for y - rather different logic, though still mostly padded both ends + // include zero (tight) and extremes (padded) if fill to zero + // (unless the shape is closed, then it's just filling the shape regardless) + yOptions.tozero = true; - } + } else if(fill === 'tonextx' || fill === 'tozerox') { + // tight y: any x fill - // tight y: any x fill - else if(fill === 'tonextx' || fill === 'tozerox') { yOptions.padded = false; } diff --git a/src/traces/scatter/cross_trace_calc.js b/src/traces/scatter/cross_trace_calc.js index 7551706ce72..47ac386e9da 100644 --- a/src/traces/scatter/cross_trace_calc.js +++ b/src/traces/scatter/cross_trace_calc.js @@ -42,8 +42,7 @@ module.exports = function crossTraceCalc(gd, plotinfo) { if(groupOpts.orientation === 'v') { posAttr = 'x'; valAttr = 'y'; - } - else { + } else { posAttr = 'y'; valAttr = 'x'; } @@ -159,8 +158,7 @@ function insertBlank(calcTrace, index, position, traceIndex, hasAnyBlanks, inter // calcdata points with the same index? newEntry.i = prevEntry.i; newEntry.gap = prevEntry.gap; - } - else if(interpolate) { + } else if(interpolate) { newEntry.s = getInterp(calcTrace, index, position, posAttr); } if(!index) { diff --git a/src/traces/scatter/fillcolor_defaults.js b/src/traces/scatter/fillcolor_defaults.js index 47cc0486532..f3d8cd49c3e 100644 --- a/src/traces/scatter/fillcolor_defaults.js +++ b/src/traces/scatter/fillcolor_defaults.js @@ -22,8 +22,7 @@ module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coe if(markerColor && !isArrayOrTypedArray(markerColor)) { inheritColorFromMarker = markerColor; - } - else if(markerLineColor && !isArrayOrTypedArray(markerLineColor)) { + } else if(markerLineColor && !isArrayOrTypedArray(markerLineColor)) { inheritColorFromMarker = markerLineColor; } } diff --git a/src/traces/scatter/get_trace_color.js b/src/traces/scatter/get_trace_color.js index 151ca81fb5d..b51014641a3 100644 --- a/src/traces/scatter/get_trace_color.js +++ b/src/traces/scatter/get_trace_color.js @@ -22,11 +22,9 @@ module.exports = function getTraceColor(trace, di) { lc = trace.line.color; return (lc && Color.opacity(lc)) ? lc : trace.fillcolor; - } - else if(trace.mode === 'none') { + } else if(trace.mode === 'none') { return trace.fill ? trace.fillcolor : ''; - } - else { + } else { var mc = di.mcc || (trace.marker || {}).color; var mlc = di.mlcc || ((trace.marker || {}).line || {}).color; @@ -38,10 +36,8 @@ module.exports = function getTraceColor(trace, di) { // make sure the points aren't TOO transparent if(Color.opacity(tc) < 0.3) { return Color.addOpacity(tc, 0.3); - } - else return tc; - } - else { + } else return tc; + } else { lc = (trace.line || {}).color; return (lc && Color.opacity(lc) && subtypes.hasLines(trace) && trace.line.width) ? diff --git a/src/traces/scatter/hover.js b/src/traces/scatter/hover.js index 754e2da0a37..f75f5308552 100644 --- a/src/traces/scatter/hover.js +++ b/src/traces/scatter/hover.js @@ -185,8 +185,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { if(trace.text && !Array.isArray(trace.text)) { pointData.text = String(trace.text); - } - else pointData.text = trace.name; + } else pointData.text = trace.name; return [pointData]; } diff --git a/src/traces/scatter/line_points.js b/src/traces/scatter/line_points.js index 0c65cdee26b..2943f2673bb 100644 --- a/src/traces/scatter/line_points.js +++ b/src/traces/scatter/line_points.js @@ -224,8 +224,7 @@ module.exports = function linePoints(d, opts) { var ptToAlter; if(ptInt1 && ptInt2) { ptToAlter = (midShift > 0 === ptInt1[dim] > ptInt2[dim]) ? ptInt1 : ptInt2; - } - else ptToAlter = ptInt1 || ptInt2; + } else ptToAlter = ptInt1 || ptInt2; ptToAlter[dim] += midShift; } @@ -237,11 +236,9 @@ module.exports = function linePoints(d, opts) { var getEdgeIntersections; if(shape === 'linear' || shape === 'spline') { getEdgeIntersections = getLinearEdgeIntersections; - } - else if(shape === 'hv' || shape === 'vh') { + } else if(shape === 'hv' || shape === 'vh') { getEdgeIntersections = getHVEdgeIntersections; - } - else if(shape === 'hvh') getEdgeIntersections = getABAEdgeIntersections(0, xEdge0, xEdge1); + } else if(shape === 'hvh') getEdgeIntersections = getABAEdgeIntersections(0, xEdge0, xEdge1); else if(shape === 'vhv') getEdgeIntersections = getABAEdgeIntersections(1, yEdge0, yEdge1); // a segment pt1->pt2 entirely outside the nearby region: @@ -269,14 +266,11 @@ module.exports = function linePoints(d, opts) { if(xSame && (x === xEdge0 || x === xEdge1) && xSame2) { if(ySame2) pti--; // backtracking exactly - drop prev pt and don't add else pts[pti - 1] = pt; // not exact: replace the prev pt - } - else if(ySame && (y === yEdge0 || y === yEdge1) && ySame2) { + } else if(ySame && (y === yEdge0 || y === yEdge1) && ySame2) { if(xSame2) pti--; else pts[pti - 1] = pt; - } - else pts[pti++] = pt; - } - else pts[pti++] = pt; + } else pts[pti++] = pt; + } else pts[pti++] = pt; } function updateEdgesForReentry(pt) { @@ -299,12 +293,12 @@ module.exports = function linePoints(d, opts) { xEdge = (pt[0] < xEdge0) ? xEdge0 : (pt[0] > xEdge1) ? xEdge1 : 0; yEdge = (pt[1] < yEdge0) ? yEdge0 : (pt[1] > yEdge1) ? yEdge1 : 0; if(xEdge || yEdge) { - // to get fills right - if first point is far, push it toward the - // screen in whichever direction(s) are far if(!pti) { + // to get fills right - if first point is far, push it toward the + // screen in whichever direction(s) are far + pts[pti++] = [xEdge || pt[0], yEdge || pt[1]]; - } - else if(lastFarPt) { + } else if(lastFarPt) { // both this point and the last are outside the nearby region // check if we're crossing the nearby region var intersections = getEdgeIntersections(lastFarPt, pt); @@ -312,9 +306,9 @@ module.exports = function linePoints(d, opts) { updateEdgesForReentry(intersections[0]); pts[pti++] = intersections[1]; } - } - // we're leaving the nearby region - add the point where we left it - else { + } else { + // we're leaving the nearby region - add the point where we left it + edgePt = getEdgeIntersections(pts[pti - 1], pt)[0]; pts[pti++] = edgePt; } @@ -330,20 +324,17 @@ module.exports = function linePoints(d, opts) { // need to add the correct extra corner // in order to get the right winding updateEdge(getClosestCorner(lastFarPt, pt)); - } - else { + } else { // we're coming from a far edge - the extra corner // we need is determined uniquely by the sectors updateEdge([lastXEdge || xEdge, lastYEdge || yEdge]); } - } - else if(lastXEdge && lastYEdge) { + } else if(lastXEdge && lastYEdge) { updateEdge([lastXEdge, lastYEdge]); } } updateEdge([xEdge, yEdge]); - } - else if((lastXEdge - xEdge) && (lastYEdge - yEdge)) { + } else if((lastXEdge - xEdge) && (lastYEdge - yEdge)) { // we're coming from an edge or far corner to an edge - again the // extra corner we need is uniquely determined by the sectors updateEdge([xEdge || lastXEdge, yEdge || lastYEdge]); @@ -351,8 +342,7 @@ module.exports = function linePoints(d, opts) { lastFarPt = pt; lastXEdge = xEdge; lastYEdge = yEdge; - } - else { + } else { if(lastFarPt) { // this point is in range but the previous wasn't: add its entry pt first updateEdgesForReentry(getEdgeIntersections(lastFarPt, pt)[0]); diff --git a/src/traces/scatter/link_traces.js b/src/traces/scatter/link_traces.js index 51dd72c5712..00dd070d907 100644 --- a/src/traces/scatter/link_traces.js +++ b/src/traces/scatter/link_traces.js @@ -25,16 +25,13 @@ module.exports = function linkTraces(gd, plotinfo, cdscatter) { if(group) { if(group in groupIndices) { groupIndex = groupIndices[group]; - } - else { + } else { groupIndex = groupIndices[group] = nextGroupIndex; nextGroupIndex++; } - } - else if(trace.fill in LINKEDFILLS && prevUnstackedGroupIndex >= 0) { + } else if(trace.fill in LINKEDFILLS && prevUnstackedGroupIndex >= 0) { groupIndex = prevUnstackedGroupIndex; - } - else { + } else { groupIndex = prevUnstackedGroupIndex = nextGroupIndex; nextGroupIndex++; } diff --git a/src/traces/scatter/marker_defaults.js b/src/traces/scatter/marker_defaults.js index 7aebb8c9e9e..7c894777ff9 100644 --- a/src/traces/scatter/marker_defaults.js +++ b/src/traces/scatter/marker_defaults.js @@ -53,8 +53,7 @@ module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout // mostly this is for transparent markers to behave nicely if(lineColor && !Array.isArray(lineColor) && (traceOut.marker.color !== lineColor)) { defaultMLC = lineColor; - } - else if(isBubble) defaultMLC = Color.background; + } else if(isBubble) defaultMLC = Color.background; else defaultMLC = Color.defaultLine; coerce('marker.line.color', defaultMLC); diff --git a/src/traces/scatter/plot.js b/src/traces/scatter/plot.js index 6666550fd27..f0713e03eb8 100644 --- a/src/traces/scatter/plot.js +++ b/src/traces/scatter/plot.js @@ -193,21 +193,18 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition revpathbase = Drawing.steps( line.shape.split('').reverse().join('') ); - } - else if(line.shape === 'spline') { + } else if(line.shape === 'spline') { pathfn = revpathbase = function(pts) { var pLast = pts[pts.length - 1]; if(pts.length > 1 && pts[0][0] === pLast[0] && pts[0][1] === pLast[1]) { // identical start and end points: treat it as a // closed curve so we don't get a kink return Drawing.smoothclosed(pts.slice(1), line.smoothing); - } - else { + } else { return Drawing.smoothopen(pts, line.smoothing); } }; - } - else { + } else { pathfn = revpathbase = function(pts) { return 'M' + pts.join('L'); }; @@ -250,12 +247,10 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition if(!fullpath) { fullpath = thispath; revpath = thisrevpath; - } - else if(ownFillDir) { + } else if(ownFillDir) { fullpath += 'L' + thispath.substr(1); revpath = thisrevpath + ('L' + revpath.substr(1)); - } - else { + } else { fullpath += 'Z' + thispath; revpath = thisrevpath + 'Z' + revpath; } @@ -308,8 +303,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition if(ownFillDir) { if(ownFillDir === 'y') { pt0[1] = pt1[1] = ya.c2p(0, true); - } - else if(ownFillDir === 'x') { + } else if(ownFillDir === 'x') { pt0[0] = pt1[0] = xa.c2p(0, true); } @@ -326,8 +320,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition .call(Drawing.singleFillStyle); } } - } - else if(tonext) { + } else if(tonext) { if(trace.fill.substr(0, 6) === 'tonext' && fullpath && prevRevpath) { // fill to next: full trace path, plus the previous path reversed if(trace.fill === 'tonext') { @@ -337,8 +330,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition // inside the other, but then that is a strange usage. transition(tonext).attr('d', fullpath + 'Z' + prevRevpath + 'Z') .call(Drawing.singleFillStyle); - } - else { + } else { // tonextx/y: for now just connect endpoints with lines. This is // the correct behavior if the endpoints are at the same value of // y/x, but if they *aren't*, we should ideally do more complicated @@ -348,16 +340,14 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition .call(Drawing.singleFillStyle); } trace._polygons = trace._polygons.concat(prevPolygons); - } - else { + } else { clearFill(tonext); trace._polygons = null; } } trace._prevRevpath = revpath; trace._prevPolygons = thisPolygons; - } - else { + } else { if(ownFillEl3) clearFill(ownFillEl3); else if(tonext) clearFill(tonext); trace._polygons = trace._prevRevpath = trace._prevPolygons = null; @@ -413,8 +403,7 @@ function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transition gd._fullLayout._scatterStackOpts[xa._id + ya._id][stackGroup].stackgaps === 'infer zero'); if(trace.marker.maxdisplayed || trace._needsCull) { showFilter = isInferZero ? visFilterWithGaps : visFilter; - } - else if(stackGroup && !isInferZero) { + } else if(stackGroup && !isInferZero) { showFilter = gapFilter; } diff --git a/src/traces/scatter/select.js b/src/traces/scatter/select.js index d7b11a44eda..820f13846a3 100644 --- a/src/traces/scatter/select.js +++ b/src/traces/scatter/select.js @@ -29,8 +29,7 @@ module.exports = function selectPoints(searchInfo, selectionTester) { for(i = 0; i < cd.length; i++) { cd[i].selected = 0; } - } - else { + } else { for(i = 0; i < cd.length; i++) { di = cd[i]; x = xa.c2p(di.x); diff --git a/src/traces/scatter/stack_defaults.js b/src/traces/scatter/stack_defaults.js index d601722b9f5..1668be2e1ce 100644 --- a/src/traces/scatter/stack_defaults.js +++ b/src/traces/scatter/stack_defaults.js @@ -24,8 +24,7 @@ module.exports = function handleStackDefaults(traceIn, traceOut, layout, coerce) var firstTrace = false; if(groupOpts) { groupOpts.traces.push(traceOut); - } - else { + } else { groupOpts = subplotStackOpts[stackGroup] = { // keep track of trace indices for use during stacking calculations // this will be filled in during `calc` and used during `crossTraceCalc` diff --git a/src/traces/scatter3d/convert.js b/src/traces/scatter3d/convert.js index 92ee32571a4..c903b3f8c93 100644 --- a/src/traces/scatter3d/convert.js +++ b/src/traces/scatter3d/convert.js @@ -196,8 +196,7 @@ function formatParam(paramIn, len, calculate, dflt, extraFn) { if(paramIn[i] === undefined) paramOut[i] = dflt; else paramOut[i] = calculate(paramIn[i], extraFn); } - } - else paramOut = calculate(paramIn, Lib.identity); + } else paramOut = calculate(paramIn, Lib.identity); return paramOut; } diff --git a/src/traces/scattercarpet/calc.js b/src/traces/scattercarpet/calc.js index 1b9efbe2179..372c0a653d4 100644 --- a/src/traces/scattercarpet/calc.js +++ b/src/traces/scattercarpet/calc.js @@ -40,8 +40,7 @@ module.exports = function calc(gd, trace) { var visible = carpet.isVisible(+a, +b); if(!visible) needsCull = true; cd[i] = {x: xy[0], y: xy[1], a: a, b: b, vis: visible}; - } - else cd[i] = {x: false, y: false}; + } else cd[i] = {x: false, y: false}; } trace._needsCull = needsCull; diff --git a/src/traces/scattergl/convert.js b/src/traces/scattergl/convert.js index c13fab77435..dc9231fe590 100644 --- a/src/traces/scattergl/convert.js +++ b/src/traces/scattergl/convert.js @@ -368,8 +368,7 @@ function getSymbolSdf(symbol) { if(isDot && !symbolNoDot) { symbolPath = symbolFunc(SYMBOL_SIZE * 1.1) + SYMBOL_SVG_CIRCLE; - } - else { + } else { symbolPath = symbolFunc(SYMBOL_SIZE); } @@ -416,8 +415,7 @@ function convertLinePositions(gd, trace, positions) { linePositions.push(NaN, NaN); } linePositions.push(NaN, NaN); - } - else { + } else { var midPtX = (positions[i * 2] + positions[i * 2 + 2]) / 2; linePositions.push( positions[i * 2], @@ -440,8 +438,7 @@ function convertLinePositions(gd, trace, positions) { linePositions.push(NaN, NaN); } linePositions.push(NaN, NaN); - } - else { + } else { var midPtY = (positions[i * 2 + 1] + positions[i * 2 + 3]) / 2; linePositions.push( positions[i * 2], @@ -459,8 +456,7 @@ function convertLinePositions(gd, trace, positions) { for(i = 0; i < count - 1; i++) { if(isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1])) { linePositions.push(NaN, NaN, NaN, NaN); - } - else { + } else { linePositions.push(positions[i * 2], positions[i * 2 + 1]); if(!isNaN(positions[i * 2 + 2]) && !isNaN(positions[i * 2 + 3])) { linePositions.push(positions[i * 2], positions[i * 2 + 3]); @@ -497,8 +493,7 @@ function convertLinePositions(gd, trace, positions) { if(isNaN(linePositions[i]) || isNaN(linePositions[i + 1])) { linePositions[i] = lastX; linePositions[i + 1] = lastY; - } - else { + } else { lastX = linePositions[i]; lastY = linePositions[i + 1]; } diff --git a/src/traces/scattergl/index.js b/src/traces/scattergl/index.js index 9b49ae3493d..407348c588f 100644 --- a/src/traces/scattergl/index.js +++ b/src/traces/scattergl/index.js @@ -473,8 +473,7 @@ function plot(gd, subplot, cdata) { if(srcPos[lastptdef + 1] !== 0) { pos = pos.concat([srcPos[lastptdef], 0]); } - } - else if(trace.fill === 'tozerox') { + } else if(trace.fill === 'tozerox') { firstptdef = 0; while(firstptdef < srcPos.length && isNaN(srcPos[firstptdef])) { firstptdef += 2; @@ -490,8 +489,7 @@ function plot(gd, subplot, cdata) { if(srcPos[lastptdef] !== 0) { pos = pos.concat([ 0, srcPos[lastptdef + 1]]); } - } - else if(trace.fill === 'toself' || trace.fill === 'tonext') { + } else if(trace.fill === 'toself' || trace.fill === 'tonext') { pos = []; last = 0; for(j = 0; j < srcPos.length; j += 2) { @@ -505,8 +503,7 @@ function plot(gd, subplot, cdata) { if(last) { pos.push(srcPos[last], srcPos[last + 1]); } - } - else { + } else { var nextTrace = trace._nexttrace; if(nextTrace) { @@ -709,18 +706,15 @@ function hoverPoints(pointData, xval, yval, hovermode) { Math.min(xl, xr), Math.min(ya._rl[0], ya._rl[1]), Math.max(xl, xr), Math.max(ya._rl[0], ya._rl[1]) ); - } - else { + } else { ids = stash.tree.range( Math.min(xl, xr), Math.min(yl, yr), Math.max(xl, xr), Math.max(yl, yr) ); } - } - else if(stash.ids) { + } else if(stash.ids) { ids = stash.ids; - } - else return [pointData]; + } else return [pointData]; // pick the id closest to the point // note that point possibly may not be found @@ -738,8 +732,7 @@ function hoverPoints(pointData, xval, yval, hovermode) { id = ids[i]; } } - } - else { + } else { for(i = 0; i < ids.length; i++) { ptx = x[ids[i]]; pty = y[ids[i]]; @@ -902,8 +895,7 @@ function selectPoints(searchInfo, selectionTester) { x: x[i], y: y[i] }); - } - else { + } else { unels.push(i); } } diff --git a/src/traces/scattermapbox/convert.js b/src/traces/scattermapbox/convert.js index 7f271dce9bf..5dbc94ced6a 100644 --- a/src/traces/scattermapbox/convert.js +++ b/src/traces/scattermapbox/convert.js @@ -275,11 +275,9 @@ function makeSymbolGeoJSON(calcTrace) { function getFillFunc(attr) { if(Lib.isArrayOrTypedArray(attr)) { return function(v) { return v; }; - } - else if(attr) { + } else if(attr) { return function() { return attr; }; - } - else { + } else { return blankFillFunc; } } diff --git a/src/traces/scatterternary/calc.js b/src/traces/scatterternary/calc.js index f551d1987d3..471802e7b44 100644 --- a/src/traces/scatterternary/calc.js +++ b/src/traces/scatterternary/calc.js @@ -67,8 +67,7 @@ module.exports = function calc(gd, trace) { y = a; x = c - b; cd[i] = {x: x, y: y, a: a, b: b, c: c}; - } - else cd[i] = {x: false, y: false}; + } else cd[i] = {x: false, y: false}; } calcMarkerSize(trace, serieslen); diff --git a/src/traces/scatterternary/defaults.js b/src/traces/scatterternary/defaults.js index fce16c7cdd8..920df2a0317 100644 --- a/src/traces/scatterternary/defaults.js +++ b/src/traces/scatterternary/defaults.js @@ -42,11 +42,9 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout if(b) { len = Math.min(len, b.length); if(c) len = Math.min(len, c.length); - } - else if(c) len = Math.min(len, c.length); + } else if(c) len = Math.min(len, c.length); else len = 0; - } - else if(b && c) { + } else if(b && c) { len = Math.min(b.length, c.length); } diff --git a/src/traces/splom/index.js b/src/traces/splom/index.js index fbfdeff7653..557c4427fdb 100644 --- a/src/traces/splom/index.js +++ b/src/traces/splom/index.js @@ -292,13 +292,11 @@ function plotOne(gd, cd0) { scene.matrix.update(matrixOpts, matrixOpts); scene.matrix.update(scene.unselectedOptions, scene.selectedOptions); scene.matrix.update(viewOpts, viewOpts); - } - else { + } else { // delete selection pass scene.matrix.update(viewOpts, null); } - } - else { + } else { var opts = Lib.extendFlat({}, matrixOpts, viewOpts); scene.matrix.update(opts, null); stash.xpx = stash.ypx = null; @@ -406,8 +404,7 @@ function selectPoints(searchInfo, selectionTester) { x: x[i], y: y[i] }); - } - else { + } else { unels.push(i); } } diff --git a/src/traces/surface/convert.js b/src/traces/surface/convert.js index f0e3a3e8aeb..1be1c4d50e9 100644 --- a/src/traces/surface/convert.js +++ b/src/traces/surface/convert.js @@ -545,8 +545,7 @@ proto.update = function(data) { }); coords.push(intensity); - } - else { + } else { // when 'z' is used as 'intensity', // we must scale its value params.intensityBounds[0] *= scaleFactor[2]; @@ -593,8 +592,7 @@ proto.update = function(data) { if(contourParams.usecolormap) { surface.highlightTint[i] = params.contourTint[i] = 0; - } - else { + } else { surface.highlightTint[i] = params.contourTint[i] = 1; } params.contourWidth[i] = contourParams.width; diff --git a/src/traces/violin/plot.js b/src/traces/violin/plot.js index 10762814a92..1b1b7a148c2 100644 --- a/src/traces/violin/plot.js +++ b/src/traces/violin/plot.js @@ -103,8 +103,7 @@ module.exports = function plot(gd, plotinfo, cdViolins, violinLayer) { if(hasBothSides) { path = pathPos + 'L' + pathNeg.substr(1) + 'Z'; - } - else { + } else { var startPt = [posCenterPx, valAxis.c2p(density[0].t)]; var endPt = [posCenterPx, valAxis.c2p(density[len - 1].t)]; diff --git a/src/transforms/aggregate.js b/src/transforms/aggregate.js index 49e964a36d2..d1ff9c2f69e 100644 --- a/src/transforms/aggregate.js +++ b/src/transforms/aggregate.js @@ -190,8 +190,7 @@ exports.supplyDefaults = function(transformIn, traceOut) { arrayAttrs[target] = 0; aggregationsOut[i] = aggregationOut; - } - else aggregationsOut[i] = {enabled: false, _index: i}; + } else aggregationsOut[i] = {enabled: false, _index: i}; } // any array attributes we haven't yet covered, fill them with the default aggregation @@ -237,8 +236,7 @@ exports.calcTransform = function(gd, trace, opts) { newGrouping = [i]; groupings.push(newGrouping); indexToPoints[groupIndices[vi]] = originalPointsAccessor(i); - } - else { + } else { groupings[groupIndex].push(i); indexToPoints[groupIndices[vi]] = (indexToPoints[groupIndices[vi]] || []).concat(originalPointsAccessor(i)); } diff --git a/src/transforms/filter.js b/src/transforms/filter.js index 1d2c62dbf8c..4e96fbd30e9 100644 --- a/src/transforms/filter.js +++ b/src/transforms/filter.js @@ -219,8 +219,7 @@ exports.calcTransform = function(gd, trace, opts) { if(passed) { forAllAttrs(fillFn, i); indexToPoints[index++] = originalPointsAccessor(i); - } - else if(preservegaps) index++; + } else if(preservegaps) index++; } opts._indexToPoints = indexToPoints; @@ -243,13 +242,11 @@ function getFilterFunc(opts, d2c, targetCalendar) { if(isOperationIn(COMPARISON_OPS)) { coercedValue = hasArrayValue ? d2cValue(value[0]) : d2cValue(value); - } - else if(isOperationIn(INTERVAL_OPS)) { + } else if(isOperationIn(INTERVAL_OPS)) { coercedValue = hasArrayValue ? [d2cValue(value[0]), d2cValue(value[1])] : [d2cValue(value), d2cValue(value)]; - } - else if(isOperationIn(SET_OPS)) { + } else if(isOperationIn(SET_OPS)) { coercedValue = hasArrayValue ? value.map(d2cValue) : [d2cValue(value)]; } diff --git a/tasks/find_locale_strings.js b/tasks/find_locale_strings.js index ae3b3d5d214..7b041125f61 100644 --- a/tasks/find_locale_strings.js +++ b/tasks/find_locale_strings.js @@ -35,12 +35,13 @@ function findLocaleStrings() { var filePartialPath = file.substr(constants.pathToSrc.length); falafel(code, {locations: true}, function(node) { - // parse through code string looking for translated strings - // You may either assign `Lib.localize` to `_` and use that, or - // call `Lib.localize` directly. if(node.type === 'CallExpression' && (node.callee.name === '_' || node.callee.source() === 'Lib._') ) { + // parse through code string looking for translated strings + // You may either assign `Lib.localize` to `_` and use that, or + // call `Lib.localize` directly. + var strNode = node.arguments[1]; if(node.arguments.length !== 2) { logError(file, node, 'Localize takes 2 args'); @@ -53,11 +54,10 @@ function findLocaleStrings() { maxLen = Math.max(maxLen, strNode.value.length); hasTranslation = true; } - } + } else if(node.type === 'VariableDeclarator' && node.id.name === '_') { + // make sure localize is the only thing we assign to a variable `_` + // NB: this does not preclude using `_` for an unused function arg - // make sure localize is the only thing we assign to a variable `_` - // NB: this does not preclude using `_` for an unused function arg - else if(node.type === 'VariableDeclarator' && node.id.name === '_') { var src = node.init.source(); if(!localizeRE.test(src)) { logError(file, node, 'Use `_` only to mean localization'); @@ -74,8 +74,7 @@ function findLocaleStrings() { if(!EXIT_CODE) { if(noOutput) { console.log('ok find_locale_strings - no output requested.'); - } - else { + } else { var strings = Object.keys(dict).sort().map(function(k) { return k + spaces(maxLen - k.length) + ' // ' + dict[k]; }).join('\n'); diff --git a/tasks/header.js b/tasks/header.js index 620f330e178..622edf71299 100644 --- a/tasks/header.js +++ b/tasks/header.js @@ -76,8 +76,7 @@ function updateHeadersInSrcFiles() { var newCode = licenseSrc + '\n' + codeLines.join('\n'); common.writeFile(file, newCode); - } - else { + } else { // otherwise, throw an error throw new Error(file + ' : has wrong header information.'); } diff --git a/tasks/pretest.js b/tasks/pretest.js index 6a6b724dfef..9ff99fdfb0f 100644 --- a/tasks/pretest.js +++ b/tasks/pretest.js @@ -25,8 +25,7 @@ function makeTestImageFolders() { if(!common.doesDirExist(folderPath)) { fs.mkdirSync(folderPath); logger('initialize ' + info); - } - else logger(info + ' is present'); + } else logger(info + ' is present'); } makeOne(constants.pathToTestImages, 'test image folder'); diff --git a/tasks/pull_date_format.js b/tasks/pull_date_format.js index fafc9fef35a..1186e9912b8 100644 --- a/tasks/pull_date_format.js +++ b/tasks/pull_date_format.js @@ -22,8 +22,7 @@ if(!argLocale) { pullOneLocale(itemLocale); }); }); -} -else { +} else { pullOneLocale(argLocale); } @@ -68,8 +67,7 @@ function pullOneLocale(locale) { var outObj; try { outObj = eval('a=' + objText); - } - catch(e) { + } catch(e) { throw new Error(locale + '--' + objText); } diff --git a/tasks/test_syntax.js b/tasks/test_syntax.js index 385f1012594..e3018d5460b 100644 --- a/tasks/test_syntax.js +++ b/tasks/test_syntax.js @@ -135,14 +135,11 @@ function assertSrcContents() { if(source === 'Math.sign') { logs.push(file + ' : contains Math.sign (IE failure)'); - } - else if(source === 'window.getComputedStyle') { + } else if(source === 'window.getComputedStyle') { getComputedStyleCnt++; - } - else if(IE_BLACK_LIST.indexOf(lastPart) !== -1) { + } else if(IE_BLACK_LIST.indexOf(lastPart) !== -1) { logs.push(file + ' : contains .' + lastPart + ' (IE failure)'); - } - else if(IE_SVG_BLACK_LIST.indexOf(lastPart) !== -1) { + } else if(IE_SVG_BLACK_LIST.indexOf(lastPart) !== -1) { // add special case for sunburst where we use 'children' // off the d3-hierarchy output var dirParts = path.dirname(file).split(path.sep); @@ -151,23 +148,19 @@ function assertSrcContents() { if(!(isSunburstFile && isLinkedToObject)) { logs.push(file + ' : contains .' + lastPart + ' (IE failure in SVG)'); } - } - else if(FF_BLACK_LIST.indexOf(lastPart) !== -1) { + } else if(FF_BLACK_LIST.indexOf(lastPart) !== -1) { logs.push(file + ' : contains .' + lastPart + ' (FF failure)'); } - } - else if(node.type === 'Identifier' && node.source() === 'getComputedStyle') { + } else if(node.type === 'Identifier' && node.source() === 'getComputedStyle') { if(node.parent.source() !== 'window.getComputedStyle') { logs.push(file + ' : getComputedStyle must be called as a `window` property.'); } - } - else if(node.type === 'CallExpression' && node.callee.name === 'require') { + } else if(node.type === 'CallExpression' && node.callee.name === 'require') { var pathNode = node.arguments[0]; var pathStr = pathNode.value; if(pathNode.type !== 'Literal') { logs.push(file + ' : You may only `require` literals.'); - } - else if(BUILTINS.indexOf(pathStr) === -1) { + } else if(BUILTINS.indexOf(pathStr) === -1) { // node version 8.9.0+ can use require.resolve(request, {paths: [...]}) // and avoid this explicit conversion to the current location if(pathStr.charAt(0) === '.') { diff --git a/tasks/util/common.js b/tasks/util/common.js index c5947d312cb..e2fa0ed53a2 100644 --- a/tasks/util/common.js +++ b/tasks/util/common.js @@ -23,8 +23,7 @@ exports.writeFile = function(filePath, content, cb) { exports.doesDirExist = function(dirPath) { try { if(fs.statSync(dirPath).isDirectory()) return true; - } - catch(e) { + } catch(e) { return false; } @@ -34,8 +33,7 @@ exports.doesDirExist = function(dirPath) { exports.doesFileExist = function(filePath) { try { if(fs.statSync(filePath).isFile()) return true; - } - catch(e) { + } catch(e) { return false; } diff --git a/test/image/export_test.js b/test/image/export_test.js index 24802498d2e..69f13f0fb71 100644 --- a/test/image/export_test.js +++ b/test/image/export_test.js @@ -123,8 +123,7 @@ function testExport(mockName, format, cb) { if(format === 'svg') { var dims = sizeOf(imagePaths.test); didExport = (dims.width === WIDTH) && (dims.height === HEIGHT); - } - else { + } else { var stats = fs.statSync(imagePaths.test); didExport = stats.size > MIN_SIZE; } diff --git a/test/jasmine/assets/custom_assertions.js b/test/jasmine/assets/custom_assertions.js index f4bdba95af5..30828bf7605 100644 --- a/test/jasmine/assets/custom_assertions.js +++ b/test/jasmine/assets/custom_assertions.js @@ -322,11 +322,9 @@ exports.assertNodeOrder = function(selectorBehind, selectorInFront, msg) { var nodeInFront = document.querySelector(selectorInFront); if(!nodeBehind) { fail(selectorBehind + ' not found (' + msg + ')'); - } - else if(!nodeInFront) { + } else if(!nodeInFront) { fail(selectorInFront + ' not found (' + msg + ')'); - } - else { + } else { var parentsBehind = getParents(nodeBehind); var parentsInFront = getParents(nodeInFront); @@ -336,8 +334,7 @@ exports.assertNodeOrder = function(selectorBehind, selectorInFront, msg) { for(var i = 0; i < parentsBehind.length; i++) { if(parentsBehind[i] === parentsInFront[i]) { commonParent = parentsBehind[i]; - } - else { + } else { siblingBehind = parentsBehind[i]; siblingInFront = parentsInFront[i]; break; diff --git a/test/jasmine/assets/get_rect_center.js b/test/jasmine/assets/get_rect_center.js index 51b5df0128d..1117383354b 100644 --- a/test/jasmine/assets/get_rect_center.js +++ b/test/jasmine/assets/get_rect_center.js @@ -41,8 +41,7 @@ function findParentSVG(node) { if(parentNode.tagName === 'svg') { return parentNode; - } - else { + } else { return findParentSVG(parentNode); } } diff --git a/test/jasmine/tests/annotations_test.js b/test/jasmine/tests/annotations_test.js index 7f52f0e688b..94b7c9f2fff 100644 --- a/test/jasmine/tests/annotations_test.js +++ b/test/jasmine/tests/annotations_test.js @@ -907,8 +907,7 @@ describe('annotation clicktoshow', function() { var clickResult = Annotations.onClick(gd, hoverData(opts.newPts)); if(clickResult && clickResult.then) { return clickResult.then(function() { checkVisible(opts); }); - } - else { + } else { checkVisible(opts); } }; diff --git a/test/jasmine/tests/geo_test.js b/test/jasmine/tests/geo_test.js index 66ea091c014..fdad67c09cf 100644 --- a/test/jasmine/tests/geo_test.js +++ b/test/jasmine/tests/geo_test.js @@ -607,7 +607,8 @@ describe('Test geo interactions', function() { }; Plotly.restyle(gd, update).then(function() { - setTimeout(function() { mouseEvent('mousemove', 300, 230); + setTimeout(function() { + mouseEvent('mousemove', 300, 230); expect(cnt).toEqual(1); diff --git a/test/jasmine/tests/lib_geometry2d_test.js b/test/jasmine/tests/lib_geometry2d_test.js index 6bc8a81f09f..c491176b47c 100644 --- a/test/jasmine/tests/lib_geometry2d_test.js +++ b/test/jasmine/tests/lib_geometry2d_test.js @@ -23,8 +23,7 @@ describe('segmentsIntersect', function() { expect(result2.y).toBeWithin(expected[0], 1e-6); expect(result1.y).toBeWithin(expected[1], 1e-6); expect(result2.x).toBeWithin(expected[1], 1e-6); - } - else { + } else { expect(result1).toBe(expected); expect(result2).toBe(expected); } @@ -116,8 +115,7 @@ describe('getVisibleSegment', function() { if(!expected) { expect(vis).toBeUndefined(msg2); - } - else { + } else { expect(vis.min).toBeWithin(expected.min, buffer * 1.1, msg2); expect(vis.max).toBeWithin(expected.max, buffer * 1.1, msg2); expect(vis.len).toBeWithin(expected.len, buffer * 2.1, msg2); diff --git a/test/jasmine/tests/modebar_test.js b/test/jasmine/tests/modebar_test.js index 923df01c78b..60d08a664fb 100644 --- a/test/jasmine/tests/modebar_test.js +++ b/test/jasmine/tests/modebar_test.js @@ -933,8 +933,7 @@ describe('ModeBar', function() { if(ax.type === 'date') { var truncate = function(v) { return v.substr(0, 10); }; expect(actual.map(truncate)).toEqual(expected.map(truncate), axName); - } - else { + } else { expect(actual).toBeCloseToArray(expected, PRECISION, axName); } } diff --git a/test/jasmine/tests/parcoords_test.js b/test/jasmine/tests/parcoords_test.js index 40de35e4954..8b7876b3098 100644 --- a/test/jasmine/tests/parcoords_test.js +++ b/test/jasmine/tests/parcoords_test.js @@ -1205,8 +1205,7 @@ describe('parcoords constraint interactions', function() { if(hasGD) { expect(getDashArray(0)).toBeCloseToArray(initialDashArray0); expect(getDashArray(1)).toBeCloseToArray(initialDashArray1); - } - else { + } else { initialDashArray0 = getDashArray(0); initialDashArray1 = getDashArray(1); checkDashCount(initialDashArray0, 1); diff --git a/test/jasmine/tests/plot_api_react_test.js b/test/jasmine/tests/plot_api_react_test.js index 8399803ff9c..fceacad76c5 100644 --- a/test/jasmine/tests/plot_api_react_test.js +++ b/test/jasmine/tests/plot_api_react_test.js @@ -950,12 +950,10 @@ describe('Plotly.react and uirevision attributes', function() { if(Array.isArray(val1) && Array.isArray(val2)) { if(Array.isArray(val1[0]) && Array.isArray(val2[0])) { expect(val1).toBeCloseTo2DArray(val2, 2, msg); - } - else { + } else { expect(val1).toBeCloseToArray(val2, 2, msg); } - } - else { + } else { expect(val1).toBe(val2, msg); } } diff --git a/test/jasmine/tests/plot_api_test.js b/test/jasmine/tests/plot_api_test.js index 26ed172b9da..b3220ac1126 100644 --- a/test/jasmine/tests/plot_api_test.js +++ b/test/jasmine/tests/plot_api_test.js @@ -1280,8 +1280,7 @@ describe('Test plot api', function() { expect(gd.data[0].xbins).toBeUndefined(msg); expect(gd.data[1].xbins).toBeUndefined(msg); expect(gd.data[1].ybins).toBeUndefined(msg); - } - else { + } else { // we can have - and use - partial autobin now expect(gd.data[0].xbins).toEqual({start: start0}); expect(gd.data[1].xbins).toEqual({end: end1}); diff --git a/test/jasmine/tests/polygon_test.js b/test/jasmine/tests/polygon_test.js index 887e4d07a88..cc4238801a7 100644 --- a/test/jasmine/tests/polygon_test.js +++ b/test/jasmine/tests/polygon_test.js @@ -107,8 +107,7 @@ describe('polygon.tester', function() { for(j = 1; j < np; j++) { if(pt0[0] === pt1[0]) { testPts.push([pt0[0], pt0[1] + (pt1[1] - pt0[1]) * j / np]); - } - else { + } else { var x = pt0[0] + (pt1[0] - pt0[0]) * j / np; // calculated the same way as in the pt_in_polygon source, // so we know rounding errors will apply the same and this pt diff --git a/test/jasmine/tests/scatter_test.js b/test/jasmine/tests/scatter_test.js index ad4bb626314..7643125f063 100644 --- a/test/jasmine/tests/scatter_test.js +++ b/test/jasmine/tests/scatter_test.js @@ -159,11 +159,12 @@ describe('Test scatter', function() { }); describe('selected / unselected attribute containers', function() { - function _supply(patch) { traceIn = Lib.extendFlat({ - mode: 'markers', - x: [1, 2, 3], - y: [2, 1, 2] - }, patch); + function _supply(patch) { + traceIn = Lib.extendFlat({ + mode: 'markers', + x: [1, 2, 3], + y: [2, 1, 2] + }, patch); traceOut = {visible: true}; supplyDefaults(traceIn, traceOut, defaultColor, layout); } @@ -729,50 +730,53 @@ describe('end-to-end scatter tests', function() { {y: [3, 4], text: 'c'} ]); - function setMode(i) { return function() { - return Plotly.restyle(gd, cases[indices[i]].edit); - }; } + function setMode(i) { + return function() { + return Plotly.restyle(gd, cases[indices[i]].edit); + }; + } - function testOrdering(i) { return function() { - var name = cases[indices[i]].name; - var hasFills = name.indexOf('fill') !== -1; - var hasLines = name.indexOf('lines') !== -1; - var hasMarkers = name.indexOf('markers') !== -1; - var hasText = name.indexOf('text') !== -1; - var tracei, prefix; + function testOrdering(i) { + return function() { + var name = cases[indices[i]].name; + var hasFills = name.indexOf('fill') !== -1; + var hasLines = name.indexOf('lines') !== -1; + var hasMarkers = name.indexOf('markers') !== -1; + var hasText = name.indexOf('text') !== -1; + var tracei, prefix; // construct the expected ordering based on case name - var selectorArray = []; - for(tracei = 0; tracei < 3; tracei++) { - prefix = '.xy .trace:nth-child(' + (tracei + 1) + ') '; + var selectorArray = []; + for(tracei = 0; tracei < 3; tracei++) { + prefix = '.xy .trace:nth-child(' + (tracei + 1) + ') '; // two fills are attached to the first trace, one to the second - if(hasFills) { - if(tracei === 0) { - selectorArray.push( + if(hasFills) { + if(tracei === 0) { + selectorArray.push( prefix + 'g:first-child>.js-fill', prefix + 'g:last-child>.js-fill'); + } else if(tracei === 1) selectorArray.push(prefix + 'g:last-child>.js-fill'); } - else if(tracei === 1) selectorArray.push(prefix + 'g:last-child>.js-fill'); + if(hasLines) selectorArray.push(prefix + '.js-line'); + if(hasMarkers) selectorArray.push(prefix + '.point'); + if(hasText) selectorArray.push(prefix + '.textpoint'); } - if(hasLines) selectorArray.push(prefix + '.js-line'); - if(hasMarkers) selectorArray.push(prefix + '.point'); - if(hasText) selectorArray.push(prefix + '.textpoint'); - } // ordering in the legend - for(tracei = 0; tracei < 3; tracei++) { - prefix = '.legend .traces:nth-child(' + (tracei + 1) + ') '; - if(hasFills) selectorArray.push(prefix + '.js-fill'); - if(hasLines) selectorArray.push(prefix + '.js-line'); - if(hasMarkers) selectorArray.push(prefix + '.scatterpts'); - if(hasText) selectorArray.push(prefix + '.pointtext'); - } + for(tracei = 0; tracei < 3; tracei++) { + prefix = '.legend .traces:nth-child(' + (tracei + 1) + ') '; + if(hasFills) selectorArray.push(prefix + '.js-fill'); + if(hasLines) selectorArray.push(prefix + '.js-line'); + if(hasMarkers) selectorArray.push(prefix + '.scatterpts'); + if(hasText) selectorArray.push(prefix + '.pointtext'); + } - var msg = i ? ('from ' + cases[indices[i - 1]].name + ' to ') : 'from default to '; - msg += name; - assertMultiNodeOrder(selectorArray, msg); - }; } + var msg = i ? ('from ' + cases[indices[i - 1]].name + ' to ') : 'from default to '; + msg += name; + assertMultiNodeOrder(selectorArray, msg); + }; + } for(i = 0; i < indices.length; i++) { p = p.then(setMode(i)).then(testOrdering(i)); diff --git a/test/jasmine/tests/select_test.js b/test/jasmine/tests/select_test.js index 1bc48e0fd3c..2ffad4464fe 100644 --- a/test/jasmine/tests/select_test.js +++ b/test/jasmine/tests/select_test.js @@ -407,7 +407,8 @@ describe('Click-to-select', function() { clickmode: 'event+select' }) .then(function() { - return _click(136, 369, {}, true); }) + return _click(136, 369, {}, true); + }) .then(function() { assertSelectedPoints([[1], [], []]); return _click(245, 136, { shiftKey: true }); diff --git a/test/jasmine/tests/shapes_test.js b/test/jasmine/tests/shapes_test.js index fb72f515a1e..b65e28fa853 100644 --- a/test/jasmine/tests/shapes_test.js +++ b/test/jasmine/tests/shapes_test.js @@ -1381,8 +1381,7 @@ describe('Test shapes', function() { if(s.type === 'path') { s.path = 'M' + x0y0 + 'L' + x1y1 + 'L' + x1y0 + 'Z'; - } - else { + } else { s.x0 = x0; s.x1 = x1; s.y0 = y0; @@ -1508,8 +1507,7 @@ describe('Test shapes', function() { if(initialCoordinate.x) { expect(finalCoordinate.x - initialCoordinate.x) .toBeCloseTo(dx); - } - else { + } else { expect(finalCoordinate.y - initialCoordinate.y) .toBeCloseTo(dy); } @@ -1531,22 +1529,19 @@ describe('Test shapes', function() { var keyN, keyS, keyW, keyE; if(initialCoordinates.y0 < initialCoordinates.y1) { keyN = 'y0'; keyS = 'y1'; - } - else { + } else { keyN = 'y1'; keyS = 'y0'; } if(initialCoordinates.x0 < initialCoordinates.x1) { keyW = 'x0'; keyE = 'x1'; - } - else { + } else { keyW = 'x1'; keyE = 'x0'; } if(~direction.indexOf('n')) { expect(finalCoordinates[keyN] - initialCoordinates[keyN]) .toBeCloseTo(dy); - } - else if(~direction.indexOf('s')) { + } else if(~direction.indexOf('s')) { expect(finalCoordinates[keyS] - initialCoordinates[keyS]) .toBeCloseTo(dy); } @@ -1554,8 +1549,7 @@ describe('Test shapes', function() { if(~direction.indexOf('w')) { expect(finalCoordinates[keyW] - initialCoordinates[keyW]) .toBeCloseTo(dx); - } - else if(~direction.indexOf('e')) { + } else if(~direction.indexOf('e')) { expect(finalCoordinates[keyE] - initialCoordinates[keyE]) .toBeCloseTo(dx); } @@ -1611,8 +1605,7 @@ describe('Test shapes', function() { if(xParams[paramNumber]) { coordinates.push({ x: x2p(param) }); - } - else if(yParams[paramNumber]) { + } else if(yParams[paramNumber]) { coordinates.push({ y: y2p(param) }); } diff --git a/test/jasmine/tests/template_test.js b/test/jasmine/tests/template_test.js index f9ff0c14a67..7379147b031 100644 --- a/test/jasmine/tests/template_test.js +++ b/test/jasmine/tests/template_test.js @@ -303,8 +303,7 @@ describe('validateTemplate', function() { if(expected) { expect(countToCheck ? out1.slice(0, countToCheck) : out1) .toEqual(expected); - } - else { + } else { expect(out1).toBeUndefined(); } } diff --git a/test/jasmine/tests/transform_multi_test.js b/test/jasmine/tests/transform_multi_test.js index b99bb812fb5..817867f900c 100644 --- a/test/jasmine/tests/transform_multi_test.js +++ b/test/jasmine/tests/transform_multi_test.js @@ -229,8 +229,7 @@ describe('user-defined transforms:', function() { function assertSupplyDefaultsArgs(_transformIn, traceOut, _layout) { if(!calledSupplyDefaults) { expect(_transformIn).toBe(transformIn); - } - else { + } else { // second supplyDefaults call has _module attached expect(_transformIn).toEqual(jasmine.objectContaining({ type: 'fake',