Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
enforce space-before-blocks,
- so that: if() { / for() { and function() {
  not: if(){ / for(){ and function(){

  are the norm
  • Loading branch information
etpinard committed Feb 29, 2016
commit e183a988ebf93cd635814105f4dd189eef638943
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"no-spaced-func": [2],
"space-in-parens": [2, "never"],
"space-before-function-paren": [2, "never"],
"space-before-blocks": [2],
"no-multi-spaces": [2],
"space-infix-ops": [0, {"int32Hint": false}],
"quotes": [2, "single"],
Expand Down
20 changes: 10 additions & 10 deletions src/components/annotations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ annotations.draw = function(gd, index, opt, value) {
.attr('data-unformatted', options.text)
.text(options.text);

function textLayout(s){
function textLayout(s) {
s.call(Plotly.Drawing.font, font)
.attr({
'text-anchor': {
Expand All @@ -375,7 +375,7 @@ annotations.draw = function(gd, index, opt, value) {
return s;
}

function drawGraphicalElements(){
function drawGraphicalElements() {

// make sure lines are aligned the way they will be
// at the end, even if their position changes
Expand All @@ -395,8 +395,8 @@ annotations.draw = function(gd, index, opt, value) {
options._w = annwidth;
options._h = annheight;

function shiftFraction(v, anchor){
if(anchor==='auto'){
function shiftFraction(v, anchor) {
if(anchor==='auto') {
if(v < 1/3) anchor = 'left';
else if(v > 2/3) anchor = 'right';
else anchor = 'center';
Expand Down Expand Up @@ -469,7 +469,7 @@ annotations.draw = function(gd, index, opt, value) {

// make sure the arrowhead (if there is one)
// and the annotation center are visible
if(options.showarrow){
if(options.showarrow) {
arrowX = Plotly.Lib.constrain(annPosPx.x - options.ax, 1, fullLayout.width - 1);
arrowY = Plotly.Lib.constrain(annPosPx.y - options.ay, 1, fullLayout.height - 1);
}
Expand Down Expand Up @@ -498,7 +498,7 @@ annotations.draw = function(gd, index, opt, value) {

// add the arrow
// uses options[arrowwidth,arrowcolor,arrowhead] for styling
var drawArrow = function(dx, dy){
var drawArrow = function(dx, dy) {
d3.select(gd)
.selectAll('.annotation-arrow-g[data-index="' + index + '"]')
.remove();
Expand Down Expand Up @@ -541,7 +541,7 @@ annotations.draw = function(gd, index, opt, value) {
return;
}

edges.forEach(function(x){
edges.forEach(function(x) {
var p = lineIntersect(arrowX0, arrowY0, arrowX, arrowY,
x[0], x[1], x[2], x[3]);
if(p) {
Expand Down Expand Up @@ -711,7 +711,7 @@ annotations.draw = function(gd, index, opt, value) {
if(gd._context.editable) {
anntext.call(Plotly.util.makeEditable, ann)
.call(textLayout)
.on('edit', function(_text){
.on('edit', function(_text) {
options.text = _text;
this.attr({'data-unformatted': options.text});
this.call(textLayout);
Expand Down Expand Up @@ -839,7 +839,7 @@ annotations.calcAutorange = function(gd) {
if(!annotationList.length || !gd._fullData.length) return;

var annotationAxes = {};
annotationList.forEach(function(ann){
annotationList.forEach(function(ann) {
annotationAxes[ann.xref] = true;
annotationAxes[ann.yref] = true;
});
Expand All @@ -863,7 +863,7 @@ function annAutorange(gd) {
// relative to their anchor points
// use the arrow and the text bg rectangle,
// as the whole anno may include hidden text in its bbox
fullLayout.annotations.forEach(function(ann){
fullLayout.annotations.forEach(function(ann) {
var xa = Plotly.Axes.getFromId(gd, ann.xref),
ya = Plotly.Axes.getFromId(gd, ann.yref);
if(!(xa || ya)) return;
Expand Down
2 changes: 1 addition & 1 deletion src/components/color/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ color.addOpacity = function(cstr, op) {
// combine two colors into one apparent color
// if back has transparency or is missing,
// color.background is assumed behind it
color.combine = function(front, back){
color.combine = function(front, back) {
var fc = tinycolor(front).toRgb();
if(fc.a===1) return tinycolor(front).toRgbString();

Expand Down
14 changes: 7 additions & 7 deletions src/components/colorbar/draw.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = function draw(gd, id) {
// evaluated halfway between levels
opts.filllevels = null;

function component(){
function component() {
var fullLayout = gd._fullLayout;
if((typeof opts.fillcolor !== 'function') &&
(typeof opts.line.color !== 'function')) {
Expand All @@ -63,9 +63,9 @@ module.exports = function draw(gd, id) {
filllevels = [],
l,
linecolormap = typeof opts.line.color === 'function' ?
opts.line.color : function(){ return opts.line.color; },
opts.line.color : function() { return opts.line.color; },
fillcolormap = typeof opts.fillcolor === 'function' ?
opts.fillcolor : function(){ return opts.fillcolor; };
opts.fillcolor : function() { return opts.fillcolor; };

var l0 = opts.levels.end + opts.levels.size/100,
ls = opts.levels.size,
Expand All @@ -84,7 +84,7 @@ module.exports = function draw(gd, id) {
}
}
else {
filllevels = linelevels.map(function(v){
filllevels = linelevels.map(function(v) {
return v-opts.levels.size / 2;
});
filllevels.push(filllevels[filllevels.length - 1] +
Expand Down Expand Up @@ -233,7 +233,7 @@ module.exports = function draw(gd, id) {
// now draw the elements
var container = fullLayout._infolayer.selectAll('g.'+id).data([0]);
container.enter().append('g').classed(id,true)
.each(function(){
.each(function() {
var s = d3.select(this);
s.append('rect').classed('cbbg',true);
s.append('g').classed('cbfills',true);
Expand All @@ -260,7 +260,7 @@ module.exports = function draw(gd, id) {
Titles.draw(gd, cbAxisOut._id + 'title');
}

function drawAxis(){
function drawAxis() {
if(['top','bottom'].indexOf(opts.titleside)!==-1) {
// squish the axis top to make room for the title
var titleGroup = container.select('.cbtitle'),
Expand Down Expand Up @@ -373,7 +373,7 @@ module.exports = function draw(gd, id) {
return Axes.doTicks(gd, cbAxisOut);
}

function positionCB(){
function positionCB() {
// wait for the axis & title to finish rendering before
// continuing positioning
// TODO: why are we redrawing multiple times now with this?
Expand Down
14 changes: 7 additions & 7 deletions src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ drawing.setRect = function(s, x, y, w, h) {
s.call(drawing.setPosition, x, y).call(drawing.setSize, w, h);
};

drawing.translatePoints = function(s, xa, ya){
s.each(function(d){
drawing.translatePoints = function(s, xa, ya) {
s.each(function(d) {
// put xp and yp into d if pixel scaling is already done
var x = d.xp || xa.c2p(d.x),
y = d.yp || ya.c2p(d.y),
Expand Down Expand Up @@ -77,7 +77,7 @@ drawing.crispRound = function(td, lineWidth, dflt) {

drawing.lineGroupStyle = function(s, lw, lc, ld) {
s.style('fill','none')
.each(function(d){
.each(function(d) {
var line = (((d||[])[0]||{}).trace||{}).line||{},
lw1 = lw||line.width||0,
dash = ld||line.dash||'';
Expand Down Expand Up @@ -111,7 +111,7 @@ drawing.dashLine = function(s, dash, lineWidth) {

drawing.fillGroupStyle = function(s) {
s.style('stroke-width',0)
.each(function(d){
.each(function(d) {
var shape = d3.select(this);
try {
shape.call(Plotly.Color.fill, d[0].trace.fillcolor);
Expand Down Expand Up @@ -203,7 +203,7 @@ drawing.pointStyle = function(s, trace) {
return drawing.symbolFuncs[xBase](r) +
(x >= 200 ? DOTPATH : '');
})
.style('opacity',function(d){
.style('opacity',function(d) {
return (d.mo+1 || marker.opacity+1) - 1;
});
}
Expand All @@ -213,7 +213,7 @@ drawing.pointStyle = function(s, trace) {
markerScale = drawing.tryColorscale(marker, markerIn, ''),
lineScale = drawing.tryColorscale(marker, markerIn, 'line.');

s.each(function(d){
s.each(function(d) {
// 'so' is suspected outliers, for box plots
var fillColor,
lineColor,
Expand Down Expand Up @@ -299,7 +299,7 @@ drawing.tryColorscale = function(cont, contIn, prefix) {
var TEXTOFFSETSIGN = {start: 1, end: -1, middle: 0, bottom: 1, top: -1},
LINEEXPAND = 1.3;
drawing.textPointStyle = function(s, trace) {
s.each(function(d){
s.each(function(d) {
var p = d3.select(this),
text = d.tx || trace.text;
if(!text || Array.isArray(text)) {
Expand Down
12 changes: 6 additions & 6 deletions src/components/errorbars/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ errorBars.plot = function(gd, plotinfo, cd) {
.data(cd)
.enter().append('g')
.attr('class','errorbars')
.each(function(d){
.each(function(d) {
var trace = d[0].trace,
xObj = trace.error_x,
yObj = trace.error_y,
Expand All @@ -82,15 +82,15 @@ errorBars.plot = function(gd, plotinfo, cd) {
d3.select(this).selectAll('g')
.data(Lib.identity)
.enter().append('g')
.each(function(d){
.each(function(d) {
coords = errorcoords(d, xa, ya);
var eb = d3.select(this),
path;
if(sparse && !d.vis) return;

if(yObj.visible && isNumeric(coords.x) &&
isNumeric(coords.yh) &&
isNumeric(coords.ys)){
isNumeric(coords.ys)) {
var yw = yObj.width;
path = 'M'+(coords.x-yw)+','+coords.yh+'h'+(2*yw) + // hat
'm-'+yw+',0V'+coords.ys; // bar
Expand All @@ -102,7 +102,7 @@ errorBars.plot = function(gd, plotinfo, cd) {
}
if(xObj.visible && isNumeric(coords.y) &&
isNumeric(coords.xh) &&
isNumeric(coords.xs)){
isNumeric(coords.xs)) {
var xw = (xObj.copy_ystyle ? yObj : xObj).width;
path = 'M'+coords.xh+','+(coords.y-xw)+'v'+(2*xw) + // hat
'm0,-'+xw+'H'+coords.xs; // bar
Expand All @@ -116,8 +116,8 @@ errorBars.plot = function(gd, plotinfo, cd) {
});
};

errorBars.style = function(gd){
d3.select(gd).selectAll('g.errorbars').each(function(d){
errorBars.style = function(gd) {
d3.select(gd).selectAll('g.errorbars').each(function(d) {
var eb = d3.select(this),
trace = d[0].trace,
yObj = trace.error_y||{},
Expand Down
Loading