Skip to content
This repository was archived by the owner on Jul 29, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 9 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,28 @@
"mocha": true
},

"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module",
},

"extends": "eslint:recommended",

"rules": {
"complexity": [2, 55],
"max-statements": [2, 115],
"no-unreachable": 1,
/*
// some disabled options which might be useful
"no-console": 0,
"no-empty": 0,
"no-extra-semi": 0,
"no-fallthrough": 0,
"no-inner-declarations": 0,
"no-mixed-spaces-and-tabs": 0,
"no-redeclare": 0,
"no-unreachable": 1,
"no-unused-vars": 0,
"no-useless-escape": 0,
"no-useless-escape": 0,
// following will flag presence of console.log as error.
"no-console": ["error", { allow: ["warn", "error"] }],
}
}
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ addons:
- libgif-dev
- g++-4.8
before_script:
- npm run lint
- npm install -g gulp
# - npm run lint
- npm install gulp
script:
- gulp
- npm test
35 changes: 35 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var fs = require('fs');
var async = require('async');
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var gutil = require('gulp-util');
var concat = require('gulp-concat');
var cleanCSS = require('gulp-clean-css');
Expand Down Expand Up @@ -216,5 +217,39 @@ gulp.task('watch', watchTasks, function () {
gulp.watch(['index.js', 'lib/**/*'], watchTasks);
});


////////////////////////////////////////////////////////////////////////////////////////
// Linting
//
// Linting has intentionally NOT been added yet to the default task; there are simply
// too many errors at the moment to make this comfortable. Run it separately with:
//
// > gulp lint or > gulp lint-<module name>
//
// This is set up so that 'gulp lint' runs the linting over the complete lib directory.
// You can also run linting on the separate modules, e.g. 'gulp lint-network' for just
// the network module. Scan the tasks below for the available lint commands.
//
// Note that currently a separate lint is missing for Graph2d, DataSet and DataGroup.
////////////////////////////////////////////////////////////////////////////////////////


