diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 00000000000..f7a63bcaa49
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,7 @@
+node_modules
+dist
+build
+
+test/jasmine/assets/jquery-1.8.3.min.js
+src/plots/polar/micropolar.js
+src/plots/geo/projections.js
diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 00000000000..a3a0894af1d
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,40 @@
+{
+ "root": true,
+ "extends": [
+ "eslint:recommended",
+ ],
+ "env": {
+ "commonjs": true
+ },
+ "rules": {
+ "no-trailing-spaces": [2],
+ "no-multiple-empty-lines": [2, {"max": 3, "maxEOF": 1}],
+ "linebreak-style": [2, "unix"],
+ "indent": [2, 4, {"SwitchCase": 1}],
+ "max-len": [0, 80],
+ "brace-style": [0, "stroustrup", {"allowSingleLine": true}],
+ "curly": [0, "multi"],
+ "camelcase": [0, {"properties": "never"}],
+ "comma-spacing": [0, {"before": false, "after": true}],
+ "comma-style": [2, "last"],
+ "semi": [2],
+ "semi-spacing": [2, {"before": false, "after": true}],
+ "key-spacing": [0, {"beforeColon": false, "afterColon": true}],
+ "no-spaced-func": [2],
+ "space-in-parens": [2, "never"],
+ "space-before-function-paren": [2, "never"],
+ "no-multi-spaces": [2],
+ "space-infix-ops": [0, {"int32Hint": false}],
+ "quotes": [2, "single"],
+ "dot-notation": [2, {"allowKeywords": false}],
+ "eqeqeq": [2],
+ "new-cap": [0],
+ "no-redeclare": [2, {"builtinGlobals": true}],
+ "no-shadow": [0, {"builtinGlobals": true}],
+ "block-scoped-var": [2],
+ "no-unused-vars": [2],
+ "no-use-before-define": [2, "nofunc"],
+ "no-loop-func": [2],
+ "no-console": [0]
+ },
+}
diff --git a/.jshintrc b/.jshintrc
deleted file mode 100644
index 2190b0e1c7c..00000000000
--- a/.jshintrc
+++ /dev/null
@@ -1,72 +0,0 @@
-{
- // environments
- "browser": true, // Define globals exposed by modern browsers.
- "jquery": false, // Define globals exposed by jQuery.
- "node": true, // Define globals exposed by Node.js.
- "jasmine": true, // Define globals exposed by jasmine
-
- // enforcing (true means bug us about it)
- "camelcase": false, // Force all variable names to use either camelCase style or UPPER_CASE with underscores.
- "curly": false, // This option requires you to always put curly braces around blocks in loops and conditionals.
- "eqeqeq": true, // Prohibit use of == and != in favor of === and !==.
- "es3": true, // This option tells JSHint that your code needs to adhere to ECMAScript 3 spec (old browsers)
- "forin": false, // This option requires all for in loops to filter object's items.
- "freeze": true, // This options prohibits overwriting prototypes of native objects such as Array, Date and so on.
- "immed": true, // This option prohibits the use of immediate function invocations without wrapping them in parentheses.
- "indent": 4, // Enforce tab width of 4 spaces.
- "latedef": "nofunc", // Prohibit use of a variable before it is defined.
- "maxcomplexity": false, // This option lets you control cyclomatic complexity throughout your code.
- "maxdepth": 6, // This option lets you control how nested do you want your blocks to be
- "maxlen": 120, // Enforce line length to 120 characters
- "newcap": true, // Require capitalized names for constructor functions.
- "noarg": true, // This option prohibits the use of arguments.caller and arguments.callee.
- "noempty": true, // This option warns when you have an empty block in your code.
- "nonbsp": true, // This option warns about "non-breaking whitespace" characters.
- "nonew": true, // This option prohibits the use of constructor functions for side-effects.
- "plusplus": false, // This option prohibits the use of unary increment and decrement operators.
- "quotmark": "single", // Enforce use of single quotation marks for strings.
- "strict": true, // Enforce placing 'use strict' at the top function scope
- "trailing": true, // Prohibit trailing whitespace.
- "undef": true, // Prohibit use of explicitly undeclared variables.
- "unused": true, // Warn when variables are defined but never used.
-
- // relaxing (true means DON'T bug us about it)
- "asi": false, // This option suppresses warnings about missing semicolons.
- "boss": false, // This option suppresses warnings about the use of assignments in cases where comparisons are expected.
- "debug": false, // This option suppresses warnings about the debugger statements in your code.
- "eqnull": true, // Suppress warnings about == null comparisons.
- "esnext": true, // This option tells JSHint that your code uses ECMAScript 6 specific syntax.
- "evil": false, // This option suppresses warnings about the use of eval.
- "expr": false, // This option suppresses warnings about the use of expressions where normally you would expect to see assignments or function calls.
- "funcscope": false, // This option suppresses warnings about declaring variables inside of control structures while accessing them later from the outside.
- "globalstrict": false, // This option suppresses warnings about the use of global strict mode.
- "iterator": false, // This option suppresses warnings about the __iterator__ property.
- "lastsemic": false, // This option suppresses warnings about missing semicolons
- "laxbreak": false, // This option suppresses most of the warnings about possibly unsafe line breakings in your code.
- "laxcomma": false, // This option suppresses warnings about comma-first coding style
- "loopfunc": false, // This option suppresses warnings about functions inside of loops.
- "maxerr": 500, // This options allows you to set the maximum amount of warnings JSHint will produce before giving up.
- "moz": false, // This options tells JSHint that your code uses Mozilla JavaScript extensions.
- "multistr": false, // This option suppresses warnings about multi-line strings.
- "notypeof": false, // This option suppresses warnings about invalid typeof operator values.
- "proto": false, // This option suppresses warnings about the __proto__ property.
- "scripturl": false, // This option suppresses warnings about the use of script-targeted URLs—such as javascript:...
- "shadow": false, // This option suppresses warnings about variable shadowing
- "sub": false, // This option suppresses warnings about using [] notation when it can be expressed in dot notation
- "supernew": false, // This option suppresses warnings about "weird" constructions like new function () { ... } and new Object;
- "validthis": false, // This option suppresses warnings about possible strict violations when the code is running in strict mode
- "noyield": false, // This option suppresses warnings about generator functions with no yield statement in them.
-
- // global pre defined variables
- "predef": [
- "JSON",
- "Uint8Array",
- "Uint16Array",
- "Uint32Array",
- "Int8Array",
- "Int16Array",
- "Int32Array",
- "Float32Array",
- "Float64Array"
- ]
-}
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 22db495b9e7..9081b3d311b 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -116,8 +116,9 @@ To view the results of a run on CircleCI, download the `build/test_images/` and
### Coding style
-- 4-space indentation
-- semi-colons are required
-- trailing commas
-
Check if ok, with `npm run lint`
+
+- See [eslintrc](https://github.com/plotly/plotly.js/blob/master/.eslintrc) and
+ the eslint [list of rules](http://eslint.org/docs/rules/) for more details.
+- Rules listed in the eslintrc file with the ignore flag `0` are the recommended
+ rules for new code added.
diff --git a/devtools/.eslintrc b/devtools/.eslintrc
new file mode 100644
index 00000000000..aabacb13e13
--- /dev/null
+++ b/devtools/.eslintrc
@@ -0,0 +1,7 @@
+{
+ "extends": "../.eslintrc",
+ "env": {
+ "node": true,
+ "browser": true
+ }
+}
diff --git a/devtools/image_viewer/viewer.js b/devtools/image_viewer/viewer.js
index 5b1d8e4fbca..8802da4222b 100644
--- a/devtools/image_viewer/viewer.js
+++ b/devtools/image_viewer/viewer.js
@@ -37,7 +37,7 @@ function createButton(imageName) {
button.style.height = '40px';
button.innerHTML = imageName;
- button.addEventListener('click', function () {
+ button.addEventListener('click', function() {
var imgBaseline = createImg(dirBaseline, imageName),
imgTest = createImg(dirTest, imageName),
imgDiff = createImg(dirDiff, 'diff-' + imageName);
@@ -50,7 +50,7 @@ function createButton(imageName) {
$mock.innerHTML = '';
$mock.appendChild(createJSONview(mock));
- });
+ });
});
return button;
diff --git a/devtools/test_dashboard/buttons.js b/devtools/test_dashboard/buttons.js
index 7cf41151a55..7f9068298b0 100644
--- a/devtools/test_dashboard/buttons.js
+++ b/devtools/test_dashboard/buttons.js
@@ -1,3 +1,5 @@
+/* global Plotly:false Tabs:false */
+
var plotlist = document.getElementById('plot-list');
var anchor = document.getElementById('embedded-graph');
var image = document.getElementById('embedded-image');
@@ -11,7 +13,7 @@ anchor.style.width = '1000px';
function plotButtons(plots, figDir) {
- Object.keys(plots).forEach( function (plotname) {
+ Object.keys(plots).forEach(function(plotname) {
var button = document.createElement('button');
@@ -23,7 +25,7 @@ function plotButtons(plots, figDir) {
plotlist.appendChild(button);
- button.addEventListener('click', function () {
+ button.addEventListener('click', function() {
var myImage = new Image();
myImage.src = figDir + plotname + '.png';
@@ -55,7 +57,7 @@ function plotButtons(plots, figDir) {
plotlist.appendChild(snapshot);
- snapshot.addEventListener('click', function () {
+ snapshot.addEventListener('click', function() {
/*
* Grab the currently loaded plot and make an image - replacing the plot.
@@ -67,7 +69,7 @@ function plotButtons(plots, figDir) {
if (!layout || !data) return;
- Plotly.Plots.getSubplotIds(gd._fullLayout, 'gl3d').forEach( function (key) {
+ Plotly.Plots.getSubplotIds(gd._fullLayout, 'gl3d').forEach(function(key) {
var scene = gd._fullLayout[key]._scene;
scene.destroy();
});
@@ -80,23 +82,23 @@ function plotButtons(plots, figDir) {
/*
* Replot with staticPlot
*/
- Plotly.plot(gd, data, layout, {staticPlot: true, plotGlPixelRatio: 2}).then( function () {
- Plotly.Plots.getSubplotIds(gd._fullLayout, 'gl3d').forEach( function (key) {
- var scene = gd._fullLayout[key]._scene;
- var dataURL = scene.toImage();
-
- var myImage = new Image();
- myImage.src = dataURL;
-
- myImage.onload = function () {
- myImage.height = scene.container.clientHeight;
- myImage.width = scene.container.clientWidth;
- };
-
- image.innerHTML = '';
- image.appendChild(myImage);
- });
- })
+ Plotly.plot(gd, data, layout, {staticPlot: true, plotGlPixelRatio: 2}).then(function() {
+ Plotly.Plots.getSubplotIds(gd._fullLayout, 'gl3d').forEach(function(key) {
+ var scene = gd._fullLayout[key]._scene;
+ var dataURL = scene.toImage();
+
+ var myImage = new Image();
+ myImage.src = dataURL;
+
+ myImage.onload = function() {
+ myImage.height = scene.container.clientHeight;
+ myImage.width = scene.container.clientWidth;
+ };
+
+ image.innerHTML = '';
+ image.appendChild(myImage);
+ });
+ });
});
var pummelButton = document.createElement('button');
@@ -112,17 +114,17 @@ function plotButtons(plots, figDir) {
var mock = require('@mocks/gl3d_marker-color.json');
var statusDiv = document.getElementById('status-info');
- pummelButton.addEventListener('click', function () {
- setInterval(function () {
+ pummelButton.addEventListener('click', function() {
+ setInterval(function() {
var plotDiv = document.createElement('div');
window.plotDiv = plotDiv;
plotDiv.id = 'div' + i;
document.body.appendChild(plotDiv);
- Plotly.plot(plotDiv, mock.data, mock.layout, {staticPlot: true}).then(function () {
+ Plotly.plot(plotDiv, mock.data, mock.layout, {staticPlot: true}).then(function() {
- Plotly.Plots.getSubplotIds(plotDiv._fullLayout, 'gl3d').forEach( function (key) {
+ Plotly.Plots.getSubplotIds(plotDiv._fullLayout, 'gl3d').forEach(function(key) {
var scene = plotDiv._fullLayout[key]._scene;
scene.destroy();
i ++;
@@ -144,7 +146,7 @@ function plotButtons(plots, figDir) {
scrapeButton.style.background = 'blue';
plotlist.appendChild(scrapeButton);
- scrapeButton.addEventListener('click', function () {
+ scrapeButton.addEventListener('click', function() {
Plotly.Snapshot.toSVG(Tabs.get());
return;
});
diff --git a/devtools/test_dashboard/server.js b/devtools/test_dashboard/server.js
index 02d2e95eedc..98d5aeb4c3a 100644
--- a/devtools/test_dashboard/server.js
+++ b/devtools/test_dashboard/server.js
@@ -18,13 +18,13 @@ var testFile;
switch(process.argv[2]) {
case 'cartesian':
testFile = 'test_cartesian';
- break;
+ break;
case 'geo':
testFile = 'test_geo';
- break;
+ break;
case 'gl3d':
testFile = 'test_gl3d';
- break;
+ break;
default:
testFile = 'test_gl2d';
}
diff --git a/devtools/test_dashboard/test_cartesian.js b/devtools/test_dashboard/test_cartesian.js
index 2b3a7a45a47..ec01fc98bb3 100644
--- a/devtools/test_dashboard/test_cartesian.js
+++ b/devtools/test_dashboard/test_cartesian.js
@@ -1,3 +1,5 @@
+/*eslint dot-notation: 0*/
+
var plotButtons = require('./buttons');
var figDir = '../../test/image/baselines/';
diff --git a/devtools/test_dashboard/test_geo.js b/devtools/test_dashboard/test_geo.js
index cf27d98e4e3..a9e3bd7075c 100644
--- a/devtools/test_dashboard/test_geo.js
+++ b/devtools/test_dashboard/test_geo.js
@@ -1,3 +1,5 @@
+/*eslint dot-notation: 0*/
+
var plotButtons = require('./buttons');
var figDir = '../../test/image/baselines/geo_';
diff --git a/devtools/test_dashboard/test_gl2d.js b/devtools/test_dashboard/test_gl2d.js
index c149df842f4..d0e8f8a1501 100644
--- a/devtools/test_dashboard/test_gl2d.js
+++ b/devtools/test_dashboard/test_gl2d.js
@@ -1,3 +1,5 @@
+/*eslint dot-notation: 0*/
+
var plotButtons = require('./buttons');
var figDir = '../../test/image/baselines/gl2d_';
diff --git a/devtools/test_dashboard/test_gl3d.js b/devtools/test_dashboard/test_gl3d.js
index f6e92ca314a..c4d26b11675 100644
--- a/devtools/test_dashboard/test_gl3d.js
+++ b/devtools/test_dashboard/test_gl3d.js
@@ -1,3 +1,5 @@
+/*eslint dot-notation: 0*/
+
var plotButtons = require('./buttons');
var figDir = '../../test/image/baselines/gl3d_';
diff --git a/package.json b/package.json
index 8b3b1cb1043..8c70802d90e 100644
--- a/package.json
+++ b/package.json
@@ -27,7 +27,7 @@
"build": "npm run preprocess && npm run bundle && npm run header",
"cibuild": "node tasks/cibundle.js",
"watch": "node tasks/watch_plotly.js",
- "lint": "cd src && jshint . || true",
+ "lint": "eslint . || true",
"test-jasmine": "karma start test/jasmine/karma.conf.js",
"citest-jasmine": "karma start test/jasmine/karma.ciconf.js",
"test-image": "./tasks/test_image.sh",
@@ -84,7 +84,6 @@
"falafel": "^1.2.0",
"glob": "^6.0.1",
"jasmine-core": "^2.3.4",
- "jshint": "^2.8.0",
"karma": "^0.13.15",
"karma-browserify": "^4.4.1",
"karma-chrome-launcher": "^0.2.1",
diff --git a/src/.eslintrc b/src/.eslintrc
new file mode 100644
index 00000000000..59dd2646b8b
--- /dev/null
+++ b/src/.eslintrc
@@ -0,0 +1,9 @@
+{
+ "extends": "../.eslintrc",
+ "env": {
+ "browser": true
+ },
+ "rules": {
+ "strict": [2, "global"]
+ }
+}
diff --git a/src/assets/geo_assets.js b/src/assets/geo_assets.js
index 87a763cdd9c..49c1fec46fa 100644
--- a/src/assets/geo_assets.js
+++ b/src/assets/geo_assets.js
@@ -6,9 +6,11 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
var saneTopojson = require('sane-topojson');
+
// export the version found in the package.json
exports.version = require('../../package.json').version;
diff --git a/src/components/annotations/arrow_paths.js b/src/components/annotations/arrow_paths.js
index 683d4d12954..47245af49e5 100644
--- a/src/components/annotations/arrow_paths.js
+++ b/src/components/annotations/arrow_paths.js
@@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
/**
* centerx is a center of scaling tuned for maximum scalability of
@@ -17,6 +18,7 @@
* TODO: option to have the pointed-to point a little in front of the
* end of the line, as people tend to want a bit of a gap there...
*/
+
module.exports = [
// no arrow
'',
diff --git a/src/components/annotations/attributes.js b/src/components/annotations/attributes.js
index 320a2fe3123..f99a825187d 100644
--- a/src/components/annotations/attributes.js
+++ b/src/components/annotations/attributes.js
@@ -6,12 +6,14 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
var Plotly = require('../../plotly');
var ARROWPATHS = require('./arrow_paths');
var fontAttrs = require('../../plots/font_attributes');
var extendFlat = require('../../lib/extend').extendFlat;
+
module.exports = {
_isLinkedToArray: true,
diff --git a/src/components/annotations/index.js b/src/components/annotations/index.js
index 8fe782ef5eb..7c6fb5778f9 100644
--- a/src/components/annotations/index.js
+++ b/src/components/annotations/index.js
@@ -533,10 +533,10 @@ annotations.draw = function(gd, index, opt, value) {
// line from the arrowhead to far away and reduce with xor
// to get the parity of the number of intersections.
if(edges.reduce(function(a, x) {
- return a ^
- !!lineIntersect(arrowX, arrowY, arrowX + 1e6, arrowY + 1e6,
- x[0], x[1], x[2], x[3]);
- },false)) {
+ return a ^
+ !!lineIntersect(arrowX, arrowY, arrowX + 1e6, arrowY + 1e6,
+ x[0], x[1], x[2], x[3]);
+ }, false)) {
// no line or arrow - so quit drawArrow now
return;
}
diff --git a/src/components/color/attributes.js b/src/components/color/attributes.js
index 5dd7cc7c1ef..6febca3091c 100644
--- a/src/components/color/attributes.js
+++ b/src/components/color/attributes.js
@@ -6,6 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
+
// IMPORTANT - default colors should be in hex for compatibility
exports.defaults = [
diff --git a/src/components/colorbar/attributes.js b/src/components/colorbar/attributes.js
index fbb91ec4aa8..9ded21dd822 100644
--- a/src/components/colorbar/attributes.js
+++ b/src/components/colorbar/attributes.js
@@ -6,11 +6,13 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
var axesAttrs = require('../../plots/cartesian/layout_attributes');
var fontAttrs = require('../../plots/font_attributes');
var extendFlat = require('../../lib/extend').extendFlat;
+
module.exports = {
// TODO: only right is supported currently
// orient: {
diff --git a/src/components/colorbar/draw.js b/src/components/colorbar/draw.js
index 2c05d6df08e..c354608f8cf 100644
--- a/src/components/colorbar/draw.js
+++ b/src/components/colorbar/draw.js
@@ -317,13 +317,13 @@ module.exports = function draw(gd, id) {
fills.exit().remove();
fills.each(function(d,i) {
var z = [
- (i===0) ? zrange[0] :
- (filllevels[i]+filllevels[i-1])/2,
- (i===filllevels.length-1) ? zrange[1] :
- (filllevels[i]+filllevels[i+1])/2
- ]
- .map(cbAxisOut.c2p)
- .map(Math.round);
+ (i===0) ? zrange[0] :
+ (filllevels[i]+filllevels[i-1])/2,
+ (i===filllevels.length-1) ? zrange[1] :
+ (filllevels[i]+filllevels[i+1])/2
+ ]
+ .map(cbAxisOut.c2p)
+ .map(Math.round);
// offset the side adjoining the next rectangle so they
// overlap, to prevent antialiasing gaps
@@ -500,7 +500,7 @@ module.exports = function draw(gd, id) {
}
// setter/getters for every item defined in opts
- Object.keys(opts).forEach(function (name) {
+ Object.keys(opts).forEach(function(name) {
component[name] = function(v) {
// getter
if(!arguments.length) return opts[name];
diff --git a/src/components/colorscale/attributes.js b/src/components/colorscale/attributes.js
index e931d52952a..9b261728bd0 100644
--- a/src/components/colorscale/attributes.js
+++ b/src/components/colorscale/attributes.js
@@ -6,6 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
+
module.exports = {
zauto: {
diff --git a/src/components/colorscale/default_scale.js b/src/components/colorscale/default_scale.js
index bdea408bb3e..a6d3709dabf 100644
--- a/src/components/colorscale/default_scale.js
+++ b/src/components/colorscale/default_scale.js
@@ -6,6 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
+
var scales = require('./scales');
diff --git a/src/components/colorscale/scales.js b/src/components/colorscale/scales.js
index 038d00e6f39..582b1e3c6e7 100644
--- a/src/components/colorscale/scales.js
+++ b/src/components/colorscale/scales.js
@@ -6,6 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
+
module.exports = {
'Greys':[[0,'rgb(0,0,0)'],[1,'rgb(255,255,255)']],
diff --git a/src/components/errorbars/attributes.js b/src/components/errorbars/attributes.js
index 7579323ca7a..7a3c398f0ad 100644
--- a/src/components/errorbars/attributes.js
+++ b/src/components/errorbars/attributes.js
@@ -6,6 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
+
module.exports = {
visible: {
diff --git a/src/components/errorbars/defaults.js b/src/components/errorbars/defaults.js
index b83ad6872c5..9aba2acafa6 100644
--- a/src/components/errorbars/defaults.js
+++ b/src/components/errorbars/defaults.js
@@ -21,7 +21,7 @@ module.exports = function(traceIn, traceOut, defaultColor, opts) {
containerOut = traceOut[objName] = {},
containerIn = traceIn[objName] || {};
- function coerce (attr, dflt) {
+ function coerce(attr, dflt) {
return Lib.coerce(containerIn, containerOut, attributes, attr, dflt);
}
diff --git a/src/components/errorbars/index.js b/src/components/errorbars/index.js
index 785d07b7fe1..4d1566701a1 100644
--- a/src/components/errorbars/index.js
+++ b/src/components/errorbars/index.js
@@ -134,9 +134,9 @@ errorBars.style = function(gd){
function errorcoords(d, xa, ya) {
// compute the coordinates of the error-bar objects
var out = {
- x: xa.c2p(d.x),
- y: ya.c2p(d.y)
- };
+ x: xa.c2p(d.x),
+ y: ya.c2p(d.y)
+ };
// calculate the error bar size and hat and shoe locations
if(d.yh!==undefined) {
diff --git a/src/components/legend/attributes.js b/src/components/legend/attributes.js
index 3dbb4a24b8b..99ac85bdf33 100644
--- a/src/components/legend/attributes.js
+++ b/src/components/legend/attributes.js
@@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
var fontAttrs = require('../../plots/font_attributes');
var colorAttrs = require('../color/attributes');
diff --git a/src/components/legend/index.js b/src/components/legend/index.js
index d72f0c12bd6..aad718ce53d 100644
--- a/src/components/legend/index.js
+++ b/src/components/legend/index.js
@@ -282,13 +282,13 @@ legend.texts = function(context, td, d, i, traces){
.data([0]);
text.enter().append('text').classed('legendtext', true);
text.attr({
- x: 40,
- y: 0
- })
- .style('text-anchor', 'start')
- .call(Plotly.Drawing.font, fullLayout.legend.font)
- .text(name)
- .attr({'data-unformatted': name});
+ x: 40,
+ y: 0
+ })
+ .style('text-anchor', 'start')
+ .call(Plotly.Drawing.font, fullLayout.legend.font)
+ .text(name)
+ .attr({'data-unformatted': name});
function textLayout(s){
Plotly.util.convertToTspans(s, function(){
@@ -512,7 +512,7 @@ legend.draw = function(td) {
}
}
- newVisible = trace.visible === true ? 'legendonly' : true;
+ newVisible = trace.visible === true ? 'legendonly' : true;
Plotly.restyle(td, 'visible', newVisible, traceIndicesInGroup);
}
});
diff --git a/src/components/modebar/buttons.js b/src/components/modebar/buttons.js
index 37dd222627c..f5b9dee720e 100644
--- a/src/components/modebar/buttons.js
+++ b/src/components/modebar/buttons.js
@@ -83,7 +83,7 @@ modeBarButtons.toImage = {
ev.clean();
});
- ev.once('error', function (err) {
+ ev.once('error', function(err) {
gd._snapshotInProgress = false;
Lib.notifier('Sorry there was a problem downloading your ' + format, 'long');
@@ -250,7 +250,7 @@ function handleCartesian(gd, ev) {
aobj[astr] = val;
}
- Plotly.relayout(gd, aobj).then( function() {
+ Plotly.relayout(gd, aobj).then(function() {
if(astr === 'dragmode') {
if(fullLayout._hasCartesian) {
Plotly.Fx.setCursor(
@@ -337,7 +337,7 @@ function handleCamera3d(gd, ev) {
fullLayout = gd._fullLayout,
sceneIds = Plotly.Plots.getSubplotIds(fullLayout, 'gl3d');
- for(var i = 0; i < sceneIds.length; i++) {
+ for(var i = 0; i < sceneIds.length; i++) {
var sceneId = sceneIds[i],
sceneLayout = layout[sceneId],
fullSceneLayout = fullLayout[sceneId],
@@ -387,7 +387,7 @@ modeBarButtons.hoverClosest3d = {
else {
layoutUpdate = {'allaxes.showspikes': false};
- for(var i = 0; i < sceneIds.length; i++) {
+ for(var i = 0; i < sceneIds.length; i++) {
var sceneId = sceneIds[i],
sceneLayout = fullLayout[sceneId],
sceneSpikes = currentSpikes[sceneId] = {};
@@ -456,7 +456,7 @@ function handleGeo(gd, ev) {
fullLayout = gd._fullLayout,
geoIds = Plotly.Plots.getSubplotIds(fullLayout, 'geo');
- for(var i = 0; i < geoIds.length; i++) {
+ for(var i = 0; i < geoIds.length; i++) {
var geo = fullLayout[geoIds[i]]._geo;
if(attr === 'zoom') {
@@ -493,7 +493,7 @@ modeBarButtons.hoverClosestPie = {
};
function toggleHover(gd) {
- var newHover = gd._fullLayout.hovermode ? false : 'closest';
+ var newHover = gd._fullLayout.hovermode ? false : 'closest';
Plotly.relayout(gd, 'hovermode', newHover);
}
diff --git a/src/components/modebar/index.js b/src/components/modebar/index.js
index 3fe7a8a29f2..3a536829c40 100644
--- a/src/components/modebar/index.js
+++ b/src/components/modebar/index.js
@@ -102,7 +102,7 @@ proto.updateButtons = function(buttons) {
* Empty div for containing a group of buttons
* @Return {HTMLelement}
*/
-proto.createGroup = function () {
+proto.createGroup = function() {
var group = document.createElement('div');
group.className = 'modebar-group';
@@ -114,7 +114,7 @@ proto.createGroup = function () {
* @Param {object} config (see ./buttons.js for more info)
* @Return {HTMLelement}
*/
-proto.createButton = function (config) {
+proto.createButton = function(config) {
var _this = this,
button = document.createElement('a');
@@ -162,7 +162,7 @@ proto.createButton = function (config) {
* @Param {string} thisIcon.path
* @Return {HTMLelement}
*/
-proto.createIcon = function (thisIcon) {
+proto.createIcon = function(thisIcon) {
var iconHeight = thisIcon.ascent - thisIcon.descent,
svgNS = 'http://www.w3.org/2000/svg',
icon = document.createElementNS(svgNS, 'svg'),
@@ -216,7 +216,7 @@ proto.updateActiveButton = function(buttonClicked) {
* @Param {object} buttons 2d array of grouped button config objects
* @Return {boolean}
*/
-proto.hasButtons = function (buttons) {
+proto.hasButtons = function(buttons) {
var currentButtons = this.buttons;
if(!currentButtons) return false;
diff --git a/src/components/modebar/manage.js b/src/components/modebar/manage.js
index 2fa91f4a19f..0eacce6497a 100644
--- a/src/components/modebar/manage.js
+++ b/src/components/modebar/manage.js
@@ -186,7 +186,7 @@ function fillCustomButton(customButtons) {
for(var j = 0; j < buttonGroup.length; j++) {
var button = buttonGroup[j];
- if(typeof button === 'string')
+ if(typeof button === 'string') {
if(modeBarButtons[button] !== undefined) {
customButtons[i][j] = modeBarButtons[button];
}
@@ -198,6 +198,7 @@ function fillCustomButton(customButtons) {
}
}
}
+ }
return customButtons;
}
diff --git a/src/components/shapes/attributes.js b/src/components/shapes/attributes.js
index 3bf7f853f1d..1958f8d8efc 100644
--- a/src/components/shapes/attributes.js
+++ b/src/components/shapes/attributes.js
@@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
var annAttrs = require('../annotations/attributes');
var scatterAttrs = require('../../traces/scatter/attributes');
diff --git a/src/components/shapes/index.js b/src/components/shapes/index.js
index 846eba13297..a965764b9cf 100644
--- a/src/components/shapes/index.js
+++ b/src/components/shapes/index.js
@@ -406,7 +406,7 @@ shapes.convertPath = function(pathIn, x2p, y2p) {
if(paramNumber > nParams) {
paramString = paramString.replace(/[\s,]*X.*/, '');
- console.log('ignoring extra params in segment ' + segment);
+ console.log('ignoring extra params in segment ' + segment);
}
return segmentType + paramString;
diff --git a/src/components/titles/index.js b/src/components/titles/index.js
index 3d4a3c24fce..d10133d941c 100644
--- a/src/components/titles/index.js
+++ b/src/components/titles/index.js
@@ -56,8 +56,7 @@ Titles.draw = function(gd, title) {
fontColor = cont.titlefont.color,
x,
y,
- transform='',
- attr = {},
+ transform = '',
xa,
ya,
avoid = {
@@ -120,7 +119,6 @@ Titles.draw = function(gd, title) {
xa._length + 10 +
fontSize*(offsetBase + (ya.showticklabels ? 1 : 0.5)) :
-10 - fontSize*(offsetBase + (ya.showticklabels ? 0.5 : 0)));
- attr = {center: 0};
options = {x: x, y: y, 'text-anchor': 'middle'};
transform = {rotate: '-90', offset: 0};
if(!avoid.side) { avoid.side = 'left'; }
@@ -183,16 +181,18 @@ Titles.draw = function(gd, title) {
'rotate(' + [transform.rotate, options.x, options.y] +
') translate(0, '+transform.offset+')' :
null);
+
titleEl.style({
- 'font-family': font,
- 'font-size': d3.round(fontSize,2)+'px',
- fill: Plotly.Color.rgb(fontColor),
- opacity: opacity*Plotly.Color.opacity(fontColor),
- 'font-weight': plots.fontWeight
- })
- .attr(options)
- .call(Plotly.util.convertToTspans)
- .attr(options);
+ 'font-family': font,
+ 'font-size': d3.round(fontSize,2)+'px',
+ fill: Plotly.Color.rgb(fontColor),
+ opacity: opacity*Plotly.Color.opacity(fontColor),
+ 'font-weight': plots.fontWeight
+ })
+ .attr(options)
+ .call(Plotly.util.convertToTspans)
+ .attr(options);
+
titleEl.selectAll('tspan.line')
.attr(options);
return plots.previousPromises(gd);
diff --git a/src/fonts/mathjax_config.js b/src/fonts/mathjax_config.js
index 7f3b8262bf7..faddf138787 100644
--- a/src/fonts/mathjax_config.js
+++ b/src/fonts/mathjax_config.js
@@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
/* global MathJax:false */
diff --git a/src/index.js b/src/index.js
index 4efad78b16f..922f578152b 100644
--- a/src/index.js
+++ b/src/index.js
@@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
/*
* Export the plotly.js API methods.
diff --git a/src/lib/dates.js b/src/lib/dates.js
index 44166501e38..5a5ef676cef 100644
--- a/src/lib/dates.js
+++ b/src/lib/dates.js
@@ -229,8 +229,9 @@ var dateTimeFormats = {
dateTimeFormats[dateType].D.push(formatter(dateFormat));
['H', 'I', 'D'].forEach(function(timeType) {
timeFormats[timeType].forEach(function(timeFormat) {
- var a = dateTimeFormats[dateType][timeType];
- // 'date time', then 'time date'
+ var a = dateTimeFormats[dateType][timeType];
+
+ // 'date time', then 'time date'
a.push(formatter(dateFormat+'~'+timeFormat));
a.push(formatter(timeFormat+'~'+dateFormat));
});
diff --git a/src/lib/events.js b/src/lib/events.js
index c5fdaeccd42..bdbe0268cb6 100644
--- a/src/lib/events.js
+++ b/src/lib/events.js
@@ -21,7 +21,7 @@ var Events = {
* If we have already instantiated an emitter for this plot
* return early.
*/
- if (plotObj._ev instanceof EventEmitter) return plotObj;
+ if (plotObj._ev instanceof EventEmitter) return plotObj;
var ev = new EventEmitter();
diff --git a/src/lib/html2unicode.js b/src/lib/html2unicode.js
index c0771d9b9a6..d0cfc574c2c 100644
--- a/src/lib/html2unicode.js
+++ b/src/lib/html2unicode.js
@@ -12,57 +12,61 @@
var toSuperScript = require('superscript-text');
var ENTITIES = {
- 'mu': 'μ',
- 'amp': '&',
- 'lt': '<',
- 'gt': '>'
+ 'mu': 'μ',
+ 'amp': '&',
+ 'lt': '<',
+ 'gt': '>'
};
function fixSuperScript(x) {
- var idx = 0;
- while((idx = x.indexOf('', idx)) >= 0) {
- var nidx = x.indexOf('', idx);
- if(nidx < idx) {
- break;
+ var idx = 0;
+
+ while((idx = x.indexOf('', idx)) >= 0) {
+ var nidx = x.indexOf('', idx);
+ if(nidx < idx) break;
+
+ x = x.slice(0, idx) + toSuperScript(x.slice(idx+5, nidx)) + x.slice(nidx+6);
}
- x = x.slice(0, idx) + toSuperScript(x.slice(idx+5, nidx)) + x.slice(nidx+6);
- }
- return x;
+
+ return x;
}
function fixBR(x) {
- return x.replace(/\
/g, '\n');
+ return x.replace(/\
/g, '\n');
}
function stripTags(x) {
- return x.replace(/\<.*\>/g, '');
+ return x.replace(/\<.*\>/g, '');
}
function fixEntities(x) {
- var idx = 0;
- while((idx = x.indexOf('&', idx)) >= 0) {
- var nidx = x.indexOf(';', idx);
- if(nidx < idx) {
- idx += 1;
- continue;
- }
- var entity = ENTITIES[x.slice(idx+1, nidx)];
- if(entity) {
- x = x.slice(0, idx) + entity + x.slice(nidx+1);
- } else {
- x = x.slice(0, idx) + x.slice(nidx+1);
+ var idx = 0;
+
+ while((idx = x.indexOf('&', idx)) >= 0) {
+ var nidx = x.indexOf(';', idx);
+ if(nidx < idx) {
+ idx += 1;
+ continue;
+ }
+
+ var entity = ENTITIES[x.slice(idx+1, nidx)];
+ if(entity) {
+ x = x.slice(0, idx) + entity + x.slice(nidx+1);
+ } else {
+ x = x.slice(0, idx) + x.slice(nidx+1);
+ }
}
- }
- return x;
+
+ return x;
}
function convertHTMLToUnicode(html) {
- return '' +
- fixEntities(
- stripTags(
- fixSuperScript(
- fixBR(
- html))));
+ return '' +
+ fixEntities(
+ stripTags(
+ fixSuperScript(
+ fixBR(
+ html))));
}
module.exports = convertHTMLToUnicode;
diff --git a/src/lib/index.js b/src/lib/index.js
index bb88740f579..12b78cb4c2c 100644
--- a/src/lib/index.js
+++ b/src/lib/index.js
@@ -176,8 +176,8 @@ lib.randstr = function randstr(existing, bits, base) {
}
var parsed = parseInt(res, base);
- if ( (existing && (existing.indexOf(res) > -1)) ||
- (parsed !== Infinity && parsed >= Math.pow(2, bits)) ) {
+ if ((existing && (existing.indexOf(res) > -1)) ||
+ (parsed !== Infinity && parsed >= Math.pow(2, bits))) {
return randstr(existing, bits, base);
}
else return res;
@@ -303,7 +303,7 @@ lib.syncOrAsync = function(sequence, arg, finalStep) {
* Helper to strip trailing slash, from
* http://stackoverflow.com/questions/6680825/return-string-without-trailing-slash
*/
-lib.stripTrailingSlash = function (str) {
+lib.stripTrailingSlash = function(str) {
if (str.substr(-1) === '/') return str.substr(0, str.length - 1);
return str;
};
diff --git a/src/lib/matrix.js b/src/lib/matrix.js
index 1fee422ed3f..23c7e488375 100644
--- a/src/lib/matrix.js
+++ b/src/lib/matrix.js
@@ -67,12 +67,12 @@ exports.dot = function(x, y) {
};
// translate by (x,y)
-exports.translationMatrix = function (x, y) {
+exports.translationMatrix = function(x, y) {
return [[1, 0, x], [0, 1, y], [0, 0, 1]];
};
// rotate by alpha around (0,0)
-exports.rotationMatrix = function (alpha) {
+exports.rotationMatrix = function(alpha) {
var a = alpha*Math.PI/180;
return [[Math.cos(a), -Math.sin(a), 0],
[Math.sin(a), Math.cos(a), 0],
diff --git a/src/lib/nested_property.js b/src/lib/nested_property.js
index 02fd0be3fde..71aa00c5a4e 100644
--- a/src/lib/nested_property.js
+++ b/src/lib/nested_property.js
@@ -129,7 +129,7 @@ function npSet(cont, parts) {
return function(val) {
var curCont = cont,
containerLevels = [cont],
- toDelete = emptyObj(val) && !isDataArray(val, parts[parts.length-1]),
+ toDelete = emptyObj(val) && !isDataArray(val, parts[parts.length-1]),
curPart,
i;
@@ -224,7 +224,7 @@ function pruneContainers(containerLevels) {
else remainingKeys = true;
}
}
- else if(typeof curCont === 'object' && curCont !== null) {
+ else if(typeof curCont === 'object' && curCont !== null) {
keys = Object.keys(curCont);
remainingKeys = false;
for(j = keys.length - 1; j >= 0; j--) {
diff --git a/src/lib/queue.js b/src/lib/queue.js
index 83813942b17..049911b0eed 100644
--- a/src/lib/queue.js
+++ b/src/lib/queue.js
@@ -18,7 +18,7 @@ var Plotly = require('../plotly');
* @param args
* @returns {Array}
*/
-function copyArgArray (gd, args) {
+function copyArgArray(gd, args) {
var copy = [];
var arg;
@@ -188,7 +188,7 @@ queue.redo = function redo(gd) {
* @param func
* @param args
*/
-queue.plotDo = function (gd, func, args) {
+queue.plotDo = function(gd, func, args) {
gd.autoplay = true;
// this *won't* copy gd and it preserves `undefined` properties!
diff --git a/src/lib/show_no_webgl_msg.js b/src/lib/show_no_webgl_msg.js
index b30d107a4dd..9230a9952b3 100644
--- a/src/lib/show_no_webgl_msg.js
+++ b/src/lib/show_no_webgl_msg.js
@@ -11,6 +11,9 @@
var Plotly = require('../plotly');
+var noop = function() {};
+
+
/**
* Prints a no webgl error message into the scene container
* @param {scene instance} scene
@@ -19,13 +22,11 @@ var Plotly = require('../plotly');
*
*/
module.exports = function showWebGlMsg(scene) {
- var noop = function () {};
-
for(var prop in scene) {
if (typeof scene[prop] === 'function') scene[prop] = noop;
}
- scene.destroy = function () {
+ scene.destroy = function() {
scene.container.parentNode.removeChild(scene.container);
};
@@ -37,7 +38,7 @@ module.exports = function showWebGlMsg(scene) {
scene.container.appendChild(div);
scene.container.style.background = '#FFFFFF';
- scene.container.onclick = function () {
+ scene.container.onclick = function() {
window.open('http://get.webgl.org');
};
diff --git a/src/lib/svg_text_utils.js b/src/lib/svg_text_utils.js
index 1ba84674cdc..ae5c151bc99 100644
--- a/src/lib/svg_text_utils.js
+++ b/src/lib/svg_text_utils.js
@@ -131,11 +131,12 @@ util.convertToTspans = function(_context, _callback){
}
newSvg.attr({
- 'class': svgClass,
- height: _svgBBox.height,
- preserveAspectRatio: 'xMinYMin meet'
- })
- .style({overflow: 'visible', 'pointer-events': 'none'});
+ 'class': svgClass,
+ height: _svgBBox.height,
+ preserveAspectRatio: 'xMinYMin meet'
+ })
+ .style({overflow: 'visible', 'pointer-events': 'none'});
+
var fill = that.style('fill') || 'black';
newSvg.select('g').attr({fill: fill, stroke: fill});
diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js
index aa7b2115cec..5c111503ebc 100644
--- a/src/plot_api/plot_api.js
+++ b/src/plot_api/plot_api.js
@@ -38,6 +38,7 @@ var plots = Plotly.Plots;
Plotly.plot = function(gd, data, layout, config) {
Plotly.Lib.markTime('in plot');
+
gd = getGraphDiv(gd);
/*
@@ -651,8 +652,8 @@ function cleanLayout(layout) {
cameraposition = scene.cameraposition;
if (Array.isArray(cameraposition) && cameraposition[0].length === 4) {
rotation = cameraposition[0];
- center = cameraposition[1];
- radius = cameraposition[2];
+ center = cameraposition[1];
+ radius = cameraposition[2];
mat = m4FromQuat([], rotation);
eye = [];
for (j = 0; j < 3; ++j) {
@@ -693,8 +694,8 @@ function cleanData(data, existingData) {
*/
var suids = [], // seen uids --- so we can weed out incoming repeats
uids = data.concat(Array.isArray(existingData) ? existingData : [])
- .filter( function(trace) { return 'uid' in trace; } )
- .map( function(trace) { return trace.uid; });
+ .filter(function(trace) { return 'uid' in trace; })
+ .map(function(trace) { return trace.uid; });
for(var tracei = 0; tracei < data.length; tracei++) {
var trace = data[tracei];
@@ -823,7 +824,7 @@ Plotly.redraw = function(gd) {
}
gd.calcdata = undefined;
- return Plotly.plot(gd).then(function () {
+ return Plotly.plot(gd).then(function() {
gd.emit('plotly_redraw');
return gd;
});
@@ -837,7 +838,7 @@ Plotly.redraw = function(gd) {
* @param {Object} layout
* @param {Object} config
*/
-Plotly.newPlot = function (gd, data, layout, config) {
+Plotly.newPlot = function(gd, data, layout, config) {
gd = getGraphDiv(gd);
plots.purge(gd);
return Plotly.plot(gd, data, layout, config);
@@ -1079,10 +1080,10 @@ function assertExtendTracesArgs(gd, update, indices, maxPoints) {
*/
if (maxPointsIsObject &&
(!(key in maxPoints) || !Array.isArray(maxPoints[key]) ||
- maxPoints[key].length !== update[key].length )) {
- throw new Error('when maxPoints is set as a key:value object it must contain a 1:1 ' +
- 'corrispondence with the keys and number of traces in the update object');
- }
+ maxPoints[key].length !== update[key].length)) {
+ throw new Error('when maxPoints is set as a key:value object it must contain a 1:1 ' +
+ 'corrispondence with the keys and number of traces in the update object');
+ }
}
}
@@ -1095,7 +1096,7 @@ function assertExtendTracesArgs(gd, update, indices, maxPoints) {
* @param {Number||Object} maxPoints
* @return {Object[]}
*/
-function getExtendProperties (gd, update, indices, maxPoints) {
+function getExtendProperties(gd, update, indices, maxPoints) {
var maxPointsIsObject = Plotly.Lib.isPlainObject(maxPoints),
updateProps = [];
@@ -1171,7 +1172,7 @@ function getExtendProperties (gd, update, indices, maxPoints) {
* @param {Function} spliceArray
* @return {Object}
*/
-function spliceTraces (gd, update, indices, maxPoints, lengthenArray, spliceArray) {
+function spliceTraces(gd, update, indices, maxPoints, lengthenArray, spliceArray) {
assertExtendTracesArgs(gd, update, indices, maxPoints);
@@ -1242,7 +1243,7 @@ function spliceTraces (gd, update, indices, maxPoints, lengthenArray, spliceArra
* @param {Number|Object} [maxPoints] Number of points for trace window after lengthening.
*
*/
-Plotly.extendTraces = function extendTraces (gd, update, indices, maxPoints) {
+Plotly.extendTraces = function extendTraces(gd, update, indices, maxPoints) {
gd = getGraphDiv(gd);
var undo = spliceTraces(gd, update, indices, maxPoints,
@@ -1271,7 +1272,7 @@ Plotly.extendTraces = function extendTraces (gd, update, indices, maxPoints) {
return promise;
};
-Plotly.prependTraces = function prependTraces (gd, update, indices, maxPoints) {
+Plotly.prependTraces = function prependTraces(gd, update, indices, maxPoints) {
gd = getGraphDiv(gd);
var undo = spliceTraces(gd, update, indices, maxPoints,
@@ -1309,7 +1310,7 @@ Plotly.prependTraces = function prependTraces (gd, update, indices, maxPoints)
* @param {Number[]|Number} [newIndices=[gd.data.length]] Locations to add traces
*
*/
-Plotly.addTraces = function addTraces (gd, traces, newIndices) {
+Plotly.addTraces = function addTraces(gd, traces, newIndices) {
gd = getGraphDiv(gd);
var currentIndices = [],
@@ -1317,7 +1318,8 @@ Plotly.addTraces = function addTraces (gd, traces, newIndices) {
redoFunc = addTraces,
undoArgs = [gd, currentIndices],
redoArgs = [gd, traces], // no newIndices here
- i;
+ i,
+ promise;
// all validation is done elsewhere to remove clutter here
checkAddTracesArgs(gd, traces, newIndices);
@@ -1341,7 +1343,7 @@ Plotly.addTraces = function addTraces (gd, traces, newIndices) {
// if the user didn't define newIndices, they just want the traces appended
// i.e., we can simply redraw and be done
if (typeof newIndices === 'undefined') {
- var promise = Plotly.redraw(gd);
+ promise = Plotly.redraw(gd);
if (Plotly.Queue) Plotly.Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
return promise;
}
@@ -1367,7 +1369,8 @@ Plotly.addTraces = function addTraces (gd, traces, newIndices) {
// this requires some extra work that moveTraces will do
if (Plotly.Queue) Plotly.Queue.startSequence(gd);
if (Plotly.Queue) Plotly.Queue.add(gd, undoFunc, undoArgs, redoFunc, redoArgs);
- var promise = Plotly.moveTraces(gd, currentIndices, newIndices);
+
+ promise = Plotly.moveTraces(gd, currentIndices, newIndices);
if (Plotly.Queue) Plotly.Queue.stopSequence(gd);
return promise;
};
@@ -1379,7 +1382,7 @@ Plotly.addTraces = function addTraces (gd, traces, newIndices) {
* @param {Object[]} gd.data The array of traces we're removing from
* @param {Number|Number[]} indices The indices
*/
-Plotly.deleteTraces = function deleteTraces (gd, indices) {
+Plotly.deleteTraces = function deleteTraces(gd, indices) {
gd = getGraphDiv(gd);
var traces = [],
@@ -1446,7 +1449,7 @@ Plotly.deleteTraces = function deleteTraces (gd, indices) {
* // reorder all traces (assume there are 5--a, b, c, d, e)
* Plotly.moveTraces(gd, [b, d, e, a, c]) // same as 'move to end'
*/
-Plotly.moveTraces = function moveTraces (gd, currentIndices, newIndices) {
+Plotly.moveTraces = function moveTraces(gd, currentIndices, newIndices) {
gd = getGraphDiv(gd);
var newData = [],
@@ -1496,7 +1499,7 @@ Plotly.moveTraces = function moveTraces (gd, currentIndices, newIndices) {
}
// reorder this mapping by newIndex, ascending
- movingTraceMap.sort(function (a, b) {
+ movingTraceMap.sort(function(a, b) {
return a.newIndex - b.newIndex;
});
@@ -2001,7 +2004,7 @@ Plotly.restyle = function restyle(gd, astr, val, traces) {
var trace = cd[0].trace,
cb = cd[0].t.cb;
if(plots.traceIs(trace, 'contour')) {
- cb.line({
+ cb.line({
width: trace.contours.showlines!==false ?
trace.line.width : 0,
dash: trace.line.dash,
@@ -2084,7 +2087,7 @@ Plotly.relayout = function relayout(gd, astr, val) {
doplot = false,
docalc = false,
domodebar = false,
- newkey, axes, keys, xyref, scene, axisAttr;
+ newkey, axes, keys, xyref, scene, axisAttr, i;
if(typeof astr === 'string') aobj[astr] = val;
else if(Plotly.Lib.isPlainObject(astr)) aobj = astr;
@@ -2098,7 +2101,7 @@ Plotly.relayout = function relayout(gd, astr, val) {
keys = Object.keys(aobj);
axes = Plotly.Axes.list(gd);
- for(var i=0; i0) plotScatterGeo.plot(this, scattergeoData);
@@ -334,7 +332,7 @@ proto.drawLayout = function(geoLayout) {
// N.B. html('') does not work in IE11
gBaseLayer.selectAll('*').remove();
- for(var i = 0; i < baseLayers.length; i++) {
+ for(var i = 0; i < baseLayers.length; i++) {
layerName = baseLayers[i];
if(axesNames.indexOf(layerName)!==-1) {
diff --git a/src/plots/geo/index.js b/src/plots/geo/index.js
index 0769e53dafa..21200af2c0b 100644
--- a/src/plots/geo/index.js
+++ b/src/plots/geo/index.js
@@ -49,10 +49,10 @@ exports.plot = function plotGeo(gd) {
// If geo is not instantiated, create one!
if(geo === undefined) {
geo = new Geo({
- id: geoId,
- container: fullLayout._geocontainer.node(),
- topojsonURL: gd._context.topojsonURL
- },
+ id: geoId,
+ container: fullLayout._geocontainer.node(),
+ topojsonURL: gd._context.topojsonURL
+ },
fullLayout
);
diff --git a/src/plots/geo/layout/attributes.js b/src/plots/geo/layout/attributes.js
index d1823040c75..e6f6823d5e2 100644
--- a/src/plots/geo/layout/attributes.js
+++ b/src/plots/geo/layout/attributes.js
@@ -6,6 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
+
module.exports = {
geo: {
diff --git a/src/plots/geo/layout/axis_attributes.js b/src/plots/geo/layout/axis_attributes.js
index a712fe8ba44..23a69bf812e 100644
--- a/src/plots/geo/layout/axis_attributes.js
+++ b/src/plots/geo/layout/axis_attributes.js
@@ -6,9 +6,11 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
var colorAttrs = require('../../../components/color/attributes');
+
module.exports = {
range: {
valType: 'info_array',
diff --git a/src/plots/geo/layout/axis_defaults.js b/src/plots/geo/layout/axis_defaults.js
index 066bc98fc14..429a801393e 100644
--- a/src/plots/geo/layout/axis_defaults.js
+++ b/src/plots/geo/layout/axis_defaults.js
@@ -17,6 +17,8 @@ var axisAttributes = require('./axis_attributes');
module.exports = function supplyGeoAxisLayoutDefaults(geoLayoutIn, geoLayoutOut) {
var axesNames = constants.axesNames;
+ var axisIn, axisOut;
+
function coerce(attr, dflt) {
return Plotly.Lib.coerce(axisIn, axisOut, axisAttributes, attr, dflt);
}
@@ -46,8 +48,8 @@ module.exports = function supplyGeoAxisLayoutDefaults(geoLayoutIn, geoLayoutOut)
for(var i = 0; i < axesNames.length; i++) {
var axisName = axesNames[i];
- var axisIn = geoLayoutIn[axisName] || {};
- var axisOut = {};
+ axisIn = geoLayoutIn[axisName] || {};
+ axisOut = {};
var rangeDflt = getRangeDflt(axisName);
diff --git a/src/plots/geo/layout/defaults.js b/src/plots/geo/layout/defaults.js
index 64a68ccf795..a6c3cccf278 100644
--- a/src/plots/geo/layout/defaults.js
+++ b/src/plots/geo/layout/defaults.js
@@ -18,15 +18,17 @@ var supplyGeoAxisLayoutDefaults = require('./axis_defaults');
module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
var geos = Plotly.Plots.getSubplotIdsInData(fullData, 'geo'),
geosLength = geos.length;
-
+
+ var geoLayoutIn, geoLayoutOut;
+
function coerce(attr, dflt) {
return Plotly.Lib.coerce(geoLayoutIn, geoLayoutOut, layoutAttributes, attr, dflt);
}
for(var i = 0; i < geosLength; i++) {
var geo = geos[i];
- var geoLayoutIn = layoutIn[geo] || {};
- var geoLayoutOut = {};
+ geoLayoutIn = layoutIn[geo] || {};
+ geoLayoutOut = {};
coerce('domain.x');
coerce('domain.y', [i / geosLength, (i + 1) / geosLength]);
diff --git a/src/plots/geo/layout/layout_attributes.js b/src/plots/geo/layout/layout_attributes.js
index 237f2e7fe7d..4344d35a0c1 100644
--- a/src/plots/geo/layout/layout_attributes.js
+++ b/src/plots/geo/layout/layout_attributes.js
@@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
var colorAttrs = require('../../../components/color/attributes');
var constants = require('../../../constants/geo_constants');
diff --git a/src/plots/geo/projections.js b/src/plots/geo/projections.js
index 732718cef09..2c309ac7e13 100644
--- a/src/plots/geo/projections.js
+++ b/src/plots/geo/projections.js
@@ -6,9 +6,6 @@
* LICENSE file in the root directory of this source tree.
*/
-
-// jshint ignore: start
-
/**
* Forked from https://github.com/d3/d3-geo-projection
* Pasted from https://github.com/etpinard/d3-geo-projection
diff --git a/src/plots/geo/set_scale.js b/src/plots/geo/set_scale.js
index 8c58dec523b..f80f93993d2 100644
--- a/src/plots/geo/set_scale.js
+++ b/src/plots/geo/set_scale.js
@@ -33,7 +33,7 @@ function createGeoScale(geoLayout, graphSize) {
lonfull1 = lonaxisLayout._fullRange[1] - clipPad,
latfull0 = lataxisLayout._fullRange[0] + clipPad,
latfull1 = lataxisLayout._fullRange[1] - clipPad;
-
+
// initial translation (makes the math easier)
projLayout._translate0 = [
graphSize.l + geoWidth / 2, graphSize.t + geoHeight / 2
@@ -48,7 +48,7 @@ function createGeoScale(geoLayout, graphSize) {
r = projLayout._rotate;
projLayout._center = [c0[0] + r[0], c0[1] + r[1]];
-
+
// needs a initial projection; it is called from makeProjection
var setScale = function(projection) {
var scale0 = projection.scale(),
@@ -56,7 +56,7 @@ function createGeoScale(geoLayout, graphSize) {
rangeBox = makeRangeBox(lon0, lat0, lon1, lat1),
fullRangeBox = makeRangeBox(lonfull0, latfull0, lonfull1, latfull1);
- var scale, translate, bounds, fullBounds;
+ var scale, translate, bounds, fullBounds;
// Inspired by: http://stackoverflow.com/a/14654988/4068492
// using the path determine the bounds of the current map and use
@@ -109,7 +109,7 @@ function createGeoScale(geoLayout, graphSize) {
geoLayout._marginX = (geoWidth - Math.round(bounds[1][0])) / 2;
geoLayout._marginY = (geoHeight - Math.round(bounds[1][1])) / 2;
};
-
+
return setScale;
}
diff --git a/src/plots/geo/zoom.js b/src/plots/geo/zoom.js
index 6ee67becfe3..cb22a05cbc2 100644
--- a/src/plots/geo/zoom.js
+++ b/src/plots/geo/zoom.js
@@ -67,7 +67,7 @@ function zoomScoped(geo, projLayout) {
.on('zoom', handleZoom)
.on('zoomend', handleZoomend);
- return zoom;
+ return zoom;
}
// zoom for non-clipped projections
@@ -76,7 +76,7 @@ function zoomNonClipped(geo, projLayout) {
zoom = initZoom(projection, projLayout);
var INSIDETOLORANCEPXS = 2;
-
+
var mouse0, rotate0, translate0, lastRotate, zoomPoint,
mouse1, rotate1, point1;
@@ -138,7 +138,7 @@ function zoomNonClipped(geo, projLayout) {
.on('zoom', handleZoom)
.on('zoomend', handleZoomend);
- return zoom;
+ return zoom;
}
// zoom for clipped projections
@@ -241,11 +241,11 @@ function position(projection, point) {
function quaternionFromEuler(euler) {
var lambda = 0.5 * euler[0] * radians,
- phi = 0.5 * euler[1] * radians,
- gamma = 0.5 * euler[2] * radians,
- sinLambda = Math.sin(lambda), cosLambda = Math.cos(lambda),
- sinPhi = Math.sin(phi), cosPhi = Math.cos(phi),
- sinGamma = Math.sin(gamma), cosGamma = Math.cos(gamma);
+ phi = 0.5 * euler[1] * radians,
+ gamma = 0.5 * euler[2] * radians,
+ sinLambda = Math.sin(lambda), cosLambda = Math.cos(lambda),
+ sinPhi = Math.sin(phi), cosPhi = Math.cos(phi),
+ sinGamma = Math.sin(gamma), cosGamma = Math.cos(gamma);
return [
cosLambda * cosPhi * cosGamma + sinLambda * sinPhi * sinGamma,
sinLambda * cosPhi * cosGamma - cosLambda * sinPhi * sinGamma,
@@ -256,7 +256,7 @@ function quaternionFromEuler(euler) {
function multiply(a, b) {
var a0 = a[0], a1 = a[1], a2 = a[2], a3 = a[3],
- b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
+ b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3];
return [
a0 * b0 - a1 * b1 - a2 * b2 - a3 * b3,
a0 * b1 + a1 * b0 + a2 * b3 - a3 * b2,
@@ -268,9 +268,9 @@ function multiply(a, b) {
function rotateBetween(a, b) {
if (!a || !b) return;
var axis = cross(a, b),
- norm = Math.sqrt(dot(axis, axis)),
- halfgamma = 0.5 * Math.acos(Math.max(-1, Math.min(1, dot(a, b)))),
- k = Math.sin(halfgamma) / norm;
+ norm = Math.sqrt(dot(axis, axis)),
+ halfgamma = 0.5 * Math.acos(Math.max(-1, Math.min(1, dot(a, b)))),
+ k = Math.sin(halfgamma) / norm;
return norm && [Math.cos(halfgamma), axis[2] * k, -axis[1] * k, axis[0] * k];
}
@@ -291,19 +291,19 @@ function unRoll(rotateAngles, pt, lastRotate) {
ptRotated = rotateCartesian(ptRotated, 0, rotateAngles[2] - lastRotate[2]);
var x = pt[0],
- y = pt[1],
- z = pt[2],
- f = ptRotated[0],
- g = ptRotated[1],
- h = ptRotated[2],
-
- // the following essentially solves:
- // ptRotated = rotateCartesian(rotateCartesian(pt, 2, newYaw), 1, newPitch)
- // for newYaw and newPitch, as best it can
- theta = Math.atan2(y, x) * degrees,
- a = Math.sqrt(x * x + y * y),
- b,
- newYaw1;
+ y = pt[1],
+ z = pt[2],
+ f = ptRotated[0],
+ g = ptRotated[1],
+ h = ptRotated[2],
+
+ // the following essentially solves:
+ // ptRotated = rotateCartesian(rotateCartesian(pt, 2, newYaw), 1, newPitch)
+ // for newYaw and newPitch, as best it can
+ theta = Math.atan2(y, x) * degrees,
+ a = Math.sqrt(x * x + y * y),
+ b,
+ newYaw1;
if(Math.abs(g) > a) {
newYaw1 = (g > 0 ? 90 : -90) - theta;
@@ -314,12 +314,12 @@ function unRoll(rotateAngles, pt, lastRotate) {
}
var newYaw2 = 180 - newYaw1 - 2*theta,
- newPitch1 = (Math.atan2(h, f) - Math.atan2(z, b)) * degrees,
- newPitch2 = (Math.atan2(h, f) - Math.atan2(z, -b)) * degrees;
+ newPitch1 = (Math.atan2(h, f) - Math.atan2(z, b)) * degrees,
+ newPitch2 = (Math.atan2(h, f) - Math.atan2(z, -b)) * degrees;
// which is closest to lastRotate[0,1]: newYaw/Pitch or newYaw2/Pitch2?
var dist1 = angleDistance(lastRotate[0], lastRotate[1], newYaw1, newPitch1),
- dist2 = angleDistance(lastRotate[0], lastRotate[1], newYaw2, newPitch2);
+ dist2 = angleDistance(lastRotate[0], lastRotate[1], newYaw2, newPitch2);
if(dist1 <= dist2) return [newYaw1, newPitch1, lastRotate[2]];
else return [newYaw2, newPitch2, lastRotate[2]];
@@ -327,7 +327,7 @@ function unRoll(rotateAngles, pt, lastRotate) {
function angleDistance(yaw0, pitch0, yaw1, pitch1) {
var dYaw = angleMod(yaw1 - yaw0),
- dPitch = angleMod(pitch1 - pitch0);
+ dPitch = angleMod(pitch1 - pitch0);
return Math.sqrt(dYaw * dYaw + dPitch * dPitch);
}
@@ -341,11 +341,11 @@ function angleMod(angle) {
// angle is in degrees
function rotateCartesian(vector, axis, angle) {
var angleRads = angle * radians,
- vectorOut = vector.slice(),
- ax1 = (axis===0) ? 1 : 0,
- ax2 = (axis===2) ? 1 : 2,
- cosa = Math.cos(angleRads),
- sina = Math.sin(angleRads);
+ vectorOut = vector.slice(),
+ ax1 = (axis===0) ? 1 : 0,
+ ax2 = (axis===2) ? 1 : 2,
+ cosa = Math.cos(angleRads),
+ sina = Math.sin(angleRads);
vectorOut[ax1] = vector[ax1] * cosa - vector[ax2] * sina;
vectorOut[ax2] = vector[ax2] * cosa + vector[ax1] * sina;
@@ -362,8 +362,8 @@ function eulerFromQuaternion(q) {
function cartesian(spherical) {
var lambda = spherical[0] * radians,
- phi = spherical[1] * radians,
- cosPhi = Math.cos(phi);
+ phi = spherical[1] * radians,
+ cosPhi = Math.cos(phi);
return [
cosPhi * Math.cos(lambda),
cosPhi * Math.sin(lambda),
@@ -372,7 +372,8 @@ function cartesian(spherical) {
}
function dot(a, b) {
- for (var i = 0, n = a.length, s = 0; i < n; ++i) s += a[i] * b[i];
+ var s = 0;
+ for (var i = 0, n = a.length; i < n; ++i) s += a[i] * b[i];
return s;
}
@@ -390,8 +391,8 @@ function cross(a, b) {
// target element's data) and `i` (the selection index of the target element).
function d3_eventDispatch(target) {
var i = 0,
- n = arguments.length,
- argumentz = [];
+ n = arguments.length,
+ argumentz = [];
while (++i < n) argumentz.push(arguments[i]);
diff --git a/src/plots/geo/zoom_reset.js b/src/plots/geo/zoom_reset.js
index 8f9311407f2..1314b1b675b 100644
--- a/src/plots/geo/zoom_reset.js
+++ b/src/plots/geo/zoom_reset.js
@@ -15,7 +15,7 @@ var loneUnhover = require('../../plotly').Fx.loneUnhover;
function createGeoZoomReset(geo, geoLayout) {
var projection = geo.projection,
zoom = geo.zoom;
-
+
var zoomReset = function() {
geo.makeProjection(geoLayout);
geo.makePath();
diff --git a/src/plots/gl2d/camera.js b/src/plots/gl2d/camera.js
index 4b14feb3ba9..5ebe9ecc46b 100644
--- a/src/plots/gl2d/camera.js
+++ b/src/plots/gl2d/camera.js
@@ -87,7 +87,7 @@ function createCamera(scene) {
result.boxEnabled = false;
}
- break;
+ break;
case 'pan':
result.boxEnabled = false;
@@ -107,7 +107,7 @@ function createCamera(scene) {
scene.cameraChanged();
}
- break;
+ break;
}
result.lastPos[0] = x;
@@ -124,7 +124,7 @@ function createCamera(scene) {
switch(scene.fullLayout.dragmode) {
case 'zoom':
- break;
+ break;
case 'pan':
var scale = Math.exp(0.1 * dy / (viewBox[3] - viewBox[1]));
@@ -143,7 +143,7 @@ function createCamera(scene) {
result.lastInputTime = Date.now();
scene.cameraChanged();
- break;
+ break;
}
return true;
diff --git a/src/plots/gl2d/convert.js b/src/plots/gl2d/convert.js
index 5f03f13a66a..50b1521bff6 100644
--- a/src/plots/gl2d/convert.js
+++ b/src/plots/gl2d/convert.js
@@ -53,7 +53,7 @@ function Axes2DOptions(scene) {
this.labels = ['x', 'y'];
this.labelEnable = [true, true, false, false];
- this.labelAngle = [0, Math.PI/2, 0, 3.0*Math.PI/2];
+ this.labelAngle = [0, Math.PI/2, 0, 3.0*Math.PI/2];
this.labelPad = [15, 15, 15, 15];
this.labelSize = [12, 12];
this.labelFont = ['sans-serif', 'sans-serif'];
@@ -111,7 +111,7 @@ proto.merge = function(options) {
// '_name' is e.g. xaxis, xaxis2, yaxis, yaxis4 ...
ax = options[this.scene[axisName]._name];
- axTitle = /Click to enter .+ title/.test(ax.title) ? '' : ax.title;
+ axTitle = /Click to enter .+ title/.test(ax.title) ? '' : ax.title;
for(j = 0; j <= 2; j += 2) {
this.labelEnable[i+j] = false;
diff --git a/src/plots/gl2d/index.js b/src/plots/gl2d/index.js
index 57c0b9e9d0c..20b00ad3b7f 100644
--- a/src/plots/gl2d/index.js
+++ b/src/plots/gl2d/index.js
@@ -20,7 +20,7 @@ exports.name = 'gl2d';
exports.attr = ['xaxis', 'yaxis'];
-exports.idRoot = ['x', 'y'];
+exports.idRoot = ['x', 'y'];
exports.attributes = require('../cartesian/attributes');
@@ -40,11 +40,11 @@ exports.plot = function plotGl2d(gd) {
// If Scene is not instantiated, create one!
if(scene === undefined) {
scene = new Scene2D({
- container: gd.querySelector('.gl-container'),
- id: subplotId,
- staticPlot: gd._context.staticPlot,
- plotGlPixelRatio: gd._context.plotGlPixelRatio
- },
+ container: gd.querySelector('.gl-container'),
+ id: subplotId,
+ staticPlot: gd._context.staticPlot,
+ plotGlPixelRatio: gd._context.plotGlPixelRatio
+ },
fullLayout
);
diff --git a/src/plots/gl2d/scene2d.js b/src/plots/gl2d/scene2d.js
index e284123d17f..7c69ae39dd1 100644
--- a/src/plots/gl2d/scene2d.js
+++ b/src/plots/gl2d/scene2d.js
@@ -28,7 +28,7 @@ var STATIC_CANVAS, STATIC_CONTEXT;
function Scene2D(options, fullLayout) {
this.container = options.container;
- this.pixelRatio = options.plotGlPixelRatio || window.devicePixelRatio;
+ this.pixelRatio = options.plotGlPixelRatio || window.devicePixelRatio;
this.id = options.id;
this.staticPlot = !!options.staticPlot;
@@ -89,9 +89,9 @@ proto.makeFramework = function() {
antialias: true
});
} catch(e) {
- throw new Error([
- 'Error creating static canvas/context for image server'
- ].join(' '));
+ throw new Error([
+ 'Error creating static canvas/context for image server'
+ ].join(' '));
}
}
@@ -105,12 +105,16 @@ proto.makeFramework = function() {
try {
gl = liveCanvas.getContext('webgl', glOpts);
- } catch(e) {}
+ } catch(e) {
+ //
+ }
if(!gl) {
try {
gl = liveCanvas.getContext('experimental-webgl', glOpts);
- } catch(e) {}
+ } catch(e) {
+ //
+ }
}
if(!gl) showNoWebGlMsg(this);
@@ -204,7 +208,7 @@ proto.toImage = function(format) {
dataURL = canvas.toDataURL('image/webp');
break;
default:
- dataURL = canvas.toDataURL('image/png');
+ dataURL = canvas.toDataURL('image/png');
}
if(this.staticPlot) this.container.removeChild(STATIC_CANVAS);
@@ -324,7 +328,7 @@ proto.plot = function(fullData, fullLayout) {
switch(traceData.type) {
case 'scattergl':
trace = createLineWithMarkers(this, traceData);
- break;
+ break;
}
}
this.traces[traceData.uid] = trace;
@@ -332,7 +336,8 @@ proto.plot = function(fullData, fullLayout) {
// remove empty traces
var traceIds = Object.keys(this.traces);
-trace_id_loop:
+
+ trace_id_loop:
for(i = 0; i < traceIds.length; ++i) {
for(j = 0; j < fullData.length; ++j) {
if(fullData[j].uid === traceIds[i]) continue trace_id_loop;
@@ -482,7 +487,7 @@ proto.draw = function() {
container: this.svgContainer
});
- this.lastPickResult = { dataCoord: result.dataCoord };
+ this.lastPickResult = { dataCoord: result.dataCoord };
}
}
else if(!result && this.lastPickResult) {
diff --git a/src/plots/gl3d/camera.js b/src/plots/gl3d/camera.js
index 516b2f660da..83c91ab40ef 100644
--- a/src/plots/gl3d/camera.js
+++ b/src/plots/gl3d/camera.js
@@ -6,241 +6,236 @@
* LICENSE file in the root directory of this source tree.
*/
-
-/* jshint shadow: true */
-
'use strict';
module.exports = createCamera;
-var now = require('right-now');
-var createView = require('3d-view');
+var now = require('right-now');
+var createView = require('3d-view');
var mouseChange = require('mouse-change');
-var mouseWheel = require('mouse-wheel');
+var mouseWheel = require('mouse-wheel');
function createCamera(element, options) {
- element = element || document.body;
- options = options || {};
-
- var limits = [ 0.01, Infinity ];
- if('distanceLimits' in options) {
- limits[0] = options.distanceLimits[0];
- limits[1] = options.distanceLimits[1];
- }
- if('zoomMin' in options) {
- limits[0] = options.zoomMin;
- }
- if('zoomMax' in options) {
- limits[1] = options.zoomMax;
- }
-
- var view = createView({
- center: options.center || [0, 0, 0],
- up: options.up || [0, 1, 0],
- eye: options.eye || [0, 0, 10],
- mode: options.mode || 'orbit',
- distanceLimits: limits
- });
-
- var pmatrix = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
- var distance = 0.0;
- var width = element.clientWidth;
- var height = element.clientHeight;
-
- var camera = {
- keyBindingMode: 'rotate',
- view: view,
- element: element,
- delay: options.delay || 16,
- rotateSpeed: options.rotateSpeed || 1,
- zoomSpeed: options.zoomSpeed || 1,
- translateSpeed: options.translateSpeed || 1,
- flipX: !!options.flipX,
- flipY: !!options.flipY,
- modes: view.modes,
- tick: function() {
- var t = now();
- var delay = this.delay;
- var ctime = t - 2 * delay;
- view.idle(t-delay);
- view.recalcMatrix(ctime);
- view.flush(t - (100+delay * 2));
- var allEqual = true;
- var matrix = view.computedMatrix;
- for(var i = 0; i < 16; ++i) {
- allEqual = allEqual && (pmatrix[i] === matrix[i]);
- pmatrix[i] = matrix[i];
- }
- var sizeChanged =
- element.clientWidth === width &&
- element.clientHeight === height;
- width = element.clientWidth;
- height = element.clientHeight;
- if(allEqual) {
- return !sizeChanged;
- }
- distance = Math.exp(view.computedRadius[0]);
- return true;
- },
- lookAt: function(center, eye, up) {
- view.lookAt(view.lastT(), center, eye, up);
- },
- rotate: function(pitch, yaw, roll) {
- view.rotate(view.lastT(), pitch, yaw, roll);
- },
- pan: function(dx, dy, dz) {
- view.pan(view.lastT(), dx, dy, dz);
- },
- translate: function(dx, dy, dz) {
- view.translate(view.lastT(), dx, dy, dz);
+ element = element || document.body;
+ options = options || {};
+
+ var limits = [ 0.01, Infinity ];
+ if('distanceLimits' in options) {
+ limits[0] = options.distanceLimits[0];
+ limits[1] = options.distanceLimits[1];
}
- };
-
- Object.defineProperties(camera, {
- matrix: {
- get: function() {
- return view.computedMatrix;
- },
- set: function(mat) {
- view.setMatrix(view.lastT(), mat);
- return view.computedMatrix;
- },
- enumerable: true
- },
- mode: {
- get: function() {
- return view.getMode();
- },
- set: function(mode) {
- var curUp = view.computedUp.slice();
- var curEye = view.computedEye.slice();
- var curCenter = view.computedCenter.slice();
- view.setMode(mode);
- if(mode === 'turntable') {
- //Hacky time warping stuff to generate smooth animation
- var t0 = now();
- view._active.lookAt(t0, curEye, curCenter, curUp);
- view._active.lookAt(t0 + 500, curEye, curCenter, [0,0,1]);
- view._active.flush(t0);
- }
- return view.getMode();
- },
- enumerable: true
- },
- center: {
- get: function() {
- return view.computedCenter;
- },
- set: function(ncenter) {
- view.lookAt(view.lastT(), null, ncenter);
- return view.computedCenter;
- },
- enumerable: true
- },
- eye: {
- get: function() {
- return view.computedEye;
- },
- set: function(neye) {
- view.lookAt(view.lastT(), neye);
- return view.computedEye;
- },
- enumerable: true
- },
- up: {
- get: function() {
- return view.computedUp;
- },
- set: function(nup) {
- view.lookAt(view.lastT(), null, null, nup);
- return view.computedUp;
- },
- enumerable: true
- },
- distance: {
- get: function() {
- return distance;
- },
- set: function(d) {
- view.setDistance(view.lastT(), d);
- return d;
- },
- enumerable: true
- },
- distanceLimits: {
- get: function() {
- return view.getDistanceLimits(limits);
- },
- set: function(v) {
- view.setDistanceLimits(v);
- return v;
- },
- enumerable: true
+ if('zoomMin' in options) {
+ limits[0] = options.zoomMin;
+ }
+ if('zoomMax' in options) {
+ limits[1] = options.zoomMax;
}
- });
- element.addEventListener('contextmenu', function(ev) {
- ev.preventDefault();
- return false;
- });
+ var view = createView({
+ center: options.center || [0, 0, 0],
+ up: options.up || [0, 1, 0],
+ eye: options.eye || [0, 0, 10],
+ mode: options.mode || 'orbit',
+ distanceLimits: limits
+ });
+
+ var pmatrix = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
+ var distance = 0.0;
+ var width = element.clientWidth;
+ var height = element.clientHeight;
+
+ var camera = {
+ keyBindingMode: 'rotate',
+ view: view,
+ element: element,
+ delay: options.delay || 16,
+ rotateSpeed: options.rotateSpeed || 1,
+ zoomSpeed: options.zoomSpeed || 1,
+ translateSpeed: options.translateSpeed || 1,
+ flipX: !!options.flipX,
+ flipY: !!options.flipY,
+ modes: view.modes,
+ tick: function() {
+ var t = now();
+ var delay = this.delay;
+ var ctime = t - 2 * delay;
+ view.idle(t-delay);
+ view.recalcMatrix(ctime);
+ view.flush(t - (100+delay * 2));
+ var allEqual = true;
+ var matrix = view.computedMatrix;
+ for(var i = 0; i < 16; ++i) {
+ allEqual = allEqual && (pmatrix[i] === matrix[i]);
+ pmatrix[i] = matrix[i];
+ }
+ var sizeChanged =
+ element.clientWidth === width &&
+ element.clientHeight === height;
+ width = element.clientWidth;
+ height = element.clientHeight;
+ if(allEqual) return !sizeChanged;
+ distance = Math.exp(view.computedRadius[0]);
+ return true;
+ },
+ lookAt: function(center, eye, up) {
+ view.lookAt(view.lastT(), center, eye, up);
+ },
+ rotate: function(pitch, yaw, roll) {
+ view.rotate(view.lastT(), pitch, yaw, roll);
+ },
+ pan: function(dx, dy, dz) {
+ view.pan(view.lastT(), dx, dy, dz);
+ },
+ translate: function(dx, dy, dz) {
+ view.translate(view.lastT(), dx, dy, dz);
+ }
+ };
+
+ Object.defineProperties(camera, {
+ matrix: {
+ get: function() {
+ return view.computedMatrix;
+ },
+ set: function(mat) {
+ view.setMatrix(view.lastT(), mat);
+ return view.computedMatrix;
+ },
+ enumerable: true
+ },
+ mode: {
+ get: function() {
+ return view.getMode();
+ },
+ set: function(mode) {
+ var curUp = view.computedUp.slice();
+ var curEye = view.computedEye.slice();
+ var curCenter = view.computedCenter.slice();
+ view.setMode(mode);
+ if(mode === 'turntable') {
+ //Hacky time warping stuff to generate smooth animation
+ var t0 = now();
+ view._active.lookAt(t0, curEye, curCenter, curUp);
+ view._active.lookAt(t0 + 500, curEye, curCenter, [0,0,1]);
+ view._active.flush(t0);
+ }
+ return view.getMode();
+ },
+ enumerable: true
+ },
+ center: {
+ get: function() {
+ return view.computedCenter;
+ },
+ set: function(ncenter) {
+ view.lookAt(view.lastT(), null, ncenter);
+ return view.computedCenter;
+ },
+ enumerable: true
+ },
+ eye: {
+ get: function() {
+ return view.computedEye;
+ },
+ set: function(neye) {
+ view.lookAt(view.lastT(), neye);
+ return view.computedEye;
+ },
+ enumerable: true
+ },
+ up: {
+ get: function() {
+ return view.computedUp;
+ },
+ set: function(nup) {
+ view.lookAt(view.lastT(), null, null, nup);
+ return view.computedUp;
+ },
+ enumerable: true
+ },
+ distance: {
+ get: function() {
+ return distance;
+ },
+ set: function(d) {
+ view.setDistance(view.lastT(), d);
+ return d;
+ },
+ enumerable: true
+ },
+ distanceLimits: {
+ get: function() {
+ return view.getDistanceLimits(limits);
+ },
+ set: function(v) {
+ view.setDistanceLimits(v);
+ return v;
+ },
+ enumerable: true
+ }
+ });
- var lastX = 0, lastY = 0;
- mouseChange(element, function(buttons, x, y, mods) {
- var rotate = camera.keyBindingMode === 'rotate';
- var pan = camera.keyBindingMode === 'pan';
- var zoom = camera.keyBindingMode === 'zoom';
+ element.addEventListener('contextmenu', function(ev) {
+ ev.preventDefault();
+ return false;
+ });
- var ctrl = !!mods.control;
- var alt = !!mods.alt;
- var shift = !!mods.shift;
- var left = !!(buttons&1);
- var right = !!(buttons&2);
- var middle = !!(buttons&4);
+ var lastX = 0, lastY = 0;
+ mouseChange(element, function(buttons, x, y, mods) {
+ var rotate = camera.keyBindingMode === 'rotate';
+ var pan = camera.keyBindingMode === 'pan';
+ var zoom = camera.keyBindingMode === 'zoom';
- var scale = 1.0 / element.clientHeight;
- var dx = scale * (x - lastX);
- var dy = scale * (y - lastY);
+ var ctrl = !!mods.control;
+ var alt = !!mods.alt;
+ var shift = !!mods.shift;
+ var left = !!(buttons&1);
+ var right = !!(buttons&2);
+ var middle = !!(buttons&4);
- var flipX = camera.flipX ? 1 : -1;
- var flipY = camera.flipY ? 1 : -1;
+ var scale = 1.0 / element.clientHeight;
+ var dx = scale * (x - lastX);
+ var dy = scale * (y - lastY);
- var t = now();
+ var flipX = camera.flipX ? 1 : -1;
+ var flipY = camera.flipY ? 1 : -1;
- var drot = Math.PI * camera.rotateSpeed;
+ var t = now();
- if( (rotate && left && !ctrl && !alt && !shift) || (left && !ctrl && !alt && shift)) {
- //Rotate
- view.rotate(t, flipX * drot * dx, -flipY * drot * dy, 0);
- }
+ var drot = Math.PI * camera.rotateSpeed;
- if( (pan && left && !ctrl && !alt && !shift) || right || (left && ctrl && !alt && !shift)) {
- //Pan
- view.pan(t, -camera.translateSpeed * dx * distance, camera.translateSpeed * dy * distance, 0);
- }
+ if((rotate && left && !ctrl && !alt && !shift) || (left && !ctrl && !alt && shift)) {
+ //Rotate
+ view.rotate(t, flipX * drot * dx, -flipY * drot * dy, 0);
+ }
- if( (zoom && left && !ctrl && !alt && !shift) || middle || (left && !ctrl && alt && !shift)) {
- //Zoom
- var kzoom = -camera.zoomSpeed * dy / window.innerHeight * (t - view.lastT()) * 100;
- view.pan(t, 0, 0, distance * (Math.exp(kzoom) - 1));
- }
+ if((pan && left && !ctrl && !alt && !shift) || right || (left && ctrl && !alt && !shift)) {
+ //Pan
+ view.pan(t, -camera.translateSpeed * dx * distance, camera.translateSpeed * dy * distance, 0);
+ }
- lastX = x;
- lastY = y;
-
- return true;
- });
-
- mouseWheel(element, function(dx, dy) {
- var flipX = camera.flipX ? 1 : -1;
- var flipY = camera.flipY ? 1 : -1;
- var t = now();
- if(Math.abs(dx) > Math.abs(dy)) {
- view.rotate(t, 0, 0, -dx * flipX * Math.PI * camera.rotateSpeed / window.innerWidth);
- } else {
- var kzoom = -camera.zoomSpeed * flipY * dy / window.innerHeight * (t - view.lastT()) / 100.0;
- view.pan(t, 0, 0, distance * (Math.exp(kzoom) - 1));
- }
- }, true);
+ if((zoom && left && !ctrl && !alt && !shift) || middle || (left && !ctrl && alt && !shift)) {
+ //Zoom
+ var kzoom = -camera.zoomSpeed * dy / window.innerHeight * (t - view.lastT()) * 100;
+ view.pan(t, 0, 0, distance * (Math.exp(kzoom) - 1));
+ }
+
+ lastX = x;
+ lastY = y;
+
+ return true;
+ });
+
+ mouseWheel(element, function(dx, dy) {
+ var flipX = camera.flipX ? 1 : -1;
+ var flipY = camera.flipY ? 1 : -1;
+ var t = now();
+ if(Math.abs(dx) > Math.abs(dy)) {
+ view.rotate(t, 0, 0, -dx * flipX * Math.PI * camera.rotateSpeed / window.innerWidth);
+ } else {
+ var kzoom = -camera.zoomSpeed * flipY * dy / window.innerHeight * (t - view.lastT()) / 100.0;
+ view.pan(t, 0, 0, distance * (Math.exp(kzoom) - 1));
+ }
+ }, true);
- return camera;
+ return camera;
}
diff --git a/src/plots/gl3d/index.js b/src/plots/gl3d/index.js
index 78abd7cf633..68f15f0177a 100644
--- a/src/plots/gl3d/index.js
+++ b/src/plots/gl3d/index.js
@@ -49,11 +49,11 @@ exports.plot = function plotGl3d(gd) {
// If Scene is not instantiated, create one!
if(scene === undefined) {
scene = new Scene({
- container: gd.querySelector('.gl-container'),
- id: sceneId,
- staticPlot: gd._context.staticPlot,
- plotGlPixelRatio: gd._context.plotGlPixelRatio
- },
+ container: gd.querySelector('.gl-container'),
+ id: sceneId,
+ staticPlot: gd._context.staticPlot,
+ plotGlPixelRatio: gd._context.plotGlPixelRatio
+ },
fullLayout
);
@@ -76,7 +76,7 @@ exports.cleanId = function cleanId(id) {
exports.setConvert = require('./set_convert');
-exports.initAxes = function (gd) {
+exports.initAxes = function(gd) {
var fullLayout = gd._fullLayout;
// until they play better together
diff --git a/src/plots/gl3d/layout/attributes.js b/src/plots/gl3d/layout/attributes.js
index a60ccce2da4..98e1719b930 100644
--- a/src/plots/gl3d/layout/attributes.js
+++ b/src/plots/gl3d/layout/attributes.js
@@ -6,6 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
+
module.exports = {
scene: {
diff --git a/src/plots/gl3d/layout/axis_attributes.js b/src/plots/gl3d/layout/axis_attributes.js
index 663acc2d646..dbc8811bf18 100644
--- a/src/plots/gl3d/layout/axis_attributes.js
+++ b/src/plots/gl3d/layout/axis_attributes.js
@@ -6,6 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
+
var axesAttrs = require('../../cartesian/layout_attributes');
var extendFlat = require('../../../lib/extend').extendFlat;
diff --git a/src/plots/gl3d/layout/convert.js b/src/plots/gl3d/layout/convert.js
index c75d6255221..d598ec1672e 100644
--- a/src/plots/gl3d/layout/convert.js
+++ b/src/plots/gl3d/layout/convert.js
@@ -18,8 +18,10 @@ var arrayCopy1D = arrtools.copy1D;
var AXES_NAMES = ['xaxis', 'yaxis', 'zaxis'];
function AxesOptions() {
- this.bounds = [ [-10, -10, -10],
- [ 10, 10, 10] ];
+ this.bounds = [
+ [-10, -10, -10],
+ [10, 10, 10]
+ ];
this.ticks = [ [], [], [] ];
this.tickEnable = [ true, true, true ];
@@ -57,7 +59,7 @@ function AxesOptions() {
this.zeroLineWidth = [ 2, 2, 2 ];
this.backgroundEnable = [ true, true, true ];
- this.backgroundColor = [ [0.8, 0.8, 0.8, 0.5],
+ this.backgroundColor = [ [0.8, 0.8, 0.8, 0.5],
[0.8, 0.8, 0.8, 0.5],
[0.8, 0.8, 0.8, 0.5] ];
@@ -77,17 +79,17 @@ proto.merge = function(sceneLayout) {
/////// Axes labels //
opts.labels[i] = convertHTML(axes.title);
if ('titlefont' in axes) {
- if (axes.titlefont.color) opts.labelColor[i] = str2RgbaArray(axes.titlefont.color);
+ if (axes.titlefont.color) opts.labelColor[i] = str2RgbaArray(axes.titlefont.color);
if (axes.titlefont.family) opts.labelFont[i] = axes.titlefont.family;
- if (axes.titlefont.size) opts.labelSize[i] = axes.titlefont.size;
+ if (axes.titlefont.size) opts.labelSize[i] = axes.titlefont.size;
}
/////// LINES ////////
- if ('showline' in axes) opts.lineEnable[i] = axes.showline;
+ if ('showline' in axes) opts.lineEnable[i] = axes.showline;
if ('linecolor' in axes) opts.lineColor[i] = str2RgbaArray(axes.linecolor);
if ('linewidth' in axes) opts.lineWidth[i] = axes.linewidth;
- if ('showgrid' in axes) opts.gridEnable[i] = axes.showgrid;
+ if ('showgrid' in axes) opts.gridEnable[i] = axes.showgrid;
if ('gridcolor' in axes) opts.gridColor[i] = str2RgbaArray(axes.gridcolor);
if ('gridwidth' in axes) opts.gridWidth[i] = axes.gridwidth;
diff --git a/src/plots/gl3d/layout/defaults.js b/src/plots/gl3d/layout/defaults.js
index d16b98c6626..495873f27be 100644
--- a/src/plots/gl3d/layout/defaults.js
+++ b/src/plots/gl3d/layout/defaults.js
@@ -14,7 +14,7 @@ var layoutAttributes = require('./layout_attributes');
var supplyGl3dAxisLayoutDefaults = require('./axis_defaults');
-module.exports = function supplyLayoutDefaults (layoutIn, layoutOut, fullData) {
+module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
if (!layoutOut._hasGL3D) return;
var scenes = Plotly.Plots.getSubplotIdsInData(fullData, 'gl3d');
@@ -26,6 +26,7 @@ module.exports = function supplyLayoutDefaults (layoutIn, layoutOut, fullData) {
// Get number of scenes to compute default scene domain
var scenesLength = scenes.length;
+ var sceneLayoutIn, sceneLayoutOut;
function coerce(attr, dflt) {
return Plotly.Lib.coerce(sceneLayoutIn, sceneLayoutOut, layoutAttributes, attr, dflt);
@@ -44,11 +45,11 @@ module.exports = function supplyLayoutDefaults (layoutIn, layoutOut, fullData) {
* Also write back a blank scene object to user layout so that some
* attributes like aspectratio can be written back dynamically.
*/
- var sceneLayoutIn;
+ sceneLayoutIn;
if(layoutIn[scene] !== undefined) sceneLayoutIn = layoutIn[scene];
else layoutIn[scene] = sceneLayoutIn = {};
- var sceneLayoutOut = layoutOut[scene] || {};
+ sceneLayoutOut = layoutOut[scene] || {};
coerce('bgcolor');
diff --git a/src/plots/gl3d/layout/tick_marks.js b/src/plots/gl3d/layout/tick_marks.js
index a725618094e..3b84aebeed9 100644
--- a/src/plots/gl3d/layout/tick_marks.js
+++ b/src/plots/gl3d/layout/tick_marks.js
@@ -6,14 +6,14 @@
* LICENSE file in the root directory of this source tree.
*/
-
-/* jshint shadow: true */
+/*eslint block-scoped-var: 0*/
+/*eslint no-redeclare: 0*/
'use strict';
module.exports = computeTickMarks;
-var Plotly = require('../../../plotly');
+var Plotly = require('../../../plotly');
var convertHTML = require('../../../lib/html2unicode');
var AXES_NAMES = ['xaxis', 'yaxis', 'zaxis'];
@@ -35,7 +35,7 @@ function contourLevelsFromTicks(ticks) {
function computeTickMarks(scene) {
var axesOptions = scene.axesOptions;
- var glRange = scene.glplot.axesPixels;
+ var glRange = scene.glplot.axesPixels;
var sceneLayout = scene.fullSceneLayout;
var ticks = [[],[],[]];
@@ -51,7 +51,7 @@ function computeTickMarks(scene) {
} else {
axes.range[0] = (glRange[i].lo) / scene.dataScale[i];
axes.range[1] = (glRange[i].hi) / scene.dataScale[i];
- axes._m = 1.0 / (scene.dataScale[i] * glRange[i].pixelsPerDataUnit);
+ axes._m = 1.0 / (scene.dataScale[i] * glRange[i].pixelsPerDataUnit);
if(axes.range[0] === axes.range[1]) {
axes.range[0] -= 1;
@@ -69,8 +69,8 @@ function computeTickMarks(scene) {
}
var dataTicks = Plotly.Axes.calcTicks(axes);
for(var j=0; j dataBounds[1][j]) {
- dataScale[j] = 1.0;
- } else {
- if(dataBounds[1][j] === dataBounds[0][j]) {
- dataScale[j] = 1.0;
- } else {
- dataScale[j] = 1.0/(dataBounds[1][j] - dataBounds[0][j]);
+ if(dataBounds[0][j] > dataBounds[1][j]) {
+ dataScale[j] = 1.0;
+ }
+ else {
+ if(dataBounds[1][j] === dataBounds[0][j]) {
+ dataScale[j] = 1.0;
+ }
+ else {
+ dataScale[j] = 1.0/(dataBounds[1][j] - dataBounds[0][j]);
+ }
}
- }
}
//Save scale
@@ -360,15 +354,15 @@ proto.plot = function(sceneData, fullLayout, layout) {
switch(data.type) {
case 'scatter3d':
trace = createScatterTrace(this, data);
- break;
+ break;
case 'surface':
trace = createSurfaceTrace(this, data);
- break;
+ break;
case 'mesh3d':
trace = createMeshTrace(this, data);
- break;
+ break;
default:
}
@@ -379,7 +373,8 @@ proto.plot = function(sceneData, fullLayout, layout) {
//Remove empty traces
var traceIds = Object.keys(this.traces);
-trace_id_loop:
+
+ trace_id_loop:
for(i = 0; i sceneBounds[1][i]) {
sceneBounds[0][i] = -1;
- sceneBounds[1][i] = 1;
+ sceneBounds[1][i] = 1;
} else {
var d = sceneBounds[1][i] - sceneBounds[0][i];
sceneBounds[0][i] -= d/32.0;
@@ -452,10 +448,10 @@ trace_id_loop:
//Compute axis scale per category
for(var i=0; i<3; ++i) {
- var axis = fullSceneLayout[axisProperties[i]];
- var axisType = axis.type;
- var axisRatio = axisTypeRatios[axisType];
- axesScaleRatio[i] = Math.pow(axisRatio.acc, 1.0/axisRatio.count) / dataScale[i];
+ var axis = fullSceneLayout[axisProperties[i]];
+ var axisType = axis.type;
+ var axisRatio = axisTypeRatios[axisType];
+ axesScaleRatio[i] = Math.pow(axisRatio.acc, 1.0/axisRatio.count) / dataScale[i];
}
/*
@@ -517,10 +513,10 @@ trace_id_loop:
if (domain && size) {
var containerStyle = this.container.style;
containerStyle.position = 'absolute';
- containerStyle.left = (size.l + domain.x[0] * size.w) + 'px';
- containerStyle.top = (size.t + (1 - domain.y[1]) * size.h) + 'px';
- containerStyle.width = (size.w * (domain.x[1] - domain.x[0])) + 'px';
- containerStyle.height = (size.h * (domain.y[1] - domain.y[0])) + 'px';
+ containerStyle.left = (size.l + domain.x[0] * size.w) + 'px';
+ containerStyle.top = (size.t + (1 - domain.y[1]) * size.h) + 'px';
+ containerStyle.width = (size.w * (domain.x[1] - domain.x[0])) + 'px';
+ containerStyle.height = (size.h * (domain.y[1] - domain.y[0])) + 'px';
}
};
@@ -534,35 +530,35 @@ proto.destroy = function() {
// for reset camera button in mode bar
-proto.setCameraToDefault = function setCameraToDefault () {
+proto.setCameraToDefault = function setCameraToDefault() {
// as in Gl3d.layoutAttributes
this.glplot.camera.lookAt(
[1.25, 1.25, 1.25],
- [0 , 0 , 0 ],
- [0 , 0 , 1 ]
+ [0, 0, 0],
+ [0, 0, 1]
);
};
// get camera position in plotly coords from 'orbit-camera' coords
-proto.getCamera = function getCamera () {
+proto.getCamera = function getCamera() {
this.glplot.camera.view.recalcMatrix(this.camera.view.lastT());
- var up = this.glplot.camera.up;
+ var up = this.glplot.camera.up;
var center = this.glplot.camera.center;
- var eye = this.glplot.camera.eye;
+ var eye = this.glplot.camera.eye;
return {
- up: {x:up[0], y:up[1], z:up[2]},
+ up: {x:up[0], y:up[1], z:up[2]},
center: {x:center[0], y:center[1], z:center[2]},
- eye: {x:eye[0], y:eye[1], z:eye[2]}
+ eye: {x:eye[0], y:eye[1], z:eye[2]}
};
};
// set camera position with a set of plotly coords
-proto.setCamera = function setCamera (cameraData) {
- var up = cameraData.up;
- var center = cameraData.center;
- var eye = cameraData.eye;
+proto.setCamera = function setCamera(cameraData) {
+ var up = cameraData.up;
+ var center = cameraData.center;
+ var eye = cameraData.eye;
this.glplot.camera.lookAt(
[eye.x, eye.y, eye.z],
[center.x, center.y, center.z],
@@ -600,7 +596,7 @@ proto.saveCamera = function saveCamera(layout) {
return hasChanged;
};
-proto.handleDragmode = function (dragmode) {
+proto.handleDragmode = function(dragmode) {
var camera = this.camera;
if (camera) {
@@ -622,12 +618,10 @@ proto.handleDragmode = function (dragmode) {
}
};
-proto.toImage = function (format) {
+proto.toImage = function(format) {
if (!format) format = 'png';
- if(this.staticMode) {
- this.container.appendChild(STATIC_CANVAS);
- }
+ if(this.staticMode) this.container.appendChild(STATIC_CANVAS);
//Force redraw
this.glplot.redraw();
@@ -663,7 +657,7 @@ proto.toImage = function (format) {
var dataURL;
- switch (format) {
+ switch(format) {
case 'jpeg':
dataURL = canvas.toDataURL('image/jpeg');
break;
@@ -671,12 +665,10 @@ proto.toImage = function (format) {
dataURL = canvas.toDataURL('image/webp');
break;
default:
- dataURL = canvas.toDataURL('image/png');
+ dataURL = canvas.toDataURL('image/png');
}
- if(this.staticMode) {
- this.container.removeChild(STATIC_CANVAS);
- }
+ if(this.staticMode) this.container.removeChild(STATIC_CANVAS);
return dataURL;
};
diff --git a/src/plots/gl3d/set_convert.js b/src/plots/gl3d/set_convert.js
index 25ad8724dfb..3e73e511be7 100644
--- a/src/plots/gl3d/set_convert.js
+++ b/src/plots/gl3d/set_convert.js
@@ -11,7 +11,7 @@
var Plotly = require('../../plotly');
-var noop = function () {};
+var noop = function() {};
module.exports = function setConvert(containerOut) {
diff --git a/src/plots/layout_attributes.js b/src/plots/layout_attributes.js
index c873b48ed92..41781deca30 100644
--- a/src/plots/layout_attributes.js
+++ b/src/plots/layout_attributes.js
@@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
var Plotly = require('../plotly');
diff --git a/src/plots/plots.js b/src/plots/plots.js
index 6df2c1f1591..0bdee8c6328 100644
--- a/src/plots/plots.js
+++ b/src/plots/plots.js
@@ -370,36 +370,36 @@ function positionPlayWithData(gd, container){
}
}
plots.sendDataToCloud = function(gd) {
- gd.emit('plotly_beforeexport');
+ gd.emit('plotly_beforeexport');
- var baseUrl = (window.PLOTLYENV && window.PLOTLYENV.BASE_URL) || 'https://plot.ly';
+ var baseUrl = (window.PLOTLYENV && window.PLOTLYENV.BASE_URL) || 'https://plot.ly';
- var hiddenformDiv = d3.select(gd)
- .append('div')
- .attr('id', 'hiddenform')
- .style('display', 'none');
+ var hiddenformDiv = d3.select(gd)
+ .append('div')
+ .attr('id', 'hiddenform')
+ .style('display', 'none');
- var hiddenform = hiddenformDiv
- .append('form')
- .attr({
- action: baseUrl + '/external',
- method: 'post',
- target: '_blank'
- });
+ var hiddenform = hiddenformDiv
+ .append('form')
+ .attr({
+ action: baseUrl + '/external',
+ method: 'post',
+ target: '_blank'
+ });
- var hiddenformInput = hiddenform
- .append('input')
- .attr({
- type: 'text',
- name: 'data'
- });
+ var hiddenformInput = hiddenform
+ .append('input')
+ .attr({
+ type: 'text',
+ name: 'data'
+ });
- hiddenformInput.node().value = plots.graphJson(gd, false, 'keepdata');
- hiddenform.node().submit();
- hiddenformDiv.remove();
+ hiddenformInput.node().value = plots.graphJson(gd, false, 'keepdata');
+ hiddenform.node().submit();
+ hiddenformDiv.remove();
- gd.emit('plotly_afterexport');
- return false;
+ gd.emit('plotly_afterexport');
+ return false;
};
plots.supplyDefaults = function(gd) {
@@ -428,7 +428,7 @@ plots.supplyDefaults = function(gd) {
// then do the data
for (i = 0; i < newData.length; i++) {
- trace = newData[i];
+ trace = newData[i];
fullTrace = plots.supplyDataDefaults(trace, i, newFullLayout);
newFullData.push(fullTrace);
diff --git a/src/plots/polar/area_attributes.js b/src/plots/polar/area_attributes.js
index 352c997a355..89cbc9822c1 100644
--- a/src/plots/polar/area_attributes.js
+++ b/src/plots/polar/area_attributes.js
@@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
var scatterAttrs = require('../../traces/scatter/attributes');
var scatterMarkerAttrs = scatterAttrs.marker;
diff --git a/src/plots/polar/axis_attributes.js b/src/plots/polar/axis_attributes.js
index f1ee92bf513..a653fd5a839 100644
--- a/src/plots/polar/axis_attributes.js
+++ b/src/plots/polar/axis_attributes.js
@@ -99,7 +99,7 @@ module.exports = {
'Defines the start and end point of this radial axis.'
].join(' ')
},
- domain: domainAttr,
+ domain: domainAttr,
orientation: {
valType: 'number',
role: 'style',
diff --git a/src/plots/polar/micropolar.js b/src/plots/polar/micropolar.js
index 0e2b5416047..f28af079454 100644
--- a/src/plots/polar/micropolar.js
+++ b/src/plots/polar/micropolar.js
@@ -6,9 +6,6 @@
* LICENSE file in the root directory of this source tree.
*/
-
-// jshint ignore: start
-
var Plotly = require('../../plotly');
var d3 = require('d3');
diff --git a/src/plots/polar/undo_manager.js b/src/plots/polar/undo_manager.js
index 31a07d62e42..2dc75b8f73b 100644
--- a/src/plots/polar/undo_manager.js
+++ b/src/plots/polar/undo_manager.js
@@ -6,9 +6,6 @@
* LICENSE file in the root directory of this source tree.
*/
-
-// jshint ignore: start
-
'use strict';
//Modified from https://github.com/ArthurClemens/Javascript-Undo-Manager
diff --git a/src/snapshot/cloneplot.js b/src/snapshot/cloneplot.js
index 139348443fa..7678bcdf602 100644
--- a/src/snapshot/cloneplot.js
+++ b/src/snapshot/cloneplot.js
@@ -15,36 +15,36 @@ var extendFlat = Plotly.Lib.extendFlat;
var extendDeep = Plotly.Lib.extendDeep;
// Put default plotTile layouts here
-function cloneLayoutOverride (tileClass) {
+function cloneLayoutOverride(tileClass) {
var override;
switch (tileClass) {
- case 'themes__thumb':
- override = {
- autosize: true,
- width: 150,
- height: 150,
- title: '',
- showlegend: false,
- margin: {l: 5, r: 5, t: 5, b: 5, pad: 0},
- annotations: []
- };
- break;
-
- case 'thumbnail':
- override = {
- title: '',
- hidesources: true,
- showlegend: false,
- borderwidth: 0,
- bordercolor: '',
- margin: {l: 1, r: 1, t: 1, b: 1, pad: 0},
- annotations: []
- };
- break;
-
- default:
- override = {};
+ case 'themes__thumb':
+ override = {
+ autosize: true,
+ width: 150,
+ height: 150,
+ title: '',
+ showlegend: false,
+ margin: {l: 5, r: 5, t: 5, b: 5, pad: 0},
+ annotations: []
+ };
+ break;
+
+ case 'thumbnail':
+ override = {
+ title: '',
+ hidesources: true,
+ showlegend: false,
+ borderwidth: 0,
+ bordercolor: '',
+ margin: {l: 1, r: 1, t: 1, b: 1, pad: 0},
+ annotations: []
+ };
+ break;
+
+ default:
+ override = {};
}
diff --git a/src/snapshot/svgtoimg.js b/src/snapshot/svgtoimg.js
index 190844d45dc..d2a055f6f0c 100644
--- a/src/snapshot/svgtoimg.js
+++ b/src/snapshot/svgtoimg.js
@@ -38,20 +38,20 @@ function svgToImg(opts) {
ctx.drawImage(img, 0, 0);
switch (format) {
- case 'jpeg':
- imgData = canvas.toDataURL('image/jpeg');
- break;
- case 'png':
- imgData = canvas.toDataURL('image/png');
- break;
- case 'webp':
- imgData = canvas.toDataURL('image/webp');
- break;
- case 'svg':
- imgData = svg;
- break;
- default:
- return ev.emit('error', 'Image format is not jpeg, png or svg');
+ case 'jpeg':
+ imgData = canvas.toDataURL('image/jpeg');
+ break;
+ case 'png':
+ imgData = canvas.toDataURL('image/png');
+ break;
+ case 'webp':
+ imgData = canvas.toDataURL('image/webp');
+ break;
+ case 'svg':
+ imgData = svg;
+ break;
+ default:
+ return ev.emit('error', 'Image format is not jpeg, png or svg');
}
ev.emit('success', imgData);
diff --git a/src/snapshot/toimage.js b/src/snapshot/toimage.js
index 899057d1e44..5184b60818d 100644
--- a/src/snapshot/toimage.js
+++ b/src/snapshot/toimage.js
@@ -6,8 +6,10 @@
* LICENSE file in the root directory of this source tree.
*/
+/*eslint dot-notation: [2, {"allowPattern": "^catch$"}]*/
'use strict';
+
var EventEmitter = require('events').EventEmitter;
var Plotly = require('../plotly');
@@ -30,10 +32,10 @@ function toImage(gd, opts) {
clonedGd.style.left = '-5000px';
document.body.appendChild(clonedGd);
- function wait () {
+ function wait() {
var delay = Snapshot.getDelay(clonedGd._fullLayout);
- setTimeout(function () {
+ setTimeout(function() {
var svg = Plotly.Snapshot.toSVG(clonedGd);
var canvasContainer = window.document.createElement('div');
@@ -69,7 +71,7 @@ function toImage(gd, opts) {
// out why and take it out.
.then(redrawFunc)
.then(wait)
- .catch( function (err) {
+ .catch(function(err) {
ev.emit('error', err);
});
diff --git a/src/snapshot/tosvg.js b/src/snapshot/tosvg.js
index d5b709ca7e8..bea6334e528 100644
--- a/src/snapshot/tosvg.js
+++ b/src/snapshot/tosvg.js
@@ -163,5 +163,5 @@ function insertGlImage(fullLayout, scene, opts) {
preserveAspectRatio: 'none'
});
- scene.destroy();
+ scene.destroy();
}
diff --git a/src/traces/bar/attributes.js b/src/traces/bar/attributes.js
index 4ee8bea10f8..2ec8848d351 100644
--- a/src/traces/bar/attributes.js
+++ b/src/traces/bar/attributes.js
@@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
var scatterAttrs = require('../scatter/attributes'),
scatterMarkerAttrs = scatterAttrs.marker,
diff --git a/src/traces/bar/index.js b/src/traces/bar/index.js
index fbd0dfaab85..3814fa265dd 100644
--- a/src/traces/bar/index.js
+++ b/src/traces/bar/index.js
@@ -13,14 +13,15 @@ var Plotly = require('../../plotly');
Plotly.Plots.register(exports, 'bar',
['cartesian', 'bar', 'oriented', 'markerColorscale', 'errorBarsOK', 'showLegend'], {
- description: [
- 'The data visualized by the span of the bars is set in `y`',
- 'if `orientation` is set th *v* (the default)',
- 'and the labels are set in `x`.',
-
- 'By setting `orientation` to *h*, the roles are interchanged.'
- ].join(' ')
-});
+ description: [
+ 'The data visualized by the span of the bars is set in `y`',
+ 'if `orientation` is set th *v* (the default)',
+ 'and the labels are set in `x`.',
+
+ 'By setting `orientation` to *h*, the roles are interchanged.'
+ ].join(' ')
+ }
+);
exports.attributes = require('./attributes');
diff --git a/src/traces/bar/layout_attributes.js b/src/traces/bar/layout_attributes.js
index 43ad2decc18..31f5f00b593 100644
--- a/src/traces/bar/layout_attributes.js
+++ b/src/traces/bar/layout_attributes.js
@@ -6,6 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
+
module.exports = {
barmode: {
diff --git a/src/traces/bar/set_positions.js b/src/traces/bar/set_positions.js
index 008bd9713d3..a8f3d05dc27 100644
--- a/src/traces/bar/set_positions.js
+++ b/src/traces/bar/set_positions.js
@@ -97,7 +97,7 @@ module.exports = function setPositions(gd, plotinfo) {
for(var i=0; i20) {
mi = CHOOSESADDLE[mi][(marchStep[0]||marchStep[1])<0 ? 0 : 1];
pi.crossings[locStr] = SADDLEREMAINDER[mi];
@@ -250,7 +251,7 @@ function makePath(pi, loc, edgeflag) {
locStr = loc.join(',');
// have we completed a loop, or reached an edge?
- if( (locStr===startLocStr && marchStep.join(',')===startStepStr) ||
+ if((locStr===startLocStr && marchStep.join(',')===startStepStr) ||
(edgeflag && (
(marchStep[0] && (loc[0]<0 || loc[0]>n-2)) ||
(marchStep[1] && (loc[1]<0 || loc[1]>m-2))))) {
@@ -319,7 +320,7 @@ function makePath(pi, loc, edgeflag) {
else if(ptcnt%2) newpt = getpt(ptavg);
// even # of pts - average central two
- else {
+ else {
newpt = [(getpt(ptavg)[0] + getpt(ptavg+1)[0]) / 2,
(getpt(ptavg)[1] + getpt(ptavg+1)[1]) / 2];
}
diff --git a/src/traces/heatmap/attributes.js b/src/traces/heatmap/attributes.js
index 1228ed3e076..32a224b81eb 100644
--- a/src/traces/heatmap/attributes.js
+++ b/src/traces/heatmap/attributes.js
@@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
var scatterAttrs = require('../scatter/attributes');
var colorscaleAttrs = require('../../components/colorscale/attributes');
diff --git a/src/traces/heatmap/calc.js b/src/traces/heatmap/calc.js
index a57c9f62b34..8fe58f0fd3d 100644
--- a/src/traces/heatmap/calc.js
+++ b/src/traces/heatmap/calc.js
@@ -97,7 +97,7 @@ module.exports = function calc(gd, trace) {
}
if(y.length && zsmooth === 'fast') {
var avgdy = (y[y.length-1]-y[0])/(y.length-1),
- maxErrY = Math.abs(avgdy/100);
+ maxErrY = Math.abs(avgdy/100);
for(i=0; imaxErrY) {
noZsmooth('y scale is not linear');
@@ -208,7 +208,7 @@ function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, ax) {
return isContour ?
arrayIn.slice(0, numbricks) : // we must be strict for contours
arrayIn.slice(0, numbricks + 1);
- }
+ }
}
else {
dv = dvIn || 1;
diff --git a/src/traces/heatmap/hover.js b/src/traces/heatmap/hover.js
index 4310d7bcd19..5999b0f58f7 100644
--- a/src/traces/heatmap/hover.js
+++ b/src/traces/heatmap/hover.js
@@ -31,6 +31,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, contour)
yl,
nx,
ny;
+
if(pointData.index!==false) {
try {
nx = Math.round(pointData.index[1]);
@@ -51,8 +52,10 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode, contour)
}
else {
if(contour) {
+ var i2;
x2 = [2*x[0]-x[1]];
- for(var i2=1; i2 0) {
- cells = alphaShape(data.alphahull, positions);
- } else {
- var d = ['x', 'y', 'z'].indexOf(data.delaunayaxis);
- cells = triangulate(positions.map(function(c) {
- return [c[(d+1)%3], c[(d+2)%3]];
- }));
+ cells = zip3(data.i, data.j, data.k);
+ }
+ else if(data.alphahull === 0) {
+ cells = convexHull(positions);
+ }
+ else if(data.alphahull > 0) {
+ cells = alphaShape(data.alphahull, positions);
+ }
+ else {
+ var d = ['x', 'y', 'z'].indexOf(data.delaunayaxis);
+ cells = triangulate(positions.map(function(c) {
+ return [c[(d+1)%3], c[(d+2)%3]];
+ }));
}
var config = {
@@ -117,18 +119,21 @@ proto.update = function(data) {
};
if(data.intensity) {
- this.color = '#fff';
- config.vertexIntensity = data.intensity;
- config.colormap = parseColorScale(data.colorscale);
- } else if(data.vertexColor) {
- this.color = data.vertexColor[0];
- config.vertexColors = parseColorArray(data.vertexColor);
- } else if(data.faceColor) {
- this.color = data.faceColor[0];
- config.cellColors = parseColorArray(data.faceColor);
- } else {
- this.color = data.color;
- config.meshColor = str2RgbaArray(data.color);
+ this.color = '#fff';
+ config.vertexIntensity = data.intensity;
+ config.colormap = parseColorScale(data.colorscale);
+ }
+ else if(data.vertexColor) {
+ this.color = data.vertexColor[0];
+ config.vertexColors = parseColorArray(data.vertexColor);
+ }
+ else if(data.faceColor) {
+ this.color = data.faceColor[0];
+ config.cellColors = parseColorArray(data.faceColor);
+ }
+ else {
+ this.color = data.color;
+ config.meshColor = str2RgbaArray(data.color);
}
//Update mesh
@@ -136,19 +141,17 @@ proto.update = function(data) {
};
proto.dispose = function() {
- this.glplot.remove(this.mesh);
- this.mesh.dispose();
+ this.glplot.remove(this.mesh);
+ this.mesh.dispose();
};
function createMesh3DTrace(scene, data) {
- var gl = scene.glplot.gl;
- var mesh = createMesh({
- gl: gl
- });
- var result = new Mesh3DTrace(scene, mesh, data.uid);
- result.update(data);
- scene.glplot.add(mesh);
- return result;
+ var gl = scene.glplot.gl;
+ var mesh = createMesh({gl: gl});
+ var result = new Mesh3DTrace(scene, mesh, data.uid);
+ result.update(data);
+ scene.glplot.add(mesh);
+ return result;
}
module.exports = createMesh3DTrace;
diff --git a/src/traces/mesh3d/defaults.js b/src/traces/mesh3d/defaults.js
index d0c4b6ef231..64060c2ae33 100644
--- a/src/traces/mesh3d/defaults.js
+++ b/src/traces/mesh3d/defaults.js
@@ -32,7 +32,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
}) && ret;
}
- var coords = readComponents(['x', 'y', 'z']);
+ var coords = readComponents(['x', 'y', 'z']);
var indices = readComponents(['i', 'j', 'k']);
if(!coords) {
@@ -43,9 +43,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout
if(indices) {
// otherwise, convert all face indices to ints
indices.forEach(function(index) {
- for(var i=0; i'),
- name: hoverinfo.indexOf('name') !== -1 ? trace2.name : undefined,
- color: pt.color,
- idealAlign: pt.pxmid[0] < 0 ? 'left' : 'right'
- },
- {
- container: fullLayout2._hoverlayer.node(),
- outerContainer: fullLayout2._paper.node()
- }
- );
+ x0: hoverCenterX - rInscribed * cd0.r,
+ x1: hoverCenterX + rInscribed * cd0.r,
+ y: hoverCenterY,
+ text: thisText.join('
'),
+ name: hoverinfo.indexOf('name') !== -1 ? trace2.name : undefined,
+ color: pt.color,
+ idealAlign: pt.pxmid[0] < 0 ? 'left' : 'right'
+ }, {
+ container: fullLayout2._hoverlayer.node(),
+ outerContainer: fullLayout2._paper.node()
+ });
Plotly.Fx.hover(gd, evt, 'pie');
@@ -135,7 +133,7 @@ module.exports = function plot(gd, cdpie) {
}
}
- function handleClick () {
+ function handleClick() {
gd._hoverdata = [pt];
gd._hoverdata.trace = cd.trace;
Plotly.Fx.click(gd, { target: true });
@@ -440,8 +438,8 @@ function scootLabels(quadrants, trace) {
thisQuadOutside,
firstOppositeOutsidePt;
- function topFirst (a, b) { return a.pxmid[1] - b.pxmid[1]; }
- function bottomFirst (a, b) { return b.pxmid[1] - a.pxmid[1]; }
+ function topFirst(a, b) { return a.pxmid[1] - b.pxmid[1]; }
+ function bottomFirst(a, b) { return b.pxmid[1] - a.pxmid[1]; }
function scootOneLabel(thisPt, prevPt) {
if(!prevPt) prevPt = {};
diff --git a/src/traces/scatter/attributes.js b/src/traces/scatter/attributes.js
index 99aeabb4e20..75f8c8d7c95 100644
--- a/src/traces/scatter/attributes.js
+++ b/src/traces/scatter/attributes.js
@@ -6,6 +6,8 @@
* LICENSE file in the root directory of this source tree.
*/
+'use strict';
+
var Drawing = require('../../components/drawing');
var PTS_LINESONLY = 20; // TODO put in constants/
diff --git a/src/traces/scatter/index.js b/src/traces/scatter/index.js
index 535d6aeced7..05ce0c5f8eb 100644
--- a/src/traces/scatter/index.js
+++ b/src/traces/scatter/index.js
@@ -27,14 +27,15 @@ scatter.selectPoints = require('./select');
Plotly.Plots.register(scatter, 'scatter',
['cartesian', 'symbols', 'markerColorscale', 'errorBarsOK', 'showLegend'], {
- description: [
- 'The scatter trace type encompasses line charts, scatter charts, text charts, and bubble charts.',
- 'The data visualized as scatter point or lines is set in `x` and `y`.',
- 'Text (appearing either on the chart or on hover only) is via `text`.',
- 'Bubble charts are achieved by setting `marker.size` and/or `marker.color`',
- 'to a numerical arrays.'
- ].join(' ')
-});
+ description: [
+ 'The scatter trace type encompasses line charts, scatter charts, text charts, and bubble charts.',
+ 'The data visualized as scatter point or lines is set in `x` and `y`.',
+ 'Text (appearing either on the chart or on hover only) is via `text`.',
+ 'Bubble charts are achieved by setting `marker.size` and/or `marker.color`',
+ 'to a numerical arrays.'
+ ].join(' ')
+ }
+);
// traces with < this many points are by default shown
// with points and lines, > just get lines
@@ -506,12 +507,13 @@ scatter.plot = function(gd, plotinfo, cdscatter) {
};
var segments = scatter.linePoints(d, {
- xaxis: xa,
- yaxis: ya,
- connectGaps: trace.connectgaps,
- baseTolerance: Math.max(line.width || 1, 3) / 4,
- linear: line.shape === 'linear'
- });
+ xaxis: xa,
+ yaxis: ya,
+ connectGaps: trace.connectgaps,
+ baseTolerance: Math.max(line.width || 1, 3) / 4,
+ linear: line.shape === 'linear'
+ });
+
if(segments.length) {
var pt0 = segments[0][0],
lastSegment = segments[segments.length - 1],
diff --git a/src/traces/scatter3d/convert.js b/src/traces/scatter3d/convert.js
index 3d6bd3d8b47..c0d33ef67b5 100644
--- a/src/traces/scatter3d/convert.js
+++ b/src/traces/scatter3d/convert.js
@@ -26,26 +26,26 @@ var MARKER_SYMBOLS = require('../../constants/gl_markers.json');
var calculateError = require('./calc_errors');
function LineWithMarkers(scene, uid) {
- this.scene = scene;
- this.uid = uid;
- this.linePlot = null;
- this.scatterPlot = null;
- this.errorBars = null;
- this.textMarkers = null;
- this.delaunayMesh = null;
- this.color = null;
- this.mode = '';
- this.dataPoints = [];
- this.axesBounds = [[-Infinity,-Infinity,-Infinity],
- [Infinity,Infinity,Infinity]];
- this.textLabels = null;
- this.data = null;
+ this.scene = scene;
+ this.uid = uid;
+ this.linePlot = null;
+ this.scatterPlot = null;
+ this.errorBars = null;
+ this.textMarkers = null;
+ this.delaunayMesh = null;
+ this.color = null;
+ this.mode = '';
+ this.dataPoints = [];
+ this.axesBounds = [[-Infinity,-Infinity,-Infinity],
+ [Infinity,Infinity,Infinity]];
+ this.textLabels = null;
+ this.data = null;
}
var proto = LineWithMarkers.prototype;
proto.handlePick = function(selection) {
- if( selection.object &&
+ if(selection.object &&
(selection.object === this.linePlot ||
selection.object === this.delaunayMesh ||
selection.object === this.textMarkers ||
@@ -64,9 +64,9 @@ proto.handlePick = function(selection) {
var selectIndex = selection.data.index;
selection.traceCoordinate = [
- this.data.x[selectIndex],
- this.data.y[selectIndex],
- this.data.z[selectIndex]
+ this.data.x[selectIndex],
+ this.data.y[selectIndex],
+ this.data.z[selectIndex]
];
return true;
@@ -77,7 +77,7 @@ function constructDelaunay(points, color, axis) {
var u = (axis+1)%3;
var v = (axis+2)%3;
var filteredPoints = [];
- var filteredIds = [];
+ var filteredIds = [];
var i;
for(i=0; itext'
+ mockCopy.data[0].text = [];
+ mockCopy.data[0].text[17] = 'hover
text';
mockCopy.data[0].hoverinfo = 'text';
beforeEach(function(done) {
@@ -237,8 +237,8 @@ describe('hover info', function() {
expect(d3.selectAll('g.axistext').size()).toEqual(0);
expect(d3.selectAll('g.hovertext').size()).toEqual(1);
- expect(d3.selectAll('g.hovertext').selectAll('tspan')[0][0].innerHTML).toEqual('hover')
- expect(d3.selectAll('g.hovertext').selectAll('tspan')[0][1].innerHTML).toEqual('text')
+ expect(d3.selectAll('g.hovertext').selectAll('tspan')[0][0].innerHTML).toEqual('hover');
+ expect(d3.selectAll('g.hovertext').selectAll('tspan')[0][1].innerHTML).toEqual('text');
expect(d3.selectAll('g.hovertext').select('text').selectAll('tspan').size()).toEqual(2);
});
});
diff --git a/test/jasmine/tests/hover_pie_test.js b/test/jasmine/tests/hover_pie_test.js
index cc52e8130e4..03ea75173d3 100644
--- a/test/jasmine/tests/hover_pie_test.js
+++ b/test/jasmine/tests/hover_pie_test.js
@@ -5,16 +5,16 @@ var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var mouseEvent = require('../assets/mouse_event');
-describe('pie hovering', function () {
+describe('pie hovering', function() {
var mock = require('@mocks/pie_simple.json');
- describe('event data', function () {
+ describe('event data', function() {
var mockCopy = Lib.extendDeep({}, mock),
width = mockCopy.layout.width,
height = mockCopy.layout.height,
gd;
- beforeEach(function (done) {
+ beforeEach(function(done) {
gd = createGraphDiv();
Plotly.plot(gd, mockCopy.data, mockCopy.layout)
@@ -23,54 +23,56 @@ describe('pie hovering', function () {
afterEach(destroyGraphDiv);
- it('should contain the correct fields', function () {
+ it('should contain the correct fields', function() {
- var expected = [{
- v: 4,
- label: '3',
- color: '#ff7f0e',
- i: 3,
- hidden: false,
- text: '26.7%',
- px1: [0,-60],
- pxmid: [-44.588689528643656,-40.14783638153149],
- midangle: -0.8377580409572781,
- px0: [-59.67131372209641,6.2717077960592],
- largeArc: 0,
- cxFinal: 200,
- cyFinal: 160
- }],
- futureData;
+ /*
+ * expected = [{
+ * v: 4,
+ * label: '3',
+ * color: '#ff7f0e',
+ * i: 3,
+ * hidden: false,
+ * text: '26.7%',
+ * px1: [0,-60],
+ * pxmid: [-44.588689528643656,-40.14783638153149],
+ * midangle: -0.8377580409572781,
+ * px0: [-59.67131372209641,6.2717077960592],
+ * largeArc: 0,
+ * cxFinal: 200,
+ * cyFinal: 160
+ * }];
+ */
+ var futureData;
- gd.on('plotly_hover', function (data) {
+ gd.on('plotly_hover', function(data) {
futureData = data;
});
mouseEvent('mouseover', width / 2, height / 2);
expect(futureData.points.length).toEqual(1);
expect(Object.keys(futureData.points[0])).toEqual([
- 'v', 'label', 'color', 'i', 'hidden',
- 'text', 'px1', 'pxmid', 'midangle',
- 'px0', 'largeArc', 'cxFinal', 'cyFinal'
- ]);
+ 'v', 'label', 'color', 'i', 'hidden',
+ 'text', 'px1', 'pxmid', 'midangle',
+ 'px0', 'largeArc', 'cxFinal', 'cyFinal'
+ ]);
expect(futureData.points[0].i).toEqual(3);
});
- it('should fire when moving from one slice to another', function (done) {
- var count = 0
+ it('should fire when moving from one slice to another', function(done) {
+ var count = 0,
futureData = [];
- gd.on('plotly_hover', function (data) {
+ gd.on('plotly_hover', function(data) {
count++;
futureData.push(data);
});
mouseEvent('mouseover', 180, 140);
- setTimeout(function () {
+ setTimeout(function() {
mouseEvent('mouseover', 240, 200);
expect(count).toEqual(2);
- expect(futureData[0]).not.toEqual(futureData[1])
+ expect(futureData[0]).not.toEqual(futureData[1]);
done();
}, 100);
});
diff --git a/test/jasmine/tests/is_plain_object_test.js b/test/jasmine/tests/is_plain_object_test.js
index 4ead19650cd..5ce1e634da9 100644
--- a/test/jasmine/tests/is_plain_object_test.js
+++ b/test/jasmine/tests/is_plain_object_test.js
@@ -34,13 +34,13 @@ describe('isPlainObject', function() {
];
shouldPass.forEach(function(obj) {
- it('treats ' + JSON.stringify(obj) + ' as a plain object', function () {
+ it('treats ' + JSON.stringify(obj) + ' as a plain object', function() {
expect(isPlainObject(obj)).toBe(true);
});
});
shouldFail.forEach(function(obj) {
- it('treats ' + JSON.stringify(obj!==window ? obj: 'window') + ' as NOT a plain object', function () {
+ it('treats ' + JSON.stringify(obj!==window ? obj: 'window') + ' as NOT a plain object', function() {
expect(isPlainObject(obj)).toBe(false);
});
});
diff --git a/test/jasmine/tests/legend_test.js b/test/jasmine/tests/legend_test.js
index 4cab38647de..a9514fbfc87 100644
--- a/test/jasmine/tests/legend_test.js
+++ b/test/jasmine/tests/legend_test.js
@@ -1,6 +1,6 @@
var Plotly = require('@src/plotly');
-describe('Test legend:', function () {
+describe('Test legend:', function() {
'use strict';
describe('supplyLayoutDefaults', function() {
diff --git a/test/jasmine/tests/lib_test.js b/test/jasmine/tests/lib_test.js
index adfa2b65c93..d5bb2c3b983 100644
--- a/test/jasmine/tests/lib_test.js
+++ b/test/jasmine/tests/lib_test.js
@@ -353,12 +353,12 @@ describe('Test lib.js:', function() {
it('should remove containers but not data arrays', function() {
var obj = {
- annotations: [{a: [1,2,3]}],
- c: [1,2,3],
- domain: [1,2],
- range: [2,3],
- shapes: ['elephant']
- },
+ annotations: [{a: [1,2,3]}],
+ c: [1,2,3],
+ domain: [1,2],
+ range: [2,3],
+ shapes: ['elephant']
+ },
propA = np(obj, 'annotations[-1].a'),
propC = np(obj, 'c'),
propD0 = np(obj, 'domain[0]'),
@@ -494,75 +494,74 @@ describe('Test lib.js:', function() {
});
});
- describe('coerce2', function() {
- var coerce2 = Plotly.Lib.coerce2,
- out;
-
- it('should set a value and return the value it sets when user input is valid', function() {
- var colVal = 'red',
- sizeVal = 14,
- attrs = {testMarker: {testColor: {valType: 'color', dflt: 'rgba(0, 0, 0, 0)'},
- testSize: {valType: 'number', dflt: 20}}},
- obj = {testMarker: {testColor: colVal, testSize: sizeVal}},
- outObj = {},
- colOut = coerce2(obj, outObj, attrs, 'testMarker.testColor'),
- sizeOut = coerce2(obj, outObj, attrs, 'testMarker.testSize');
+ describe('coerce2', function() {
+ var coerce2 = Plotly.Lib.coerce2;
- expect(colOut).toBe(colVal);
- expect(colOut).toBe(outObj.testMarker.testColor);
- expect(sizeOut).toBe(sizeVal);
- expect(sizeOut).toBe(outObj.testMarker.testSize);
- });
+ it('should set a value and return the value it sets when user input is valid', function() {
+ var colVal = 'red',
+ sizeVal = 14,
+ attrs = {testMarker: {testColor: {valType: 'color', dflt: 'rgba(0, 0, 0, 0)'},
+ testSize: {valType: 'number', dflt: 20}}},
+ obj = {testMarker: {testColor: colVal, testSize: sizeVal}},
+ outObj = {},
+ colOut = coerce2(obj, outObj, attrs, 'testMarker.testColor'),
+ sizeOut = coerce2(obj, outObj, attrs, 'testMarker.testSize');
- it('should set and return the default if the user input is not valid', function() {
- var colVal = 'r',
- sizeVal = 'aaaaah!',
- attrs = {testMarker: {testColor: {valType: 'color', dflt: 'rgba(0, 0, 0, 0)'},
- testSize: {valType: 'number', dflt: 20}}},
- obj = {testMarker: {testColor: colVal, testSize: sizeVal}},
- outObj = {},
- colOut = coerce2(obj, outObj, attrs, 'testMarker.testColor'),
- sizeOut = coerce2(obj, outObj, attrs, 'testMarker.testSize');
-
- expect(colOut).toBe('rgba(0, 0, 0, 0)');
- expect(sizeOut).toBe(outObj.testMarker.testSize);
- expect(sizeOut).toBe(20);
- expect(sizeOut).toBe(outObj.testMarker.testSize);
- });
+ expect(colOut).toBe(colVal);
+ expect(colOut).toBe(outObj.testMarker.testColor);
+ expect(sizeOut).toBe(sizeVal);
+ expect(sizeOut).toBe(outObj.testMarker.testSize);
+ });
- it('should return false if there is no user input', function() {
- var colVal = null,
- sizeVal = null,
- attrs = {testMarker: {testColor: {valType: 'color', dflt: 'rgba(0, 0, 0, 0)'},
- testSize: {valType: 'number', dflt: 20}}},
- obj = {testMarker: {testColor: colVal, testSize: sizeVal}},
- outObj = {},
- colOut = coerce2(obj, outObj, attrs, 'testMarker.testColor'),
- sizeOut = coerce2(obj, outObj, attrs, 'testMarker.testSize');
+ it('should set and return the default if the user input is not valid', function() {
+ var colVal = 'r',
+ sizeVal = 'aaaaah!',
+ attrs = {testMarker: {testColor: {valType: 'color', dflt: 'rgba(0, 0, 0, 0)'},
+ testSize: {valType: 'number', dflt: 20}}},
+ obj = {testMarker: {testColor: colVal, testSize: sizeVal}},
+ outObj = {},
+ colOut = coerce2(obj, outObj, attrs, 'testMarker.testColor'),
+ sizeOut = coerce2(obj, outObj, attrs, 'testMarker.testSize');
+
+ expect(colOut).toBe('rgba(0, 0, 0, 0)');
+ expect(sizeOut).toBe(outObj.testMarker.testSize);
+ expect(sizeOut).toBe(20);
+ expect(sizeOut).toBe(outObj.testMarker.testSize);
+ });
- expect(colOut).toBe(false);
- expect(sizeOut).toBe(false);
+ it('should return false if there is no user input', function() {
+ var colVal = null,
+ sizeVal = null,
+ attrs = {testMarker: {testColor: {valType: 'color', dflt: 'rgba(0, 0, 0, 0)'},
+ testSize: {valType: 'number', dflt: 20}}},
+ obj = {testMarker: {testColor: colVal, testSize: sizeVal}},
+ outObj = {},
+ colOut = coerce2(obj, outObj, attrs, 'testMarker.testColor'),
+ sizeOut = coerce2(obj, outObj, attrs, 'testMarker.testSize');
+
+ expect(colOut).toBe(false);
+ expect(sizeOut).toBe(false);
+ });
});
- });
describe('info_array valType', function() {
var infoArrayAttrs = {
- range: {
- valType: 'info_array',
- items: [
- { valType: 'number' },
- { valType: 'number' }
- ]
- },
- domain: {
- valType: 'info_array',
- items: [
- { valType: 'number', min: 0, max: 1 },
- { valType: 'number', min: 0, max: 1 }
- ],
- dflt: [0, 1]
- }
- };
+ range: {
+ valType: 'info_array',
+ items: [
+ { valType: 'number' },
+ { valType: 'number' }
+ ]
+ },
+ domain: {
+ valType: 'info_array',
+ items: [
+ { valType: 'number', min: 0, max: 1 },
+ { valType: 'number', min: 0, max: 1 }
+ ],
+ dflt: [0, 1]
+ }
+ };
it('should insert the default if input is missing', function() {
expect(coerce(undefined, {}, infoArrayAttrs, 'domain'))
@@ -599,6 +598,7 @@ describe('Test lib.js:', function() {
size: 314159,
color: 'neon pink with sparkles'
};
+
var attributes = {
fontWithDefault: {
family: extendFlat({}, fontAttrs.family, {dflt: defaultFont.family}),
@@ -607,13 +607,13 @@ describe('Test lib.js:', function() {
},
fontNoDefault: fontAttrs
};
-
+
+ var containerIn;
+
function coerce(attr, dflt) {
return Plotly.Lib.coerce(containerIn, {}, attributes, attr, dflt);
}
- var containerIn;
-
it('should insert the full default if no or empty input', function() {
containerIn = undefined;
expect(coerceFont(coerce, 'fontWithDefault'))
diff --git a/test/jasmine/tests/plot_api_test.js b/test/jasmine/tests/plot_api_test.js
index 7aa4a76197c..698304c93ca 100644
--- a/test/jasmine/tests/plot_api_test.js
+++ b/test/jasmine/tests/plot_api_test.js
@@ -1,6 +1,6 @@
var Plotly = require('@src/plotly');
-describe('Test graph_obj', function () {
+describe('Test graph_obj', function() {
'use strict';
describe('Plotly.restyle', function() {
@@ -51,10 +51,10 @@ describe('Test graph_obj', function () {
});
- describe('Plotly.deleteTraces', function () {
+ describe('Plotly.deleteTraces', function() {
var gd;
- beforeEach(function () {
+ beforeEach(function() {
gd = {
data: [
{'name': 'a'},
@@ -66,31 +66,31 @@ describe('Test graph_obj', function () {
spyOn(Plotly, 'redraw');
});
- it('should throw an error when indices are omitted', function () {
+ it('should throw an error when indices are omitted', function() {
- expect(function () {
+ expect(function() {
Plotly.deleteTraces(gd);
}).toThrow(new Error('indices must be an integer or array of integers.'));
});
- it('should throw an error when indices are out of bounds', function () {
+ it('should throw an error when indices are out of bounds', function() {
- expect(function () {
+ expect(function() {
Plotly.deleteTraces(gd, 10);
}).toThrow(new Error('indices must be valid indices for gd.data.'));
});
- it('should throw an error when indices are repeated', function () {
+ it('should throw an error when indices are repeated', function() {
- expect(function () {
+ expect(function() {
Plotly.deleteTraces(gd, [0, 0]);
}).toThrow(new Error('each index in indices must be unique.'));
});
- it('should work when indices are negative', function () {
+ it('should work when indices are negative', function() {
var expectedData = [
{'name': 'a'},
{'name': 'b'},
@@ -103,7 +103,7 @@ describe('Test graph_obj', function () {
});
- it('should work when multiple traces are deleted', function () {
+ it('should work when multiple traces are deleted', function() {
var expectedData = [
{'name': 'b'},
{'name': 'c'}
@@ -115,7 +115,7 @@ describe('Test graph_obj', function () {
});
- it('should work when indices are not sorted', function () {
+ it('should work when indices are not sorted', function() {
var expectedData = [
{'name': 'b'},
{'name': 'c'}
@@ -129,26 +129,26 @@ describe('Test graph_obj', function () {
});
- describe('Plotly.addTraces', function () {
+ describe('Plotly.addTraces', function() {
var gd;
- beforeEach(function () {
+ beforeEach(function() {
gd = { data: [{'name': 'a'}, {'name': 'b'}] };
spyOn(Plotly, 'redraw');
spyOn(Plotly, 'moveTraces');
});
- it('should throw an error when traces is not an object or an array of objects', function () {
+ it('should throw an error when traces is not an object or an array of objects', function() {
var expected = JSON.parse(JSON.stringify(gd));
- expect(function () {
+ expect(function() {
Plotly.addTraces(gd, 1, 2);
}).toThrowError(Error, 'all values in traces array must be non-array objects');
- expect(function () {
+ expect(function() {
Plotly.addTraces(gd, [{}, 4], 2);
}).toThrowError(Error, 'all values in traces array must be non-array objects');
- expect(function () {
+ expect(function() {
Plotly.addTraces(gd, [{}, []], 2);
}).toThrowError(Error, 'all values in traces array must be non-array objects');
@@ -157,18 +157,18 @@ describe('Test graph_obj', function () {
});
- it('should throw an error when traces and newIndices arrays are unequal', function () {
+ it('should throw an error when traces and newIndices arrays are unequal', function() {
- expect(function () {
+ expect(function() {
Plotly.addTraces(gd, [{}, {}], 2);
}).toThrowError(Error, 'if indices is specified, traces.length must equal indices.length');
});
- it('should throw an error when newIndices are out of bounds', function () {
+ it('should throw an error when newIndices are out of bounds', function() {
var expected = JSON.parse(JSON.stringify(gd));
- expect(function () {
+ expect(function() {
Plotly.addTraces(gd, [{}, {}], [0, 10]);
}).toThrow(new Error('newIndices must be valid indices for gd.data.'));
@@ -176,7 +176,7 @@ describe('Test graph_obj', function () {
expect(gd).toEqual(expected);
});
- it('should work when newIndices is undefined', function () {
+ it('should work when newIndices is undefined', function() {
Plotly.addTraces(gd, [{'name': 'c'}, {'name': 'd'}]);
expect(gd.data[2].name).toBeDefined();
expect(gd.data[2].uid).toBeDefined();
@@ -186,7 +186,7 @@ describe('Test graph_obj', function () {
expect(Plotly.moveTraces).not.toHaveBeenCalled();
});
- it('should work when newIndices is defined', function () {
+ it('should work when newIndices is defined', function() {
Plotly.addTraces(gd, [{'name': 'c'}, {'name': 'd'}], [1, 3]);
expect(gd.data[2].name).toBeDefined();
expect(gd.data[2].uid).toBeDefined();
@@ -197,7 +197,7 @@ describe('Test graph_obj', function () {
});
- it('should work when newIndices has negative indices', function () {
+ it('should work when newIndices has negative indices', function() {
Plotly.addTraces(gd, [{'name': 'c'}, {'name': 'd'}], [-3, -1]);
expect(gd.data[2].name).toBeDefined();
expect(gd.data[2].uid).toBeDefined();
@@ -208,7 +208,7 @@ describe('Test graph_obj', function () {
});
- it('should work when newIndices is an integer', function () {
+ it('should work when newIndices is an integer', function() {
Plotly.addTraces(gd, {'name': 'c'}, 0);
expect(gd.data[2].name).toBeDefined();
expect(gd.data[2].uid).toBeDefined();
@@ -220,7 +220,7 @@ describe('Test graph_obj', function () {
describe('Plotly.moveTraces should', function() {
var gd;
- beforeEach(function () {
+ beforeEach(function() {
gd = {
data: [
{'name': 'a'},
@@ -232,62 +232,62 @@ describe('Test graph_obj', function () {
spyOn(Plotly, 'redraw');
});
- it('throw an error when index arrays are unequal', function () {
- expect(function () {
+ it('throw an error when index arrays are unequal', function() {
+ expect(function() {
Plotly.moveTraces(gd, [1], [2, 1]);
}).toThrow(new Error('current and new indices must be of equal length.'));
});
- it('throw an error when gd.data isn\'t an array.', function () {
- expect(function () {
+ it('throw an error when gd.data isn\'t an array.', function() {
+ expect(function() {
Plotly.moveTraces({}, [0], [0]);
}).toThrow(new Error('gd.data must be an array.'));
- expect(function () {
+ expect(function() {
Plotly.moveTraces({data: 'meow'}, [0], [0]);
}).toThrow(new Error('gd.data must be an array.'));
});
- it('thow an error when a current index is out of bounds', function () {
- expect(function () {
+ it('thow an error when a current index is out of bounds', function() {
+ expect(function() {
Plotly.moveTraces(gd, [-gd.data.length - 1], [0]);
}).toThrow(new Error('currentIndices must be valid indices for gd.data.'));
- expect(function () {
+ expect(function() {
Plotly.moveTraces(gd, [gd.data.length], [0]);
}).toThrow(new Error('currentIndices must be valid indices for gd.data.'));
});
- it('thow an error when a new index is out of bounds', function () {
- expect(function () {
+ it('thow an error when a new index is out of bounds', function() {
+ expect(function() {
Plotly.moveTraces(gd, [0], [-gd.data.length - 1]);
}).toThrow(new Error('newIndices must be valid indices for gd.data.'));
- expect(function () {
+ expect(function() {
Plotly.moveTraces(gd, [0], [gd.data.length]);
}).toThrow(new Error('newIndices must be valid indices for gd.data.'));
});
- it('thow an error when current indices are repeated', function () {
- expect(function () {
+ it('thow an error when current indices are repeated', function() {
+ expect(function() {
Plotly.moveTraces(gd, [0, 0], [0, 1]);
}).toThrow(new Error('each index in currentIndices must be unique.'));
// note that both positive and negative indices are accepted!
- expect(function () {
+ expect(function() {
Plotly.moveTraces(gd, [0, -gd.data.length], [0, 1]);
}).toThrow(new Error('each index in currentIndices must be unique.'));
});
- it('thow an error when new indices are repeated', function () {
- expect(function () {
+ it('thow an error when new indices are repeated', function() {
+ expect(function() {
Plotly.moveTraces(gd, [0, 1], [0, 0]);
}).toThrow(new Error('each index in newIndices must be unique.'));
// note that both positive and negative indices are accepted!
- expect(function () {
+ expect(function() {
Plotly.moveTraces(gd, [0, 1], [-gd.data.length, 0]);
}).toThrow(new Error('each index in newIndices must be unique.'));
});
- it('accept integers in place of arrays', function () {
+ it('accept integers in place of arrays', function() {
var expectedData = [
{'name': 'b'},
{'name': 'a'},
@@ -301,7 +301,7 @@ describe('Test graph_obj', function () {
});
- it('handle unsorted currentIndices', function () {
+ it('handle unsorted currentIndices', function() {
var expectedData = [
{'name': 'd'},
{'name': 'a'},
@@ -315,7 +315,7 @@ describe('Test graph_obj', function () {
});
- it('work when newIndices are undefined.', function () {
+ it('work when newIndices are undefined.', function() {
var expectedData = [
{'name': 'b'},
{'name': 'c'},
@@ -329,7 +329,7 @@ describe('Test graph_obj', function () {
});
- it('accept negative indices.', function () {
+ it('accept negative indices.', function() {
var expectedData = [
{'name': 'a'},
{'name': 'c'},
@@ -347,7 +347,7 @@ describe('Test graph_obj', function () {
describe('Plotly.ExtendTraces', function() {
var gd;
- beforeEach(function () {
+ beforeEach(function() {
gd = {
data: [
{x: [0,1,2], marker: {size: [3,2,1]}},
@@ -357,9 +357,9 @@ describe('Test graph_obj', function () {
if (!Plotly.Queue) {
Plotly.Queue = {
- add: function () {},
- startSequence: function () {},
- endSequence: function () {}
+ add: function() {},
+ startSequence: function() {},
+ endSequence: function() {}
};
}
@@ -367,87 +367,87 @@ describe('Test graph_obj', function () {
spyOn(Plotly.Queue, 'add');
});
- it('should throw an error when gd.data isn\'t an array.', function () {
+ it('should throw an error when gd.data isn\'t an array.', function() {
- expect(function () {
+ expect(function() {
Plotly.extendTraces({}, {x: [[1]]}, [0]);
}).toThrow(new Error('gd.data must be an array'));
- expect(function () {
+ expect(function() {
Plotly.extendTraces({data: 'meow'}, {x: [[1]]}, [0]);
}).toThrow(new Error('gd.data must be an array'));
});
- it('should throw an error when update is not an object', function () {
+ it('should throw an error when update is not an object', function() {
- expect(function () {
+ expect(function() {
Plotly.extendTraces(gd, undefined, [0], 8);
}).toThrow(new Error('update must be a key:value object'));
- expect(function () {
+ expect(function() {
Plotly.extendTraces(gd, null, [0]);
}).toThrow(new Error('update must be a key:value object'));
});
- it('should throw an error when indices are omitted', function () {
+ it('should throw an error when indices are omitted', function() {
- expect(function () {
+ expect(function() {
Plotly.extendTraces(gd, {x: [[1]]});
}).toThrow(new Error('indices must be an integer or array of integers'));
});
- it('should thow an error when a current index is out of bounds', function () {
+ it('should throw an error when a current index is out of bounds', function() {
- expect(function () {
+ expect(function() {
Plotly.extendTraces(gd, {x: [[1]]}, [-gd.data.length - 1]);
}).toThrow(new Error('indices must be valid indices for gd.data.'));
});
- it('should not thow an error when negative index wraps to positive', function () {
+ it('should not throw an error when negative index wraps to positive', function() {
- expect(function () {
+ expect(function() {
Plotly.extendTraces(gd, {x: [[1]]}, [-1]);
}).not.toThrow();
});
- it('should thow an error when number of Indices does not match Update arrays', function () {
+ it('should throw an error when number of Indices does not match Update arrays', function() {
- expect(function () {
+ expect(function() {
Plotly.extendTraces(gd, {x: [[1, 2], [2, 3]] }, [0]);
}).toThrow(new Error('attribute x must be an array of length equal to indices array length'));
- expect(function () {
+ expect(function() {
Plotly.extendTraces(gd, {x: [[1]]}, [0, 1]);
}).toThrow(new Error('attribute x must be an array of length equal to indices array length'));
});
- it('should thow an error when maxPoints is an Object but does not match Update', function () {
+ it('should throw an error when maxPoints is an Object but does not match Update', function() {
- expect(function () {
+ expect(function() {
Plotly.extendTraces(gd, {x: [[1]]}, [0], {y: [1]});
}).toThrow(new Error('when maxPoints is set as a key:value object it must contain a 1:1 ' +
'corrispondence with the keys and number of traces in the update object'));
- expect(function () {
+ expect(function() {
Plotly.extendTraces(gd, {x: [[1]]}, [0], {x: [1, 2]});
}).toThrow(new Error('when maxPoints is set as a key:value object it must contain a 1:1 ' +
'corrispondence with the keys and number of traces in the update object'));
});
- it('should throw an error when update keys mismatch trace keys', function () {
+ it('should throw an error when update keys mismatch trace keys', function() {
// lets update y on both traces, but only 1 trace has "y"
gd.data[1].y = [1,2,3];
- expect(function () {
+ expect(function() {
Plotly.extendTraces(gd, {
y: [[3, 4], [4, 5]], 'marker.size': [[0, -1], [5, 6]]
}, [0, 1]);
@@ -455,7 +455,7 @@ describe('Test graph_obj', function () {
});
- it('should extend traces with update keys', function () {
+ it('should extend traces with update keys', function() {
Plotly.extendTraces(gd, {
x: [[3, 4], [4, 5]], 'marker.size': [[0, -1], [5, 6]]
@@ -469,7 +469,7 @@ describe('Test graph_obj', function () {
expect(Plotly.redraw).toHaveBeenCalled();
});
- it('should extend and window traces with update keys', function () {
+ it('should extend and window traces with update keys', function() {
var maxPoints = 3;
Plotly.extendTraces(gd, {
@@ -482,7 +482,7 @@ describe('Test graph_obj', function () {
]);
});
- it('should extend and window traces with update keys', function () {
+ it('should extend and window traces with update keys', function() {
var maxPoints = 3;
Plotly.extendTraces(gd, {
@@ -495,7 +495,7 @@ describe('Test graph_obj', function () {
]);
});
- it('should extend and window traces using full maxPoint object', function () {
+ it('should extend and window traces using full maxPoint object', function() {
var maxPoints = {x: [2, 3], 'marker.size': [1, 2]};
Plotly.extendTraces(gd, {
@@ -508,7 +508,7 @@ describe('Test graph_obj', function () {
]);
});
- it('should truncate arrays when maxPoints is zero', function () {
+ it('should truncate arrays when maxPoints is zero', function() {
Plotly.extendTraces(gd, {
x: [[3, 4], [4, 5]], 'marker.size': [[0, -1], [5, 6]]
@@ -522,7 +522,7 @@ describe('Test graph_obj', function () {
expect(Plotly.redraw).toHaveBeenCalled();
});
- it('prepend is the inverse of extend - no maxPoints', function () {
+ it('prepend is the inverse of extend - no maxPoints', function() {
var cachedData = Plotly.Lib.extendDeep([], gd.data);
Plotly.extendTraces(gd, {
@@ -540,7 +540,7 @@ describe('Test graph_obj', function () {
});
- it('extend is the inverse of prepend - no maxPoints', function () {
+ it('extend is the inverse of prepend - no maxPoints', function() {
var cachedData = Plotly.Lib.extendDeep([], gd.data);
Plotly.prependTraces(gd, {
@@ -558,7 +558,7 @@ describe('Test graph_obj', function () {
});
- it('prepend is the inverse of extend - with maxPoints', function () {
+ it('prepend is the inverse of extend - with maxPoints', function() {
var maxPoints = 3;
var cachedData = Plotly.Lib.extendDeep([], gd.data);
diff --git a/test/jasmine/tests/plot_interact_test.js b/test/jasmine/tests/plot_interact_test.js
index 80ed3a1918d..bdf46fafbd7 100644
--- a/test/jasmine/tests/plot_interact_test.js
+++ b/test/jasmine/tests/plot_interact_test.js
@@ -1,13 +1,12 @@
var d3 = require('d3');
var Plotly = require('@src/index');
-var Fx = require('@src/plots/cartesian/graph_interact');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
-describe('Test plot structure', function () {
+describe('Test plot structure', function() {
'use strict';
afterEach(destroyGraphDiv);
diff --git a/test/jasmine/tests/plot_promise_test.js b/test/jasmine/tests/plot_promise_test.js
index a25dbaf0914..b42af7044db 100644
--- a/test/jasmine/tests/plot_promise_test.js
+++ b/test/jasmine/tests/plot_promise_test.js
@@ -2,17 +2,16 @@ var Plotly = require('@src/plotly');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
-describe('Plotly.___ methods', function () {
+describe('Plotly.___ methods', function() {
'use strict';
-
- describe('Plotly.plot promise', function () {
+
+ describe('Plotly.plot promise', function() {
var promise,
promiseGd;
- beforeEach(function (done) {
+ beforeEach(function(done) {
+ var data = [{ x: [1,2,3], y: [4,5,6] }];
- var data = [{ x: [1,2,3], y: [4,5,6] }],
-
promise = Plotly.plot(createGraphDiv(), data, {});
promise.then(function(gd){
@@ -22,7 +21,7 @@ describe('Plotly.___ methods', function () {
});
afterEach(destroyGraphDiv);
- it('should be returned with the graph div as an argument', function () {
+ it('should be returned with the graph div as an argument', function() {
expect(promiseGd).toBeDefined();
expect(typeof promiseGd).toBe('object');
expect(promiseGd.data).toBeDefined();
@@ -30,16 +29,16 @@ describe('Plotly.___ methods', function () {
});
});
- describe('Plotly.redraw promise', function () {
+ describe('Plotly.redraw promise', function() {
var promise,
promiseGd;
- beforeEach(function (done) {
+ beforeEach(function(done) {
var data = [{ x: [1,2,3], y: [4,5,6] }],
initialDiv = createGraphDiv();
-
+
Plotly.plot(initialDiv, data, {});
-
+
promise = Plotly.redraw(initialDiv);
promise.then(function(gd){
@@ -49,7 +48,7 @@ describe('Plotly.___ methods', function () {
});
afterEach(destroyGraphDiv);
- it('should be returned with the graph div as an argument', function () {
+ it('should be returned with the graph div as an argument', function() {
expect(promiseGd).toBeDefined();
expect(typeof promiseGd).toBe('object');
expect(promiseGd.data).toBeDefined();
@@ -57,13 +56,13 @@ describe('Plotly.___ methods', function () {
});
});
- describe('Plotly.newPlot promise', function () {
+ describe('Plotly.newPlot promise', function() {
var promise,
promiseGd;
- beforeEach(function (done) {
- var data = [{ x: [1,2,3], y: [4,5,6] }],
-
+ beforeEach(function(done) {
+ var data = [{ x: [1,2,3], y: [4,5,6] }];
+
promise = Plotly.newPlot(createGraphDiv(), data, {});
promise.then(function(gd){
@@ -73,7 +72,7 @@ describe('Plotly.___ methods', function () {
});
afterEach(destroyGraphDiv);
- it('should be returned with the graph div as an argument', function () {
+ it('should be returned with the graph div as an argument', function() {
expect(promiseGd).toBeDefined();
expect(typeof promiseGd).toBe('object');
expect(promiseGd.data).toBeDefined();
@@ -81,16 +80,16 @@ describe('Plotly.___ methods', function () {
});
});
- describe('Plotly.extendTraces promise', function () {
+ describe('Plotly.extendTraces promise', function() {
var promise,
promiseGd;
- beforeEach(function (done) {
+ beforeEach(function(done) {
var data = [{ x: [1,2,3], y: [4,5,6] }],
initialDiv = createGraphDiv();
-
+
Plotly.plot(initialDiv, data, {});
-
+
promise = Plotly.extendTraces(initialDiv, { y: [[2]] }, [0], 3);
promise.then(function(gd){
@@ -100,7 +99,7 @@ describe('Plotly.___ methods', function () {
});
afterEach(destroyGraphDiv);
- it('should be returned with the graph div as an argument', function () {
+ it('should be returned with the graph div as an argument', function() {
expect(promiseGd).toBeDefined();
expect(typeof promiseGd).toBe('object');
expect(promiseGd.data).toBeDefined();
@@ -108,16 +107,16 @@ describe('Plotly.___ methods', function () {
});
});
- describe('Plotly.prependTraces promise', function () {
+ describe('Plotly.prependTraces promise', function() {
var promise,
promiseGd;
- beforeEach(function (done) {
+ beforeEach(function(done) {
var data = [{ x: [1,2,3], y: [4,5,6] }],
initialDiv = createGraphDiv();
-
+
Plotly.plot(initialDiv, data, {});
-
+
promise = Plotly.prependTraces(initialDiv, { y: [[2]] }, [0], 3);
promise.then(function(gd){
@@ -127,7 +126,7 @@ describe('Plotly.___ methods', function () {
});
afterEach(destroyGraphDiv);
- it('should be returned with the graph div as an argument', function () {
+ it('should be returned with the graph div as an argument', function() {
expect(promiseGd).toBeDefined();
expect(typeof promiseGd).toBe('object');
expect(promiseGd.data).toBeDefined();
@@ -135,16 +134,16 @@ describe('Plotly.___ methods', function () {
});
});
- describe('Plotly.addTraces promise', function () {
+ describe('Plotly.addTraces promise', function() {
var promise,
promiseGd;
- beforeEach(function (done) {
+ beforeEach(function(done) {
var data = [{ x: [1,2,3], y: [4,5,6] }],
initialDiv = createGraphDiv();
-
+
Plotly.plot(initialDiv, data, {});
-
+
promise = Plotly.addTraces(initialDiv, [{ x: [1,2,3], y: [1,2,3] }], [1]);
promise.then(function(gd){
@@ -154,7 +153,7 @@ describe('Plotly.___ methods', function () {
});
afterEach(destroyGraphDiv);
- it('should be returned with the graph div as an argument', function () {
+ it('should be returned with the graph div as an argument', function() {
expect(promiseGd).toBeDefined();
expect(typeof promiseGd).toBe('object');
expect(promiseGd.data).toBeDefined();
@@ -162,16 +161,16 @@ describe('Plotly.___ methods', function () {
});
});
- describe('Plotly.deleteTraces promise', function () {
+ describe('Plotly.deleteTraces promise', function() {
var promise,
promiseGd;
- beforeEach(function (done) {
+ beforeEach(function(done) {
var data = [{ x: [1,2,3], y: [4,5,6] }],
initialDiv = createGraphDiv();
-
+
Plotly.plot(initialDiv, data, {});
-
+
promise = Plotly.deleteTraces(initialDiv, [0]);
promise.then(function(gd){
@@ -181,7 +180,7 @@ describe('Plotly.___ methods', function () {
});
afterEach(destroyGraphDiv);
- it('should be returned with the graph div as an argument', function () {
+ it('should be returned with the graph div as an argument', function() {
expect(promiseGd).toBeDefined();
expect(typeof promiseGd).toBe('object');
expect(promiseGd.data).toBeDefined();
@@ -189,16 +188,16 @@ describe('Plotly.___ methods', function () {
});
});
- describe('Plotly.deleteTraces promise', function () {
+ describe('Plotly.deleteTraces promise', function() {
var promise,
promiseGd;
- beforeEach(function (done) {
+ beforeEach(function(done) {
var data = [{ x: [1,2,3], y: [4,5,6] }],
initialDiv = createGraphDiv();
-
+
Plotly.plot(initialDiv, data, {});
-
+
promise = Plotly.deleteTraces(initialDiv, [0]);
promise.then(function(gd){
@@ -208,7 +207,7 @@ describe('Plotly.___ methods', function () {
});
afterEach(destroyGraphDiv);
- it('should be returned with the graph div as an argument', function () {
+ it('should be returned with the graph div as an argument', function() {
expect(promiseGd).toBeDefined();
expect(typeof promiseGd).toBe('object');
expect(promiseGd.data).toBeDefined();
@@ -216,19 +215,19 @@ describe('Plotly.___ methods', function () {
});
});
- describe('Plotly.moveTraces promise', function () {
+ describe('Plotly.moveTraces promise', function() {
var promise,
promiseGd;
- beforeEach(function (done) {
+ beforeEach(function(done) {
var data = [
{ x: [1,2,3], y: [4,5,6] },
{ x: [1,2,3], y: [6,5,4] }
],
initialDiv = createGraphDiv();
-
+
Plotly.plot(initialDiv, data, {});
-
+
promise = Plotly.moveTraces(initialDiv, 0, 1);
promise.then(function(gd){
@@ -238,7 +237,7 @@ describe('Plotly.___ methods', function () {
});
afterEach(destroyGraphDiv);
- it('should be returned with the graph div as an argument', function () {
+ it('should be returned with the graph div as an argument', function() {
expect(promiseGd).toBeDefined();
expect(typeof promiseGd).toBe('object');
expect(promiseGd.data).toBeDefined();
@@ -246,16 +245,16 @@ describe('Plotly.___ methods', function () {
});
});
- describe('Plotly.restyle promise', function () {
+ describe('Plotly.restyle promise', function() {
var promise,
promiseGd;
- beforeEach(function (done) {
+ beforeEach(function(done) {
var data = [{ x: [1,2,3], y: [4,5,6] }],
initialDiv = createGraphDiv();
-
+
Plotly.plot(initialDiv, data, {});
-
+
promise = Plotly.restyle(initialDiv, 'marker.color', 'rgb(255,0,0)');
promise.then(function(gd){
@@ -265,7 +264,7 @@ describe('Plotly.___ methods', function () {
});
afterEach(destroyGraphDiv);
- it('should be returned with the graph div as an argument', function () {
+ it('should be returned with the graph div as an argument', function() {
expect(promiseGd).toBeDefined();
expect(typeof promiseGd).toBe('object');
expect(promiseGd.data).toBeDefined();
@@ -273,16 +272,16 @@ describe('Plotly.___ methods', function () {
});
});
- describe('Plotly.relayout promise', function () {
+ describe('Plotly.relayout promise', function() {
var promise,
promiseGd;
- beforeEach(function (done) {
+ beforeEach(function(done) {
var data = [{ x: [1,2,3], y: [4,5,6] }],
initialDiv = createGraphDiv();
-
+
Plotly.plot(initialDiv, data, {});
-
+
promise = Plotly.restyle(initialDiv, 'title', 'Promise test!');
promise.then(function(gd){
@@ -292,7 +291,7 @@ describe('Plotly.___ methods', function () {
});
afterEach(destroyGraphDiv);
- it('should be returned with the graph div as an argument', function () {
+ it('should be returned with the graph div as an argument', function() {
expect(promiseGd).toBeDefined();
expect(typeof promiseGd).toBe('object');
expect(promiseGd.data).toBeDefined();
diff --git a/test/jasmine/tests/plots_test.js b/test/jasmine/tests/plots_test.js
index 6c2d7ffcb53..e3bed3e7ad9 100644
--- a/test/jasmine/tests/plots_test.js
+++ b/test/jasmine/tests/plots_test.js
@@ -2,7 +2,8 @@ var Plotly = require('@src/plotly');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
-describe('Test Plotly.Plots', function () {
+
+describe('Test Plotly.Plots', function() {
'use strict';
describe('Plotly.Plots.supplyLayoutGlobalDefaults should', function() {
@@ -239,7 +240,7 @@ describe('Test Plotly.Plots', function () {
attr: 'abc',
idRoot: 'cba',
attributes: { stuff: { 'more stuff': 102102 } }
- }
+ };
Plotly.Plots.registerSubplot(fake);
@@ -266,13 +267,13 @@ describe('Test Plotly.Plots', function () {
];
shouldPass.forEach(function(s) {
- it('considers ' + JSON.stringify(s) + 'as a correct attribute name', function () {
+ it('considers ' + JSON.stringify(s) + 'as a correct attribute name', function() {
expect(subplotsRegistry.fake.attrRegex.test(s)).toBe(true);
});
});
shouldFail.forEach(function(s) {
- it('considers ' + JSON.stringify(s) + 'as an incorrect attribute name', function () {
+ it('considers ' + JSON.stringify(s) + 'as an incorrect attribute name', function() {
expect(subplotsRegistry.fake.attrRegex.test(s)).toBe(false);
});
});
@@ -292,13 +293,13 @@ describe('Test Plotly.Plots', function () {
];
shouldPass.forEach(function(s) {
- it('considers ' + JSON.stringify(s) + 'as a correct attribute name', function () {
+ it('considers ' + JSON.stringify(s) + 'as a correct attribute name', function() {
expect(subplotsRegistry.fake.idRegex.test(s)).toBe(true);
});
});
shouldFail.forEach(function(s) {
- it('considers ' + JSON.stringify(s) + 'as an incorrect attribute name', function () {
+ it('considers ' + JSON.stringify(s) + 'as an incorrect attribute name', function() {
expect(subplotsRegistry.fake.idRegex.test(s)).toBe(false);
});
});
@@ -306,17 +307,17 @@ describe('Test Plotly.Plots', function () {
});
- describe('Plotly.Plots.purge', function () {
+ describe('Plotly.Plots.purge', function() {
var gd;
- beforeEach(function (done) {
+ beforeEach(function(done) {
gd = createGraphDiv();
Plotly.plot(gd, [{ x: [1,2,3], y: [2,3,4] }], {}).then(done);
});
afterEach(destroyGraphDiv);
- it('should unset everything in the gd except _context', function () {
+ it('should unset everything in the gd except _context', function() {
var expectedKeys = [
'_ev', 'on', 'once', 'removeListener', 'removeAllListeners',
'emit', '_context', '_replotPending', '_mouseDownTime',
diff --git a/test/jasmine/tests/scatter_test.js b/test/jasmine/tests/scatter_test.js
index d72cfcb1fce..5b492ce170b 100644
--- a/test/jasmine/tests/scatter_test.js
+++ b/test/jasmine/tests/scatter_test.js
@@ -1,6 +1,6 @@
var Plotly = require('@src/plotly');
-describe('Test scatter', function () {
+describe('Test scatter', function() {
'use strict';
describe('supplyDefaults', function() {
@@ -62,44 +62,44 @@ describe('Test scatter', function () {
describe('isBubble', function() {
it('should return true when marker.size is an Array', function() {
var trace = {
- marker: {
- size: [1, 4, 2, 10]
- }
- },
- isBubble = Plotly.Scatter.isBubble(trace);
+ marker: {
+ size: [1, 4, 2, 10]
+ }
+ },
+ isBubble = Plotly.Scatter.isBubble(trace);
expect(isBubble).toBe(true);
});
it('should return false when marker.size is an number', function() {
var trace = {
- marker: {
- size: 10
- }
- },
- isBubble = Plotly.Scatter.isBubble(trace);
+ marker: {
+ size: 10
+ }
+ },
+ isBubble = Plotly.Scatter.isBubble(trace);
expect(isBubble).toBe(false);
});
it('should return false when marker.size is not defined', function() {
var trace = {
- marker: {
- color: 'red'
- }
- },
- isBubble = Plotly.Scatter.isBubble(trace);
+ marker: {
+ color: 'red'
+ }
+ },
+ isBubble = Plotly.Scatter.isBubble(trace);
expect(isBubble).toBe(false);
});
it('should return false when marker is not defined', function() {
var trace = {
- line: {
- color: 'red'
- }
- },
- isBubble = Plotly.Scatter.isBubble(trace);
+ line: {
+ color: 'red'
+ }
+ },
+ isBubble = Plotly.Scatter.isBubble(trace);
expect(isBubble).toBe(false);
});
diff --git a/test/jasmine/tests/scattergeo_test.js b/test/jasmine/tests/scattergeo_test.js
index b39a7e164f7..0168d3249f6 100644
--- a/test/jasmine/tests/scattergeo_test.js
+++ b/test/jasmine/tests/scattergeo_test.js
@@ -1,6 +1,6 @@
var Plotly = require('@src/plotly');
-describe('Test scattergeo', function () {
+describe('Test scattergeo', function() {
'use strict';
var ScatterGeo = Plotly.ScatterGeo;
diff --git a/test/jasmine/tests/svg_text_utils_test.js b/test/jasmine/tests/svg_text_utils_test.js
index 4abb4692fd6..ef7e4e190cb 100644
--- a/test/jasmine/tests/svg_text_utils_test.js
+++ b/test/jasmine/tests/svg_text_utils_test.js
@@ -24,7 +24,7 @@ describe('svg+text utils', function() {
it('checks for XSS attack in href', function() {
var node = mockTextSVGElement(
'XSS'
- )
+ );
expect(node.text()).toEqual('XSS');
expect(node.select('a').attr('xlink:href')).toBe(null);
@@ -33,7 +33,7 @@ describe('svg+text utils', function() {
it('checks for XSS attack in href (with plenty of white spaces)', function() {
var node = mockTextSVGElement(
'XSS'
- )
+ );
expect(node.text()).toEqual('XSS');
expect(node.select('a').attr('xlink:href')).toBe(null);
@@ -42,7 +42,7 @@ describe('svg+text utils', function() {
it('whitelists http hrefs', function() {
var node = mockTextSVGElement(
'bl.ocks.org'
- )
+ );
expect(node.text()).toEqual('bl.ocks.org');
expect(node.select('a').attr('xlink:href')).toEqual('http://bl.ocks.org/');
@@ -51,7 +51,7 @@ describe('svg+text utils', function() {
it('whitelists https hrefs', function() {
var node = mockTextSVGElement(
'plot.ly'
- )
+ );
expect(node.text()).toEqual('plot.ly');
expect(node.select('a').attr('xlink:href')).toEqual('https://plot.ly');
@@ -60,7 +60,7 @@ describe('svg+text utils', function() {
it('whitelists mailto hrefs', function() {
var node = mockTextSVGElement(
'support'
- )
+ );
expect(node.text()).toEqual('support');
expect(node.select('a').attr('xlink:href')).toEqual('mailto:support@plot.ly');
diff --git a/test/syntax_test.js b/test/syntax_test.js
index 742437d0281..9f982601c60 100644
--- a/test/syntax_test.js
+++ b/test/syntax_test.js
@@ -1,7 +1,7 @@
var path = require('path');
var fs = require('fs');
-var jshint = require('jshint').JSHINT;
+var falafel = require('falafel');
var glob = require('glob');
var constants = require('../tasks/util/constants');
@@ -14,19 +14,16 @@ glob(path.join(constants.pathToJasmineTests, '**/*.js'), function(err, files) {
files.forEach(function(file) {
var code = fs.readFileSync(file, 'utf-8');
- jshint(code);
-
- var impliedGlobals = jshint.data().implieds;
-
- impliedGlobals.forEach(function(obj) {
- if(focusGlobals.indexOf(obj.name) !== -1) {
+ falafel(code, {locations: true}, function(node) {
+ if(node.type === 'Identifier' && focusGlobals.indexOf(node.name) !== -1) {
logs.push([
path.basename(file),
- '[line ' + obj.line + '] :',
+ '[line ' + node.loc.start.line + '] :',
'contains either a *fdescribe* or a *fit* block.'
].join(' '));
}
});
+
});
if(logs.length) throw new Error(logs.join('\n'));