Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

clean up whitespace and formatting to make jshint happy

  • Loading branch information...
commit ee2bccab622e847d914da6e97af2d840d71b4ea3 1 parent b306d72
@dchester dchester authored
View
2  .jshintignore
@@ -0,0 +1,2 @@
+src/js/Rickshaw.Class.js
+src/js/Rickshaw.Compat.ClassList.js
View
7 .jshintrc
@@ -0,0 +1,7 @@
+{
+ "funcscope": true,
+ "lastsemic": true,
+ "loopfunc": true,
+ "eqnull": true,
+ "expr": true
+}
View
4 src/js/Rickshaw.Fixtures.Number.js
@@ -7,7 +7,7 @@ Rickshaw.Fixtures.Number.formatKMBT = function(y) {
else if (abs_y >= 1000000) { return y / 1000000 + "M" }
else if (abs_y >= 1000) { return y / 1000 + "K" }
else if (abs_y < 1 && y > 0) { return y.toFixed(2) }
- else if (abs_y == 0) { return '' }
+ else if (abs_y === 0) { return '' }
else { return y }
};
@@ -19,6 +19,6 @@ Rickshaw.Fixtures.Number.formatBase1024KMGTP = function(y) {
else if (abs_y >= 1048576) { return y / 1048576 + "M" }
else if (abs_y >= 1024) { return y / 1024 + "K" }
else if (abs_y < 1 && y > 0) { return y.toFixed(2) }
- else if (abs_y == 0) { return '' }
+ else if (abs_y === 0) { return '' }
else { return y }
};
View
12 src/js/Rickshaw.Fixtures.RandomData.js
@@ -18,15 +18,15 @@ Rickshaw.Fixtures.RandomData = function(timeInterval) {
data.forEach( function(series) {
var randomVariance = Math.random() * 20;
- var v = randomValue / 25 + counter++
- + (Math.cos((index * counter * 11) / 960) + 2) * 15
- + (Math.cos(index / 7) + 2) * 7
- + (Math.cos(index / 17) + 2) * 1;
+ var v = randomValue / 25 + counter++ +
+ (Math.cos((index * counter * 11) / 960) + 2) * 15 +
+ (Math.cos(index / 7) + 2) * 7 +
+ (Math.cos(index / 17) + 2) * 1;
series.push( { x: (index * timeInterval) + timeBase, y: v + randomVariance } );
} );
- lastRandomValue = randomValue * .85;
- }
+ lastRandomValue = randomValue * 0.85;
+ };
};
View
13 src/js/Rickshaw.Fixtures.Time.js
@@ -12,7 +12,7 @@ Rickshaw.Fixtures.Time = function() {
{
name: 'decade',
seconds: 86400 * 365.25 * 10,
- formatter: function(d) { return (parseInt(d.getUTCFullYear() / 10) * 10) }
+ formatter: function(d) { return (parseInt(d.getUTCFullYear() / 10, 10) * 10) }
}, {
name: 'year',
seconds: 86400 * 365.25,
@@ -70,11 +70,14 @@ Rickshaw.Fixtures.Time = function() {
this.ceil = function(time, unit) {
+ var nearFuture;
+ var rounded;
+
if (unit.name == 'month') {
- var nearFuture = new Date((time + unit.seconds - 1) * 1000);
+ nearFuture = new Date((time + unit.seconds - 1) * 1000);
- var rounded = new Date(0);
+ rounded = new Date(0);
rounded.setUTCFullYear(nearFuture.getUTCFullYear());
rounded.setUTCMonth(nearFuture.getUTCMonth());
rounded.setUTCDate(1);
@@ -88,9 +91,9 @@ Rickshaw.Fixtures.Time = function() {
if (unit.name == 'year') {
- var nearFuture = new Date((time + unit.seconds - 1) * 1000);
+ nearFuture = new Date((time + unit.seconds - 1) * 1000);
- var rounded = new Date(0);
+ rounded = new Date(0);
rounded.setUTCFullYear(nearFuture.getUTCFullYear());
rounded.setUTCMonth(0);
rounded.setUTCDate(1);
View
2  src/js/Rickshaw.Graph.Annotate.js
@@ -90,7 +90,7 @@ Rickshaw.Graph.Annotate = function(args) {
var annotationRangeWidth = annotationRangeEnd - annotationRangeStart;
box.rangeElement.style.left = annotationRangeStart + 'px';
- box.rangeElement.style.width = annotationRangeWidth + 'px'
+ box.rangeElement.style.width = annotationRangeWidth + 'px';
box.rangeElement.classList.remove('offscreen');
}
View
9 src/js/Rickshaw.Graph.Axis.X.js
@@ -61,12 +61,13 @@ Rickshaw.Graph.Axis.X = function(args) {
axis.tickFormat( args.tickFormat || function(x) { return x } );
var berth = Math.floor(this.width * berthRate / 2) || 0;
+ var transform;
if (this.orientation == 'top') {
var yOffset = this.height || this.graph.height;
- var transform = 'translate(' + berth + ',' + yOffset + ')';
+ transform = 'translate(' + berth + ',' + yOffset + ')';
} else {
- var transform = 'translate(' + berth + ', 0)';
+ transform = 'translate(' + berth + ', 0)';
}
if (this.element) {
@@ -94,10 +95,10 @@ Rickshaw.Graph.Axis.X = function(args) {
if (typeof window !== 'undefined') {
var style = window.getComputedStyle(element, null);
- var elementHeight = parseInt(style.getPropertyValue('height'));
+ var elementHeight = parseInt(style.getPropertyValue('height'), 10);
if (!args.auto) {
- var elementWidth = parseInt(style.getPropertyValue('width'));
+ var elementWidth = parseInt(style.getPropertyValue('width'), 10);
}
}
View
6 src/js/Rickshaw.Graph.Axis.Y.js
@@ -43,10 +43,10 @@ Rickshaw.Graph.Axis.Y = function(args) {
if (typeof window !== 'undefined') {
var style = window.getComputedStyle(this.element.parentNode, null);
- var elementWidth = parseInt(style.getPropertyValue('width'));
+ var elementWidth = parseInt(style.getPropertyValue('width'), 10);
if (!args.auto) {
- var elementHeight = parseInt(style.getPropertyValue('height'));
+ var elementHeight = parseInt(style.getPropertyValue('height'), 10);
}
}
@@ -81,7 +81,7 @@ Rickshaw.Graph.Axis.Y = function(args) {
.append("svg:g")
.attr("class", ["y_ticks", this.ticksTreatment].join(" "))
.attr("transform", transform)
- .call(axis.ticks(this.ticks).tickSubdivide(0).tickSize(this.tickSize))
+ .call(axis.ticks(this.ticks).tickSubdivide(0).tickSize(this.tickSize));
var gridSize = (this.orientation == 'right' ? 1 : -1) * this.graph.width;
View
2  src/js/Rickshaw.Graph.Behavior.Series.Highlight.js
@@ -53,7 +53,7 @@ Rickshaw.Graph.Behavior.Series.Highlight = function(args) {
var series = self.graph.series.pop();
self.graph.series.splice(line.originalIndex, 0, series);
- delete line['originalIndex'];
+ delete line.originalIndex;
}
if (colorSafe[line.series.name]) {
View
4 src/js/Rickshaw.Graph.Behavior.Series.Toggle.js
@@ -21,7 +21,7 @@ Rickshaw.Graph.Behavior.Series.Toggle = function(args) {
line.series.disable();
line.element.classList.add('disabled');
}
- }
+ };
var label = line.element.getElementsByTagName('span')[0];
label.onclick = function(e){
@@ -85,7 +85,7 @@ Rickshaw.Graph.Behavior.Series.Toggle = function(args) {
ui.item.unbind('no.onclick');
}, 250);
}
- })
+ });
this.legend.lines.forEach( function(l) {
self.addAnchor(l);
View
10 src/js/Rickshaw.Graph.HoverDetail.js
@@ -68,7 +68,11 @@ Rickshaw.Graph.HoverDetail = Rickshaw.Class.create({
for (var i = approximateIndex; i < data.length - 1;) {
if (!data[i] || !data[i + 1]) break;
- if (data[i].x <= domainX && data[i + 1].x > domainX) { dataIndex = i; break }
+
+ if (data[i].x <= domainX && data[i + 1].x > domainX) {
+ dataIndex = i;
+ break;
+ }
if (data[i + 1].x <= domainX) { i++ } else { i-- }
}
@@ -193,7 +197,7 @@ Rickshaw.Graph.HoverDetail = Rickshaw.Class.create({
'mousemove',
function(e) {
this.visible = true;
- this.update(e)
+ this.update(e);
}.bind(this),
false
);
@@ -206,7 +210,7 @@ Rickshaw.Graph.HoverDetail = Rickshaw.Class.create({
if (e.relatedTarget && !(e.relatedTarget.compareDocumentPosition(this.graph.element) & Node.DOCUMENT_POSITION_CONTAINS)) {
this.hide();
}
- }.bind(this),
+ }.bind(this),
false
);
}
View
2  src/js/Rickshaw.Graph.Legend.js
@@ -13,7 +13,7 @@ Rickshaw.Graph.Legend = function(args) {
element.appendChild(list);
var series = graph.series
- .map( function(s) { return s } )
+ .map( function(s) { return s } );
if (!args.naturalOrder) {
series = series.reverse();
View
4 src/js/Rickshaw.Graph.RangeSlider.js
@@ -41,10 +41,10 @@ Rickshaw.Graph.RangeSlider = function(args) {
$(element).slider('option', 'min', graph.dataDomain()[0]);
$(element).slider('option', 'max', graph.dataDomain()[1]);
- if (graph.window.xMin == undefined) {
+ if (graph.window.xMin == null) {
values[0] = graph.dataDomain()[0];
}
- if (graph.window.xMax == undefined) {
+ if (graph.window.xMax == null) {
values[1] = graph.dataDomain()[1];
}
View
4 src/js/Rickshaw.Graph.Renderer.Area.js
@@ -21,7 +21,7 @@ Rickshaw.Graph.Renderer.Area = Rickshaw.Class.create( Rickshaw.Graph.Renderer, {
.x( function(d) { return graph.x(d.x) } )
.y0( function(d) { return graph.y(d.y0) } )
.y1( function(d) { return graph.y(d.y + d.y0) } )
- .interpolate(graph.interpolation).tension(this.tension)
+ .interpolate(graph.interpolation).tension(this.tension);
factory.defined && factory.defined( function(d) { return d.y !== null } );
return factory;
@@ -34,7 +34,7 @@ Rickshaw.Graph.Renderer.Area = Rickshaw.Class.create( Rickshaw.Graph.Renderer, {
var factory = d3.svg.line()
.x( function(d) { return graph.x(d.x) } )
.y( function(d) { return graph.y(d.y + d.y0) } )
- .interpolate(graph.interpolation).tension(this.tension)
+ .interpolate(graph.interpolation).tension(this.tension);
factory.defined && factory.defined( function(d) { return d.y !== null } );
return factory;
View
2  src/js/Rickshaw.Graph.Renderer.Bar.js
@@ -26,7 +26,7 @@ Rickshaw.Graph.Renderer.Bar = Rickshaw.Class.create( Rickshaw.Graph.Renderer, {
var domain = $super();
var frequentInterval = this._frequentInterval();
- domain.x[1] += parseInt(frequentInterval.magnitude);
+ domain.x[1] += parseInt(frequentInterval.magnitude, 10);
return domain;
},
View
2  src/js/Rickshaw.Graph.Renderer.Line.js
@@ -20,7 +20,7 @@ Rickshaw.Graph.Renderer.Line = Rickshaw.Class.create( Rickshaw.Graph.Renderer, {
var factory = d3.svg.line()
.x( function(d) { return graph.x(d.x) } )
.y( function(d) { return graph.y(d.y) } )
- .interpolate(this.graph.interpolation).tension(this.tension)
+ .interpolate(this.graph.interpolation).tension(this.tension);
factory.defined && factory.defined( function(d) { return d.y !== null } );
return factory;
View
4 src/js/Rickshaw.Graph.Renderer.js
@@ -36,7 +36,7 @@ Rickshaw.Graph.Renderer = Rickshaw.Class.create( {
var firstPoint = stackedData[0][0];
var xMin = firstPoint.x;
- var xMax = firstPoint.x
+ var xMax = firstPoint.x;
var yMin = firstPoint.y + firstPoint.y0;
var yMax = firstPoint.y + firstPoint.y0;
@@ -45,7 +45,7 @@ Rickshaw.Graph.Renderer = Rickshaw.Class.create( {
series.forEach( function(d) {
- if (d.y == undefined) return;
+ if (d.y == null) return;
var y = d.y + d.y0;
View
2  src/js/Rickshaw.Graph.Smoother.js
@@ -64,6 +64,6 @@ Rickshaw.Graph.Smoother = function(args) {
this.aggregationScale = scale;
this.graph.update();
- }
+ };
};
View
8 src/js/Rickshaw.Graph.js
@@ -81,7 +81,7 @@ Rickshaw.Graph = function(args) {
if (typeof x != 'number' || ( typeof y != 'number' && y !== null ) ) {
throw "x and y properties of points should be numbers instead of " +
- (typeof x) + " and " + (typeof y)
+ (typeof x) + " and " + (typeof y);
}
}, this );
@@ -236,8 +236,8 @@ Rickshaw.Graph = function(args) {
if (typeof window !== undefined) {
var style = window.getComputedStyle(this.element, null);
- var elementWidth = parseInt(style.getPropertyValue('width'));
- var elementHeight = parseInt(style.getPropertyValue('height'));
+ var elementWidth = parseInt(style.getPropertyValue('width'), 10);
+ var elementHeight = parseInt(style.getPropertyValue('height'), 10);
}
this.width = args.width || elementWidth || 400;
@@ -246,7 +246,7 @@ Rickshaw.Graph = function(args) {
this.vis && this.vis
.attr('width', this.width)
.attr('height', this.height);
- }
+ };
this.initialize(args);
};
View
4 src/js/Rickshaw.Series.FixedDuration.js
@@ -4,7 +4,7 @@ Rickshaw.Series.FixedDuration = Rickshaw.Class.create(Rickshaw.Series, {
initialize: function (data, palette, options) {
- var options = options || {}
+ options = options || {};
if (typeof(options.timeInterval) === 'undefined') {
throw new Error('FixedDuration series requires timeInterval');
@@ -52,7 +52,7 @@ Rickshaw.Series.FixedDuration = Rickshaw.Class.create(Rickshaw.Series, {
addData: function($super, data) {
- $super(data)
+ $super(data);
this.currentSize += 1;
this.currentIndex += 1;
View
6 src/js/Rickshaw.Series.js
@@ -4,7 +4,7 @@ Rickshaw.Series = Rickshaw.Class.create( Array, {
initialize: function (data, palette, options) {
- options = options || {}
+ options = options || {};
this.palette = new Rickshaw.Color.Palette(palette);
@@ -33,11 +33,11 @@ Rickshaw.Series = Rickshaw.Class.create( Array, {
item.data = (item.data || []);
// backfill, if necessary
- if ((item.data.length == 0) && this.length && (this.getIndex() > 0)) {
+ if ((item.data.length === 0) && this.length && (this.getIndex() > 0)) {
this[0].data.forEach( function(plot) {
item.data.push({ x: plot.x, y: 0 });
} );
- } else if (item.data.length == 0) {
+ } else if (item.data.length === 0) {
item.data.push({ x: this.timeBase - (this.timeInterval || 0), y: 0 });
}
Please sign in to comment.
Something went wrong with that request. Please try again.