function runLintTask(pathPrefix) {
return gulp.src([ pathPrefix + '/**/*.js', '!node_modules/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
}

gulp.task('lint', function () {return runLintTask('lib');});
gulp.task('lint-timeline', function () {return runLintTask('lib/timeline');});
gulp.task('lint-network', function () {return runLintTask('lib/network');});
gulp.task('lint-graph3d', function () {return runLintTask('lib/graph3d');});


////////////////////////////////////////////////////////////////////////////////////////
// End Linting
////////////////////////////////////////////////////////////////////////////////////////

// The default task (called when you run `gulp`)
gulp.task('default', ['clean', 'bundle', 'minify']);
5 changes: 2 additions & 3 deletions lib/graph3d/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ Camera.prototype.setOffset = function(x, y) {
this.calculateCameraOrientation();
};


/**
* Get camera offset by horizontal and vertical
* @return {Point3d} x - horizontal offset, y - vertical offset, z - not used
*/
Camera.prototype.getOffset = function(x, y) {
Camera.prototype.getOffset = function() {
return this.cameraOffset;
};

Expand Down Expand Up @@ -165,7 +165,6 @@ Camera.prototype.calculateCameraOrientation = function() {
this.cameraRotation.z = -this.armRotation.horizontal;

var xa = this.cameraRotation.x;
var ya = this.cameraRotation.y;
var za = this.cameraRotation.z;
var dx = this.cameraOffset.x;
var dy = this.cameraOffset.y;
Expand Down
1 change: 0 additions & 1 deletion lib/graph3d/DataGroup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var DataSet = require('../DataSet');
var DataView = require('../DataView');
var Point3d = require('./Point3d');
var Range = require('./Range');


Expand Down
5 changes: 1 addition & 4 deletions lib/graph3d/Filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function Filter (dataGroup, column, graph) {
else {
this.loaded = true;
}
};
}


/**
Expand Down Expand Up @@ -176,9 +176,6 @@ Filter.prototype.loadInBackground = function(index) {
var frame = this.graph.frame;

if (index < this.values.length) {
var dataPointsTemp = this._getDataPoints(index);
//this.graph.redrawInfo(); // TODO: not neat

// create a progress box
if (frame.progress === undefined) {
frame.progress = document.createElement('DIV');
Expand Down
27 changes: 10 additions & 17 deletions lib/graph3d/Graph3d.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
var Emitter = require('emitter-component');
var DataSet = require('../DataSet');
var DataView = require('../DataView');
var util = require('../util');
var Point3d = require('./Point3d');
var Point2d = require('./Point2d');
var Camera = require('./Camera');
var Filter = require('./Filter');
var Slider = require('./Slider');
var StepNumber = require('./StepNumber');
var Range = require('./Range');
var Settings = require('./Settings');
var DataGroup = require('./DataGroup');

Expand Down Expand Up @@ -439,7 +435,7 @@ Graph3d.prototype.getDataPoints = function(data) {
Graph3d.prototype._getDataPoints = function (data) {
// TODO: store the created matrix dataPoints in the filters instead of
// reloading each time.
var x, y, i, z, obj, point;
var x, y, i, obj;

var dataPoints = [];

Expand Down Expand Up @@ -492,7 +488,7 @@ Graph3d.prototype._getDataPoints = function (data) {
// Add next member points for line drawing
for (i = 0; i < dataPoints.length; i++) {
if (i > 0) {
dataPoints[i - 1].pointNext = dataPoints[i];;
dataPoints[i - 1].pointNext = dataPoints[i];
}
}
}
Expand Down Expand Up @@ -692,8 +688,6 @@ Graph3d.prototype.setData = function (data) {
* @param {Object} options
*/
Graph3d.prototype.setOptions = function (options) {
var cameraPosition = undefined;

this.animationStop();

Settings.setOptions(options, this);
Expand Down Expand Up @@ -913,7 +907,6 @@ Graph3d.prototype._redrawLegend = function() {
var step = new StepNumber(legendMin, legendMax, (legendMax-legendMin)/5, true);
step.start(true);

var y;
var from;
var to;
while (!step.end()) {
Expand Down Expand Up @@ -1125,6 +1118,7 @@ Graph3d.prototype._redrawAxis = function() {
var xRange = this.xRange;
var yRange = this.yRange;
var zRange = this.zRange;
var point3d;

// draw x-grid lines
ctx.lineWidth = 1;
Expand Down Expand Up @@ -1152,8 +1146,8 @@ Graph3d.prototype._redrawAxis = function() {

if (this.showXAxis) {
yText = (armVector.x > 0) ? yRange.min : yRange.max;
var point3d = new Point3d(x, yText, zRange.min);
var msg = ' ' + this.xValueLabel(x) + ' ';
point3d = new Point3d(x, yText, zRange.min);
let msg = ' ' + this.xValueLabel(x) + ' ';
this.drawAxisLabelX(ctx, point3d, msg, armAngle, textMargin);
}

Expand Down Expand Up @@ -1187,7 +1181,7 @@ Graph3d.prototype._redrawAxis = function() {
if (this.showYAxis) {
xText = (armVector.y > 0) ? xRange.min : xRange.max;
point3d = new Point3d(xText, y, zRange.min);
var msg = ' ' + this.yValueLabel(y) + ' ';
let msg = ' ' + this.yValueLabel(y) + ' ';
this.drawAxisLabelY(ctx, point3d, msg, armAngle, textMargin);
}

Expand All @@ -1213,7 +1207,7 @@ Graph3d.prototype._redrawAxis = function() {
to = new Point2d(from2d.x - textMargin, from2d.y);
this._line(ctx, from2d, to, this.axisColor);

var msg = this.zValueLabel(z) + ' ';
let msg = this.zValueLabel(z) + ' ';
this.drawAxisLabelZ(ctx, from3d, msg, 5);

step.next();
Expand Down Expand Up @@ -1339,7 +1333,7 @@ Graph3d.prototype._getStrokeWidth = function(point) {
* Draw a bar element in the view with the given properties.
*/
Graph3d.prototype._redrawBar = function(ctx, point, xWidth, yWidth, color, borderColor) {
var i, j, surface;
var surface;

// calculate all corner points
var me = this;
Expand Down Expand Up @@ -1377,7 +1371,7 @@ Graph3d.prototype._redrawBar = function(ctx, point, xWidth, yWidth, color, borde
point.surfaces = surfaces;

// calculate the distance of each of the surface centers to the camera
for (j = 0; j < surfaces.length; j++) {
for (let j = 0; j < surfaces.length; j++) {
surface = surfaces[j];
var transCenter = this._convertPointToTranslation(surface.center);
surface.dist = this.showPerspective ? transCenter.length() : -transCenter.z;
Expand All @@ -1404,7 +1398,7 @@ Graph3d.prototype._redrawBar = function(ctx, point, xWidth, yWidth, color, borde
ctx.strokeStyle = borderColor;
ctx.fillStyle = color;
// NOTE: we start at j=2 instead of j=0 as we don't need to draw the two surfaces at the backside
for (j = 2; j < surfaces.length; j++) {
for (let j = 2; j < surfaces.length; j++) {
surface = surfaces[j];
this._polygon(ctx, surface.corners);
}
Expand Down Expand Up @@ -1652,7 +1646,6 @@ Graph3d.prototype._redrawSurfaceGraphPoint = function(ctx, point) {
var topSideVisible = true;
var fillStyle;
var strokeStyle;
var lineWidth;

if (this.showGrayBottom || this.showShadow) {
// calculate the cross product of the two vectors from center
Expand Down
2 changes: 1 addition & 1 deletion lib/graph3d/Point3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function Point3d(x, y, z) {
this.x = x !== undefined ? x : 0;
this.y = y !== undefined ? y : 0;
this.z = z !== undefined ? z : 0;
};
}

/**
* Subtract the two provided points, returns a-b
Expand Down
4 changes: 2 additions & 2 deletions lib/graph3d/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Slider.prototype.setPlayInterval = function(interval) {
* Retrieve the current play interval
* @return {Number} interval The interval in milliseconds
*/
Slider.prototype.getPlayInterval = function(interval) {
Slider.prototype.getPlayInterval = function() {
return this.playInterval;
};

Expand Down Expand Up @@ -333,7 +333,7 @@ Slider.prototype._onMouseMove = function (event) {
};


Slider.prototype._onMouseUp = function (event) {
Slider.prototype._onMouseUp = function (event) { // eslint-disable-line no-unused-vars
this.frame.style.cursor = 'auto';

// remove event listeners
Expand Down
2 changes: 1 addition & 1 deletion lib/graph3d/StepNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function StepNumber(start, end, step, prettyStep) {

this._current = 0;
this.setRange(start, end, step, prettyStep);
};
}


/**
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"devDependencies": {
"async": "^2.1.4",
"babel-core": "^6.6.5",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.4",
"babel-polyfill": "^6.22.0",
"babel-plugin-transform-es3-member-expression-literals": "^6.22.0",
Expand All @@ -55,9 +54,9 @@
"clean-css": "^4.0.2",
"eslint": "^4.2.0",
"gulp": "^3.9.1",
"gulp-eslint": "^4.0.0",
"gulp-clean-css": "^3.7.0",
"gulp-concat": "^2.6.1",
"gulp-eslint": "^4.0.0",
"gulp-rename": "^1.2.2",
"gulp-util": "^3.0.8",
"jsdom": "9.9.1",
Expand Down