From 5c141ab5e0b2b7122c28493afec4bad26258e184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Fri, 8 Jan 2016 18:05:36 -0500 Subject: [PATCH 01/14] add eslintrc files: - one root level file with all the rules - plus one per set of js environments --- .eslintrc | 40 ++++++++++++++++++++++++++++++++++++++++ devtools/.eslintrc | 7 +++++++ src/.eslintrc | 9 +++++++++ tasks/.eslintrc | 6 ++++++ test/.eslintrc | 3 +++ test/image/.eslintrc | 3 +++ test/jasmine/.eslintrc | 7 +++++++ 7 files changed, 75 insertions(+) create mode 100644 .eslintrc create mode 100644 devtools/.eslintrc create mode 100644 src/.eslintrc create mode 100644 tasks/.eslintrc create mode 100644 test/.eslintrc create mode 100644 test/image/.eslintrc create mode 100644 test/jasmine/.eslintrc diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 00000000000..feda9ef3957 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,40 @@ +{ + "root": true, + "extends": [ + "eslint:recommended", + ], + "env": { + "commonjs": true + }, + "rules": { + "no-trailing-spaces": [0], + "no-multiple-empty-lines": [2, {"max": 3, "maxEOF": 1}], + "linebreak-style": [2, "unix"], + "indent": [0, 4], + "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": [0, "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": [0, "never"], + "no-multi-spaces": [0], + "space-infix-ops": [0, {"int32Hint": false}], + "quotes": [2, "single"], + "dot-notation": [2, {"allowKeywords": false}], + "eqeqeq": [2], + "new-cap": [2], + "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/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/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/tasks/.eslintrc b/tasks/.eslintrc new file mode 100644 index 00000000000..54cef5dbfbe --- /dev/null +++ b/tasks/.eslintrc @@ -0,0 +1,6 @@ +{ + "extends": "../.eslintrc", + "env": { + "node": true + } +} diff --git a/test/.eslintrc b/test/.eslintrc new file mode 100644 index 00000000000..7a2a763b8b2 --- /dev/null +++ b/test/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "../tasks/.eslintrc" +} diff --git a/test/image/.eslintrc b/test/image/.eslintrc new file mode 100644 index 00000000000..61595266543 --- /dev/null +++ b/test/image/.eslintrc @@ -0,0 +1,3 @@ +{ + "extends": "../../tasks/.eslintrc" +} diff --git a/test/jasmine/.eslintrc b/test/jasmine/.eslintrc new file mode 100644 index 00000000000..d177999d069 --- /dev/null +++ b/test/jasmine/.eslintrc @@ -0,0 +1,7 @@ +{ + "extends": "../../.eslintrc", + "env": { + "browser": true, + "jasmine": true + } +} From 6aa2f7d32233eab170d0ec2c09f82432ae544d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Fri, 8 Jan 2016 18:06:07 -0500 Subject: [PATCH 02/14] add eslintingore: - so that eslint . from the root gives the desired results --- .eslintignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .eslintignore diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 00000000000..be0b872bc0c --- /dev/null +++ b/.eslintignore @@ -0,0 +1,6 @@ +dist/* +build/* + +test/jasmine/assets/jquery-1.8.3.min.js +src/plots/polar/micropolar.js +src/plots/geo/projections.js From 006b297ff07d038a99285d7be40d707207bb5866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Fri, 8 Jan 2016 18:06:23 -0500 Subject: [PATCH 03/14] replace jshint with eslint for `npm run lint` script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 54d333c0bde..e61291661c3 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", From 9a9395fbf59e9cb0b4374c079d009e9de1fd6c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 11 Jan 2016 15:30:52 -0500 Subject: [PATCH 04/14] ignore node_modules/ in eslint --- .eslintignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.eslintignore b/.eslintignore index be0b872bc0c..f7a63bcaa49 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,6 @@ -dist/* -build/* +node_modules +dist +build test/jasmine/assets/jquery-1.8.3.min.js src/plots/polar/micropolar.js From 23d31881bd3a46e603fd6aaf22e200ee2d3c158b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 11 Jan 2016 15:48:19 -0500 Subject: [PATCH 05/14] update eslintrc --- .eslintrc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.eslintrc b/.eslintrc index feda9ef3957..56759cf48fb 100644 --- a/.eslintrc +++ b/.eslintrc @@ -7,28 +7,28 @@ "commonjs": true }, "rules": { - "no-trailing-spaces": [0], + "no-trailing-spaces": [2], "no-multiple-empty-lines": [2, {"max": 3, "maxEOF": 1}], "linebreak-style": [2, "unix"], - "indent": [0, 4], + "indent": [2, 4, {"SwitchCase": 1}], "max-len": [0, 80], - "brace-style": [0, "stroustrup", { "allowSingleLine": true }], + "brace-style": [0, "stroustrup", {"allowSingleLine": true}], "curly": [0, "multi"], "camelcase": [0, {"properties": "never"}], "comma-spacing": [0, {"before": false, "after": true}], - "comma-style": [0, "last"], + "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": [0, "never"], - "no-multi-spaces": [0], + "no-multi-spaces": [2], "space-infix-ops": [0, {"int32Hint": false}], "quotes": [2, "single"], "dot-notation": [2, {"allowKeywords": false}], "eqeqeq": [2], - "new-cap": [2], + "new-cap": [0], "no-redeclare": [2, {"builtinGlobals": true}], "no-shadow": [0, {"builtinGlobals": true}], "block-scoped-var": [2], From c01995e45dd25c69e9f66db5bd7931bc2915bd4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 11 Jan 2016 15:53:15 -0500 Subject: [PATCH 06/14] lint (add 'use strict'; to add src files) --- src/assets/geo_assets.js | 2 + src/components/annotations/arrow_paths.js | 2 + src/components/annotations/attributes.js | 2 + src/components/color/attributes.js | 2 + src/components/colorbar/attributes.js | 2 + src/components/colorscale/attributes.js | 2 + src/components/colorscale/default_scale.js | 2 + src/components/colorscale/scales.js | 2 + src/components/errorbars/attributes.js | 2 + src/components/legend/attributes.js | 1 + src/components/shapes/attributes.js | 1 + src/fonts/mathjax_config.js | 1 + src/index.js | 1 + src/plotly.js | 1 + src/plots/attributes.js | 2 + src/plots/cartesian/attributes.js | 50 +++++++++++---------- src/plots/cartesian/constants.js | 2 + src/plots/cartesian/layout_attributes.js | 3 +- src/plots/font_attributes.js | 2 + src/plots/geo/layout/attributes.js | 2 + src/plots/geo/layout/axis_attributes.js | 2 + src/plots/geo/layout/layout_attributes.js | 1 + src/plots/geo/projections.js | 3 -- src/plots/gl3d/layout/attributes.js | 2 + src/plots/gl3d/layout/axis_attributes.js | 2 + src/plots/layout_attributes.js | 1 + src/plots/polar/area_attributes.js | 1 + src/plots/polar/micropolar.js | 3 -- src/plots/polar/undo_manager.js | 3 -- src/traces/bar/attributes.js | 1 + src/traces/bar/layout_attributes.js | 2 + src/traces/box/attributes.js | 1 + src/traces/box/layout_attributes.js | 3 ++ src/traces/choropleth/attributes.js | 1 + src/traces/contour/attributes.js | 1 + src/traces/heatmap/attributes.js | 1 + src/traces/histogram2d/attributes.js | 1 + src/traces/histogram2dcontour/attributes.js | 2 + src/traces/mesh3d/attributes.js | 1 + src/traces/pie/attributes.js | 1 - src/traces/scatter/attributes.js | 2 + src/traces/scattergeo/attributes.js | 1 + src/traces/scattergl/attributes.js | 1 + tasks/bundle.js | 2 +- 44 files changed, 87 insertions(+), 36 deletions(-) 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/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/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/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/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/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/plotly.js b/src/plotly.js index 152afc0314a..975565e0df9 100644 --- a/src/plotly.js +++ b/src/plotly.js @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; /* * Pack internal modules unto an object. diff --git a/src/plots/attributes.js b/src/plots/attributes.js index 444e6efa532..52b03c671ed 100644 --- a/src/plots/attributes.js +++ b/src/plots/attributes.js @@ -6,6 +6,8 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; + module.exports = { type: { diff --git a/src/plots/cartesian/attributes.js b/src/plots/cartesian/attributes.js index 56b97345a98..56d6cca9450 100644 --- a/src/plots/cartesian/attributes.js +++ b/src/plots/cartesian/attributes.js @@ -6,30 +6,32 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; + module.exports = { - xaxis: { - valType: 'axisid', - role: 'info', - dflt: 'x', - description: [ - 'Sets a reference between this trace\'s x coordinates and', - 'a 2D cartesian x axis.', - 'If *x* (the default value), the x coordinates refer to', - '`layout.xaxis`.', - 'If *x2*, the x coordinates refer to `layout.xaxis2`, and so on.' - ].join(' ') - }, - yaxis: { - valType: 'axisid', - role: 'info', - dflt: 'y', - description: [ - 'Sets a reference between this trace\'s y coordinates and', - 'a 2D cartesian y axis.', - 'If *y* (the default value), the y coordinates refer to', - '`layout.yaxis`.', - 'If *y2*, the y coordinates refer to `layout.xaxis2`, and so on.' - ].join(' ') - } + xaxis: { + valType: 'axisid', + role: 'info', + dflt: 'x', + description: [ + 'Sets a reference between this trace\'s x coordinates and', + 'a 2D cartesian x axis.', + 'If *x* (the default value), the x coordinates refer to', + '`layout.xaxis`.', + 'If *x2*, the x coordinates refer to `layout.xaxis2`, and so on.' + ].join(' ') + }, + yaxis: { + valType: 'axisid', + role: 'info', + dflt: 'y', + description: [ + 'Sets a reference between this trace\'s y coordinates and', + 'a 2D cartesian y axis.', + 'If *y* (the default value), the y coordinates refer to', + '`layout.yaxis`.', + 'If *y2*, the y coordinates refer to `layout.xaxis2`, and so on.' + ].join(' ') + } }; diff --git a/src/plots/cartesian/constants.js b/src/plots/cartesian/constants.js index 6e2f1d9eb13..fb30322e895 100644 --- a/src/plots/cartesian/constants.js +++ b/src/plots/cartesian/constants.js @@ -6,6 +6,8 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; + module.exports = { // ms between first mousedown and 2nd mouseup to constitute dblclick... diff --git a/src/plots/cartesian/layout_attributes.js b/src/plots/cartesian/layout_attributes.js index 0df8bcec423..ef423607fc4 100644 --- a/src/plots/cartesian/layout_attributes.js +++ b/src/plots/cartesian/layout_attributes.js @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; var Plotly = require('../../plotly'); var fontAttrs = require('../font_attributes'); @@ -129,7 +130,7 @@ module.exports = { '(the number of milliseconds since January 1st, 1970).', 'For example, to set the starting tick to', 'November 4th, 2013, set the range to 1380844800000.0.' - ].join(' ') + ].join(' ') }, dtick: { valType: 'any', diff --git a/src/plots/font_attributes.js b/src/plots/font_attributes.js index 09e3e907039..22ce05a412b 100644 --- a/src/plots/font_attributes.js +++ b/src/plots/font_attributes.js @@ -6,6 +6,8 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; + module.exports = { family: { 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/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/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/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/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/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/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/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/box/attributes.js b/src/traces/box/attributes.js index e423b96d38d..c01f7914850 100644 --- a/src/traces/box/attributes.js +++ b/src/traces/box/attributes.js @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; var scatterAttrs = require('../scatter/attributes'); var colorAttrs = require('../../components/color/attributes'); diff --git a/src/traces/box/layout_attributes.js b/src/traces/box/layout_attributes.js index 2cc5fe79cdc..13dec977304 100644 --- a/src/traces/box/layout_attributes.js +++ b/src/traces/box/layout_attributes.js @@ -6,6 +6,9 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; + + module.exports = { boxmode: { valType: 'enumerated', diff --git a/src/traces/choropleth/attributes.js b/src/traces/choropleth/attributes.js index 67392e25253..872010ef3c3 100644 --- a/src/traces/choropleth/attributes.js +++ b/src/traces/choropleth/attributes.js @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; var ScatterGeoAttrs = require('../scattergeo/attributes'); var colorscaleAttrs = require('../../components/colorscale/attributes'); diff --git a/src/traces/contour/attributes.js b/src/traces/contour/attributes.js index 699e651ca16..7173f97a6b0 100644 --- a/src/traces/contour/attributes.js +++ b/src/traces/contour/attributes.js @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; var heatmapAttrs = require('../heatmap/attributes'); var scatterAttrs = require('../scatter/attributes'); 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/histogram2d/attributes.js b/src/traces/histogram2d/attributes.js index 930e17b7691..0a95fbc99c0 100644 --- a/src/traces/histogram2d/attributes.js +++ b/src/traces/histogram2d/attributes.js @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; var histogramAttrs = require('../histogram/attributes'); var heatmapAttrs = require('../heatmap/attributes'); diff --git a/src/traces/histogram2dcontour/attributes.js b/src/traces/histogram2dcontour/attributes.js index 4dd10a479e4..4b4f8131d07 100644 --- a/src/traces/histogram2dcontour/attributes.js +++ b/src/traces/histogram2dcontour/attributes.js @@ -6,6 +6,8 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; + var histogram2dAttrs = require('../histogram2d/attributes'); var contourAttrs = require('../contour/attributes'); diff --git a/src/traces/mesh3d/attributes.js b/src/traces/mesh3d/attributes.js index def239cca1a..4c3e218c964 100644 --- a/src/traces/mesh3d/attributes.js +++ b/src/traces/mesh3d/attributes.js @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; var colorscaleAttrs = require('../../components/colorscale/attributes'); var surfaceAtts = require('../surface/attributes'); diff --git a/src/traces/pie/attributes.js b/src/traces/pie/attributes.js index 79590a9195a..fa33cd0bf12 100644 --- a/src/traces/pie/attributes.js +++ b/src/traces/pie/attributes.js @@ -260,4 +260,3 @@ module.exports = { ].join(' ') } }; - 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/scattergeo/attributes.js b/src/traces/scattergeo/attributes.js index 026aa16102b..724cd12bc8d 100644 --- a/src/traces/scattergeo/attributes.js +++ b/src/traces/scattergeo/attributes.js @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; var scatterAttrs = require('../scatter/attributes'); var plotAttrs = require('../../plots/attributes'); diff --git a/src/traces/scattergl/attributes.js b/src/traces/scattergl/attributes.js index 2ccc88c8b7f..a012ecbac4c 100644 --- a/src/traces/scattergl/attributes.js +++ b/src/traces/scattergl/attributes.js @@ -6,6 +6,7 @@ * LICENSE file in the root directory of this source tree. */ +'use strict'; var scatterAttrs = require('../scatter/attributes'); var DASHES = require('../../constants/gl2d_dashes.json'); diff --git a/tasks/bundle.js b/tasks/bundle.js index 2b13767ddab..a74c38992a9 100644 --- a/tasks/bundle.js +++ b/tasks/bundle.js @@ -63,7 +63,7 @@ browserify(constants.pathToPlotlyGeoAssetsSrc, { }) .pipe(fs.createWriteStream(constants.pathToPlotlyGeoAssetsDist)); - + // Browserify the plotly.js with meta browserify(constants.pathToPlotlySrc, { debug: DEV, From 6fbff9729b9df64e4eccfa490127e4e5344b12b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 11 Jan 2016 15:56:40 -0500 Subject: [PATCH 07/14] lint (re-indent, rm whitespaces, some ;) --- devtools/image_viewer/viewer.js | 2 +- devtools/test_dashboard/buttons.js | 44 +-- devtools/test_dashboard/server.js | 6 +- src/components/annotations/index.js | 8 +- src/components/colorbar/draw.js | 14 +- src/components/errorbars/index.js | 6 +- src/components/legend/index.js | 16 +- src/components/modebar/buttons.js | 10 +- src/components/modebar/manage.js | 3 +- src/components/shapes/index.js | 2 +- src/components/titles/index.js | 24 +- src/lib/dates.js | 5 +- src/lib/events.js | 2 +- src/lib/html2unicode.js | 72 ++-- src/lib/index.js | 4 +- src/lib/nested_property.js | 4 +- src/lib/svg_text_utils.js | 11 +- src/plot_api/plot_api.js | 38 +- src/plot_api/plot_schema.js | 8 +- src/plots/cartesian/axes.js | 20 +- src/plots/cartesian/graph_interact.js | 25 +- src/plots/cartesian/index.js | 2 - src/plots/cartesian/select.js | 6 +- src/plots/geo/geo.js | 12 +- src/plots/geo/index.js | 8 +- src/plots/geo/layout/axis_defaults.js | 6 +- src/plots/geo/layout/defaults.js | 8 +- src/plots/geo/set_scale.js | 8 +- src/plots/geo/zoom.js | 79 ++-- src/plots/geo/zoom_reset.js | 2 +- src/plots/gl2d/camera.js | 8 +- src/plots/gl2d/convert.js | 4 +- src/plots/gl2d/index.js | 12 +- src/plots/gl2d/scene2d.js | 25 +- src/plots/gl3d/camera.js | 424 +++++++++++----------- src/plots/gl3d/index.js | 10 +- src/plots/gl3d/layout/convert.js | 16 +- src/plots/gl3d/layout/defaults.js | 5 +- src/plots/gl3d/layout/tick_marks.js | 10 +- src/plots/gl3d/project.js | 23 +- src/plots/gl3d/scene.js | 324 ++++++++--------- src/plots/plots.js | 50 +-- src/plots/polar/axis_attributes.js | 2 +- src/snapshot/cloneplot.js | 52 +-- src/snapshot/svgtoimg.js | 28 +- src/snapshot/tosvg.js | 2 +- src/traces/bar/index.js | 17 +- src/traces/bar/set_positions.js | 2 +- src/traces/box/index.js | 31 +- src/traces/box/plot.js | 24 +- src/traces/contour/colorbar.js | 6 +- src/traces/contour/index.js | 25 +- src/traces/contour/plot.js | 9 +- src/traces/heatmap/calc.js | 4 +- src/traces/heatmap/hover.js | 5 +- src/traces/heatmap/plot.js | 38 +- src/traces/histogram/index.js | 21 +- src/traces/histogram2d/index.js | 21 +- src/traces/histogram2dcontour/index.js | 21 +- src/traces/mesh3d/convert.js | 125 +++---- src/traces/mesh3d/defaults.js | 8 +- src/traces/pie/calc.js | 6 +- src/traces/pie/plot.js | 24 +- src/traces/scatter/index.js | 30 +- src/traces/scatter3d/convert.js | 87 +++-- src/traces/scatter3d/index.js | 21 +- src/traces/scattergeo/index.js | 15 +- src/traces/scattergl/convert.js | 43 +-- src/traces/scattergl/index.js | 15 +- src/traces/surface/convert.js | 11 +- src/traces/surface/defaults.js | 2 +- tasks/preprocess.js | 5 +- tasks/util/format_bundle_msg.js | 8 +- tasks/util/make_watchified_bundle.js | 2 +- test/jasmine/tests/contour_test.js | 3 +- test/jasmine/tests/extend_test.js | 10 +- test/jasmine/tests/geolayout_test.js | 6 +- test/jasmine/tests/gl3daxes_test.js | 2 +- test/jasmine/tests/heatmap_test.js | 4 +- test/jasmine/tests/histogram_test.js | 4 +- test/jasmine/tests/hover_label_test.js | 36 +- test/jasmine/tests/hover_pie_test.js | 46 +-- test/jasmine/tests/lib_test.js | 140 +++---- test/jasmine/tests/plot_api_test.js | 34 +- test/jasmine/tests/plot_promise_test.js | 45 ++- test/jasmine/tests/plots_test.js | 2 +- test/jasmine/tests/scatter_test.js | 40 +- test/jasmine/tests/svg_text_utils_test.js | 10 +- 88 files changed, 1244 insertions(+), 1214 deletions(-) diff --git a/devtools/image_viewer/viewer.js b/devtools/image_viewer/viewer.js index 5b1d8e4fbca..2442dce15ae 100644 --- a/devtools/image_viewer/viewer.js +++ b/devtools/image_viewer/viewer.js @@ -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..7268b06cc9c 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'); @@ -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'); @@ -122,7 +124,7 @@ function plotButtons(plots, figDir) { 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 ++; 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/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/colorbar/draw.js b/src/components/colorbar/draw.js index 2c05d6df08e..b795db400da 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 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/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..0605734f468 100644 --- a/src/components/modebar/buttons.js +++ b/src/components/modebar/buttons.js @@ -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/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/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/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..ccf3d3e8838 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; 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/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..aaf501c38e5 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]; @@ -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'); + } } } @@ -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, @@ -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; }; @@ -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/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/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..27d1fb232a7 100644 --- a/src/plots/gl3d/camera.js +++ b/src/plots/gl3d/camera.js @@ -13,234 +13,232 @@ 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..f5c6069795c 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 ); 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..e3217a80a0e 100644 --- a/src/plots/gl3d/layout/defaults.js +++ b/src/plots/gl3d/layout/defaults.js @@ -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..b25f366a3a7 100644 --- a/src/plots/gl3d/layout/tick_marks.js +++ b/src/plots/gl3d/layout/tick_marks.js @@ -13,7 +13,7 @@ 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 +352,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 +371,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 +446,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 +511,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'; } }; @@ -538,8 +532,8 @@ 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] ); }; @@ -547,22 +541,22 @@ proto.setCameraToDefault = function setCameraToDefault () { 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; + 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], @@ -625,9 +619,7 @@ proto.handleDragmode = function (dragmode) { 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 +655,7 @@ proto.toImage = function (format) { var dataURL; - switch (format) { + switch(format) { case 'jpeg': dataURL = canvas.toDataURL('image/jpeg'); break; @@ -671,12 +663,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/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/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/snapshot/cloneplot.js b/src/snapshot/cloneplot.js index 139348443fa..c8057ab054d 100644 --- a/src/snapshot/cloneplot.js +++ b/src/snapshot/cloneplot.js @@ -19,32 +19,32 @@ 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/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/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/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/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..3eb8bebb879 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'); 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; iXSS' - ) + ); 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'); From e0f9f008db1dfd55b4ff8e420cf6410ee7474fd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 11 Jan 2016 15:57:09 -0500 Subject: [PATCH 08/14] replace file jshint ignore for eslint --- devtools/test_dashboard/test_cartesian.js | 2 ++ devtools/test_dashboard/test_geo.js | 2 ++ devtools/test_dashboard/test_gl2d.js | 2 ++ devtools/test_dashboard/test_gl3d.js | 2 ++ src/plots/gl3d/camera.js | 3 --- src/plots/gl3d/layout/tick_marks.js | 4 ++-- src/plots/gl3d/scene.js | 4 +++- src/snapshot/toimage.js | 4 +++- tasks/util/pull_font_svg.js | 2 -- test/jasmine/tests/events_test.js | 2 ++ 10 files changed, 18 insertions(+), 9 deletions(-) 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/src/plots/gl3d/camera.js b/src/plots/gl3d/camera.js index 27d1fb232a7..83c91ab40ef 100644 --- a/src/plots/gl3d/camera.js +++ b/src/plots/gl3d/camera.js @@ -6,9 +6,6 @@ * LICENSE file in the root directory of this source tree. */ - -/* jshint shadow: true */ - 'use strict'; module.exports = createCamera; diff --git a/src/plots/gl3d/layout/tick_marks.js b/src/plots/gl3d/layout/tick_marks.js index b25f366a3a7..3b84aebeed9 100644 --- a/src/plots/gl3d/layout/tick_marks.js +++ b/src/plots/gl3d/layout/tick_marks.js @@ -6,8 +6,8 @@ * LICENSE file in the root directory of this source tree. */ - -/* jshint shadow: true */ +/*eslint block-scoped-var: 0*/ +/*eslint no-redeclare: 0*/ 'use strict'; diff --git a/src/plots/gl3d/scene.js b/src/plots/gl3d/scene.js index e5d004a8103..57254a2d87a 100644 --- a/src/plots/gl3d/scene.js +++ b/src/plots/gl3d/scene.js @@ -7,7 +7,9 @@ */ -/* jshint shadow: true */ +/*eslint block-scoped-var: 0*/ +/*eslint no-redeclare: 0*/ + 'use strict'; var Plotly = require('../../plotly'); diff --git a/src/snapshot/toimage.js b/src/snapshot/toimage.js index 899057d1e44..be057a1d768 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'); @@ -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/tasks/util/pull_font_svg.js b/tasks/util/pull_font_svg.js index 147beddeddf..6c39294c717 100644 --- a/tasks/util/pull_font_svg.js +++ b/tasks/util/pull_font_svg.js @@ -27,8 +27,6 @@ module.exports = function pullFontSVG(data, pathOut) { var charStr = JSON.stringify(chars, null, 4).replace(/\"/g, '\''); var outStr = [ - '/* jshint quotmark:true */', - '', '\'use strict\';', '', 'module.exports = ' + charStr + ';', diff --git a/test/jasmine/tests/events_test.js b/test/jasmine/tests/events_test.js index 35c76b6dcdd..bab06874df0 100644 --- a/test/jasmine/tests/events_test.js +++ b/test/jasmine/tests/events_test.js @@ -1,3 +1,5 @@ +/* global $:false */ + /* * Note this test requires JQuery in the global scope. * we should keep it that way to keep testing our backward From 80563bed4341a20d7da814c1007b3239b757f6b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 11 Jan 2016 15:57:24 -0500 Subject: [PATCH 09/14] rm un-used variables --- src/traces/box/hover.js | 4 ++-- test/jasmine/tests/plot_interact_test.js | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/traces/box/hover.js b/src/traces/box/hover.js index 153d51b3b0b..9d3651e5bcb 100644 --- a/src/traces/box/hover.js +++ b/src/traces/box/hover.js @@ -20,7 +20,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { ya = pointData.ya, closeData = [], dx, dy, distfn, boxDelta, - posLetter, posAxis, posText, + posLetter, posAxis, val, valLetter, valAxis; // adjust inbox w.r.t. to calculate box size @@ -71,7 +71,7 @@ module.exports = function hoverPoints(pointData, xval, yval, hovermode) { pointData[posLetter+'0'] = posAxis.c2p(di.pos + t.bPos - t.bdPos, true); pointData[posLetter+'1'] = posAxis.c2p(di.pos + t.bPos + t.bdPos, true); - posText = Plotly.Axes.tickText(posAxis, posAxis.c2l(di.pos), 'hover').text; + Plotly.Axes.tickText(posAxis, posAxis.c2l(di.pos), 'hover').text; pointData[posLetter+'LabelVal'] = di.pos; // box plots: each "point" gets many labels diff --git a/test/jasmine/tests/plot_interact_test.js b/test/jasmine/tests/plot_interact_test.js index 80ed3a1918d..328566a4c59 100644 --- a/test/jasmine/tests/plot_interact_test.js +++ b/test/jasmine/tests/plot_interact_test.js @@ -1,7 +1,6 @@ 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'); From b8af7e585215050db46fae26b2545ddd445733aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 11 Jan 2016 15:57:58 -0500 Subject: [PATCH 10/14] rewrite syntax test using falafel (instead of jshint) --- test/syntax_test.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) 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')); From 1eceb030b6502340c353935da90b004cb9388f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 11 Jan 2016 15:58:22 -0500 Subject: [PATCH 11/14] add info about eslint --- CONTRIBUTING.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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. From c80026de973c8a4550ccc2da391b3dd4e9c2fa86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 11 Jan 2016 15:58:36 -0500 Subject: [PATCH 12/14] rm jshintrc and jshint from dev-dependencies --- .jshintrc | 72 ---------------------------------------------------- package.json | 1 - 2 files changed, 73 deletions(-) delete mode 100644 .jshintrc 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/package.json b/package.json index e61291661c3..ad2706c54b0 100644 --- a/package.json +++ b/package.json @@ -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", From abeae11b883332136fd047ac8afca6055dc4901f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 11 Jan 2016 17:59:41 -0500 Subject: [PATCH 13/14] make no space-before-function-paren rule mandatory --- .eslintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index 56759cf48fb..a3a0894af1d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -22,7 +22,7 @@ "key-spacing": [0, {"beforeColon": false, "afterColon": true}], "no-spaced-func": [2], "space-in-parens": [2, "never"], - "space-before-function-paren": [0, "never"], + "space-before-function-paren": [2, "never"], "no-multi-spaces": [2], "space-infix-ops": [0, {"int32Hint": false}], "quotes": [2, "single"], From 2daa656bddc840d776febc4d87578403c07324b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20T=C3=A9treault-Pinard?= Date: Mon, 11 Jan 2016 18:03:34 -0500 Subject: [PATCH 14/14] lint -> function() not function () --- devtools/image_viewer/viewer.js | 2 +- devtools/test_dashboard/buttons.js | 16 +-- src/components/colorbar/draw.js | 2 +- src/components/errorbars/defaults.js | 2 +- src/components/modebar/buttons.js | 2 +- src/components/modebar/index.js | 8 +- src/lib/index.js | 2 +- src/lib/matrix.js | 4 +- src/lib/queue.js | 4 +- src/lib/show_no_webgl_msg.js | 9 +- src/plot_api/plot_api.js | 20 +-- src/plots/cartesian/axes.js | 6 +- src/plots/cartesian/graph_interact.js | 6 +- src/plots/gl3d/index.js | 2 +- src/plots/gl3d/layout/defaults.js | 2 +- src/plots/gl3d/scene.js | 10 +- src/plots/gl3d/set_convert.js | 2 +- src/snapshot/cloneplot.js | 2 +- src/snapshot/toimage.js | 4 +- src/traces/box/calc.js | 10 +- src/traces/mesh3d/defaults.js | 2 +- src/traces/pie/plot.js | 6 +- src/traces/surface/convert.js | 4 +- test/image/compare_pixels_test.js | 14 +- test/image/make_baseline.js | 8 +- test/jasmine/assets/mouse_event.js | 2 +- test/jasmine/tests/axes_test.js | 3 +- test/jasmine/tests/bar_test.js | 3 +- test/jasmine/tests/box_test.js | 3 +- test/jasmine/tests/choropleth_test.js | 3 +- test/jasmine/tests/color_test.js | 3 +- test/jasmine/tests/colorbar_test.js | 3 +- test/jasmine/tests/colorscale_test.js | 3 +- test/jasmine/tests/contour_test.js | 3 +- test/jasmine/tests/events_test.js | 4 +- test/jasmine/tests/extend_test.js | 2 +- test/jasmine/tests/geoaxes_test.js | 3 +- test/jasmine/tests/geolayout_test.js | 3 +- test/jasmine/tests/gl3daxes_test.js | 2 +- test/jasmine/tests/gl3dlayout_test.js | 2 +- test/jasmine/tests/gl_plot_interact_test.js | 2 +- test/jasmine/tests/heatmap_test.js | 2 +- test/jasmine/tests/histogram_test.js | 3 +- test/jasmine/tests/hover_pie_test.js | 16 +-- test/jasmine/tests/is_plain_object_test.js | 4 +- test/jasmine/tests/legend_test.js | 2 +- test/jasmine/tests/plot_api_test.js | 134 ++++++++++---------- test/jasmine/tests/plot_interact_test.js | 2 +- test/jasmine/tests/plot_promise_test.js | 68 +++++----- test/jasmine/tests/plots_test.js | 17 +-- test/jasmine/tests/scatter_test.js | 2 +- test/jasmine/tests/scattergeo_test.js | 2 +- 52 files changed, 229 insertions(+), 216 deletions(-) diff --git a/devtools/image_viewer/viewer.js b/devtools/image_viewer/viewer.js index 2442dce15ae..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); diff --git a/devtools/test_dashboard/buttons.js b/devtools/test_dashboard/buttons.js index 7268b06cc9c..7f9068298b0 100644 --- a/devtools/test_dashboard/buttons.js +++ b/devtools/test_dashboard/buttons.js @@ -13,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'); @@ -25,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'; @@ -90,7 +90,7 @@ function plotButtons(plots, figDir) { var myImage = new Image(); myImage.src = dataURL; - myImage.onload = function () { + myImage.onload = function() { myImage.height = scene.container.clientHeight; myImage.width = scene.container.clientWidth; }; @@ -114,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 ++; @@ -146,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/src/components/colorbar/draw.js b/src/components/colorbar/draw.js index b795db400da..c354608f8cf 100644 --- a/src/components/colorbar/draw.js +++ b/src/components/colorbar/draw.js @@ -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/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/modebar/buttons.js b/src/components/modebar/buttons.js index 0605734f468..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'); 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/lib/index.js b/src/lib/index.js index ccf3d3e8838..12b78cb4c2c 100644 --- a/src/lib/index.js +++ b/src/lib/index.js @@ -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/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/plot_api/plot_api.js b/src/plot_api/plot_api.js index aaf501c38e5..5c111503ebc 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -824,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; }); @@ -838,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); @@ -1096,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 = []; @@ -1172,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); @@ -1243,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, @@ -1272,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, @@ -1310,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 = [], @@ -1382,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 = [], @@ -1449,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 = [], @@ -1499,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; }); diff --git a/src/plots/cartesian/axes.js b/src/plots/cartesian/axes.js index 25b958b5826..fefaaba3154 100644 --- a/src/plots/cartesian/axes.js +++ b/src/plots/cartesian/axes.js @@ -707,7 +707,7 @@ axes.setConvert = function(ax) { v = axes.cleanDatum(v); return isNumeric(v) ? Number(v) : axes.BADNUM; }; - ax.d2l = function (v, clip) { + ax.d2l = function(v, clip) { if (ax.type === 'log') return ax.c2l(ax.d2c(v), clip); else return ax.d2c(v); }; @@ -1187,7 +1187,7 @@ axes.autoBin = function(data,ax,nbins,is2d) { // if ticks are set to automatic, determine the right values (tick0,dtick) // in any case, set tickround to # of digits to round tick labels to, // or codes to this effect for log and date scales -axes.calcTicks = function calcTicks (ax) { +axes.calcTicks = function calcTicks(ax) { if(ax.tickmode === 'array') return arrayTicks(ax); // calculate max number of (auto) ticks to display based on plot size @@ -1935,7 +1935,7 @@ axes.getFromId = function(td, id, type) { }; // get an axis object of specified type from the containing trace -axes.getFromTrace = function (td, fullTrace, type) { +axes.getFromTrace = function(td, fullTrace, type) { var fullLayout = td._fullLayout; var ax = null; if (Plotly.Plots.traceIs(fullTrace, 'gl3d')) { diff --git a/src/plots/cartesian/graph_interact.js b/src/plots/cartesian/graph_interact.js index 02c41239405..20531a93e86 100644 --- a/src/plots/cartesian/graph_interact.js +++ b/src/plots/cartesian/graph_interact.js @@ -264,7 +264,7 @@ var HOVERARROWSIZE = constants.HOVERARROWSIZE, // The actual rendering is done by private functions // hover() and unhover(). -fx.hover = function (gd, evt, subplot) { +fx.hover = function(gd, evt, subplot) { if(typeof gd === 'string') gd = document.getElementById(gd); if(gd._lastHoverTime === undefined) gd._lastHoverTime = 0; @@ -281,14 +281,14 @@ fx.hover = function (gd, evt, subplot) { return; } // Queue up the next hover for 100ms from now (if no further events) - gd._hoverTimer = setTimeout(function () { + gd._hoverTimer = setTimeout(function() { hover(gd,evt,subplot); gd._lastHoverTime = Date.now(); gd._hoverTimer = undefined; }, constants.HOVERMINTIME); }; -fx.unhover = function (gd, evt, subplot) { +fx.unhover = function(gd, evt, subplot) { if(typeof gd === 'string') gd = document.getElementById(gd); // Important, clear any queued hovers if (gd._hoverTimer) { diff --git a/src/plots/gl3d/index.js b/src/plots/gl3d/index.js index f5c6069795c..68f15f0177a 100644 --- a/src/plots/gl3d/index.js +++ b/src/plots/gl3d/index.js @@ -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/defaults.js b/src/plots/gl3d/layout/defaults.js index e3217a80a0e..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'); diff --git a/src/plots/gl3d/scene.js b/src/plots/gl3d/scene.js index 57254a2d87a..07903635a86 100644 --- a/src/plots/gl3d/scene.js +++ b/src/plots/gl3d/scene.js @@ -530,7 +530,7 @@ 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], @@ -540,7 +540,7 @@ proto.setCameraToDefault = function setCameraToDefault () { }; // 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; @@ -555,7 +555,7 @@ proto.getCamera = function getCamera () { }; // set camera position with a set of plotly coords -proto.setCamera = function setCamera (cameraData) { +proto.setCamera = function setCamera(cameraData) { var up = cameraData.up; var center = cameraData.center; var eye = cameraData.eye; @@ -596,7 +596,7 @@ proto.saveCamera = function saveCamera(layout) { return hasChanged; }; -proto.handleDragmode = function (dragmode) { +proto.handleDragmode = function(dragmode) { var camera = this.camera; if (camera) { @@ -618,7 +618,7 @@ proto.handleDragmode = function (dragmode) { } }; -proto.toImage = function (format) { +proto.toImage = function(format) { if (!format) format = 'png'; if(this.staticMode) this.container.appendChild(STATIC_CANVAS); 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/snapshot/cloneplot.js b/src/snapshot/cloneplot.js index c8057ab054d..7678bcdf602 100644 --- a/src/snapshot/cloneplot.js +++ b/src/snapshot/cloneplot.js @@ -15,7 +15,7 @@ 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) { diff --git a/src/snapshot/toimage.js b/src/snapshot/toimage.js index be057a1d768..5184b60818d 100644 --- a/src/snapshot/toimage.js +++ b/src/snapshot/toimage.js @@ -32,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'); diff --git a/src/traces/box/calc.js b/src/traces/box/calc.js index 56785310077..2548dc42415 100644 --- a/src/traces/box/calc.js +++ b/src/traces/box/calc.js @@ -46,7 +46,7 @@ module.exports = function calc(gd, trace) { // so if you want one box // per trace, set x0 (y0) to the x (y) value or category for this trace // (or set x (y) to a constant array matching y (x)) - function getPos (gd, trace, posLetter, posAxis, val) { + function getPos(gd, trace, posLetter, posAxis, val) { var pos0; if (posLetter in trace) pos = posAxis.makeCalcdata(trace, posLetter); else { @@ -62,7 +62,7 @@ module.exports = function calc(gd, trace) { } else pos0 = gd.numboxes; pos0 = posAxis.d2c(pos0); - pos = val.map(function(){ return pos0; }); + pos = val.map(function() { return pos0; }); } return pos; } @@ -74,7 +74,7 @@ module.exports = function calc(gd, trace) { posDistinct = dv.vals; dPos = dv.minDiff/2; - function binVal (cd, val, pos, posDistinct, dPos) { + function binVal(cd, val, pos, posDistinct, dPos) { var posDistinctLength = posDistinct.length, valLength = val.length, valBinned = [], @@ -104,7 +104,7 @@ module.exports = function calc(gd, trace) { valBinned = binVal(cd, val, pos, posDistinct, dPos); // sort the bins and calculate the stats - function calculateStats (cd, valBinned) { + function calculateStats(cd, valBinned) { var v, l, cdi, i; for (i = 0; i < valBinned.length; ++i) { @@ -136,7 +136,7 @@ module.exports = function calc(gd, trace) { calculateStats(cd, valBinned); // remove empty bins - cd = cd.filter(function(cdi){ return cdi.val && cdi.val.length; }); + cd = cd.filter(function(cdi) { return cdi.val && cdi.val.length; }); if(!cd.length) return [{t: {emptybox: true}}]; // add numboxes and dPos to cd diff --git a/src/traces/mesh3d/defaults.js b/src/traces/mesh3d/defaults.js index 3eb8bebb879..64060c2ae33 100644 --- a/src/traces/mesh3d/defaults.js +++ b/src/traces/mesh3d/defaults.js @@ -77,7 +77,7 @@ module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout } if(traceOut.reversescale) { - traceOut.colorscale = traceOut.colorscale.map(function (si) { + traceOut.colorscale = traceOut.colorscale.map(function(si) { return [1 - si[0], si[1]]; }).reverse(); } diff --git a/src/traces/pie/plot.js b/src/traces/pie/plot.js index 3c05529a2f0..7d5dd989770 100644 --- a/src/traces/pie/plot.js +++ b/src/traces/pie/plot.js @@ -133,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 }); @@ -438,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/surface/convert.js b/src/traces/surface/convert.js index 494f712bacf..c782e786eac 100644 --- a/src/traces/surface/convert.js +++ b/src/traces/surface/convert.js @@ -84,10 +84,10 @@ proto.handlePick = function(selection) { } }; -function parseColorScale (colorscale, alpha) { +function parseColorScale(colorscale, alpha) { if (alpha === undefined) alpha = 1; - return colorscale.map(function (elem) { + return colorscale.map(function(elem) { var index = elem[0]; var color = tinycolor(elem[1]); var rgb = color.toRgb(); diff --git a/test/image/compare_pixels_test.js b/test/image/compare_pixels_test.js index b85099df378..260ddf54520 100644 --- a/test/image/compare_pixels_test.js +++ b/test/image/compare_pixels_test.js @@ -28,8 +28,8 @@ var userFileName = process.argv[2]; if(!userFileName) runAll(); else runSingle(userFileName); -function runAll () { - test('testing mocks', function (t) { +function runAll() { + test('testing mocks', function(t) { var allMocks = fs.readdirSync(constants.pathToTestImageMocks); @@ -73,14 +73,14 @@ function runAll () { }); } -function runSingle (userFileName) { - test('testing single mock: ' + userFileName, function (t) { +function runSingle(userFileName) { + test('testing single mock: ' + userFileName, function(t) { t.plan(1); testMock(userFileName, t); }); } -function testMock (fileName, t) { +function testMock(fileName, t) { var figure = require(path.join(constants.pathToTestImageMocks, fileName)); var bodyMock = { figure: figure, @@ -94,7 +94,7 @@ function testMock (fileName, t) { var savedImageStream = fs.createWriteStream(savedImagePath); var options = getOptions(bodyMock, 'http://localhost:9010/'); - function checkImage () { + function checkImage() { var options = { file: diffPath, highlightColor: 'purple', @@ -109,7 +109,7 @@ function testMock (fileName, t) { ); } - function onEqualityCheck (err, isEqual) { + function onEqualityCheck(err, isEqual) { if (err) { touch(diffPath); return console.error(err, imageFileName); diff --git a/test/image/make_baseline.js b/test/image/make_baseline.js index 6b42afeb79d..a21558ec8fc 100644 --- a/test/image/make_baseline.js +++ b/test/image/make_baseline.js @@ -13,7 +13,7 @@ var bar; if (!userFileName) { - fs.readdir(constants.pathToTestImageMocks, function (err, files) { + fs.readdir(constants.pathToTestImageMocks, function(err, files) { console.log('####### ' + files.length + ' total baseline images to build #######'); bar = new ProgressBar('processing [:bar] [:current / :total]', { total: files.length, width: 30 }); if (err) return console.log(err); @@ -25,7 +25,7 @@ else { } -function createBaselineImage (fileName) { +function createBaselineImage(fileName) { if (path.extname(fileName) !== '.json') return; var figure = require(path.join(constants.pathToTestImageMocks, fileName)); @@ -40,12 +40,12 @@ function createBaselineImage (fileName) { var savedImageStream = fs.createWriteStream(savedImagePath); var options = getOptions(bodyMock, 'http://localhost:9010/'); - function checkFormat (err, res) { + function checkFormat(err, res) { if (err) console.log(err); if (res.headers['content-type'] !== 'image/png') console.log(res.statusCode); } - function onClose () { + function onClose() { if (bar) bar.tick(); if (userFileName) console.log('generated : ' + imageFileName + ' successfully'); } diff --git a/test/jasmine/assets/mouse_event.js b/test/jasmine/assets/mouse_event.js index 036e33f0a4f..c8fd5b77028 100644 --- a/test/jasmine/assets/mouse_event.js +++ b/test/jasmine/assets/mouse_event.js @@ -1,4 +1,4 @@ -module.exports = function (type, x, y, opts) { +module.exports = function(type, x, y, opts) { var el = document.elementFromPoint(x,y); var options = opts || { bubbles: true }; var ev = new window.MouseEvent(type, options); diff --git a/test/jasmine/tests/axes_test.js b/test/jasmine/tests/axes_test.js index bd336907956..0d223be78d8 100644 --- a/test/jasmine/tests/axes_test.js +++ b/test/jasmine/tests/axes_test.js @@ -1,6 +1,7 @@ var Plotly = require('@src/plotly'); -describe('Test axes', function () { + +describe('Test axes', function() { 'use strict'; describe('swap', function() { diff --git a/test/jasmine/tests/bar_test.js b/test/jasmine/tests/bar_test.js index 72621ff3d37..7645b93c2cd 100644 --- a/test/jasmine/tests/bar_test.js +++ b/test/jasmine/tests/bar_test.js @@ -1,6 +1,7 @@ var Bar = require('@src/traces/bar'); -describe('Test bar', function () { + +describe('Test bar', function() { 'use strict'; describe('supplyDefaults', function() { diff --git a/test/jasmine/tests/box_test.js b/test/jasmine/tests/box_test.js index 76acc2fb0be..5c357f26ad5 100644 --- a/test/jasmine/tests/box_test.js +++ b/test/jasmine/tests/box_test.js @@ -1,6 +1,7 @@ var Box = require('@src/traces/box'); -describe('Test boxes', function () { + +describe('Test boxes', function() { 'use strict'; describe('supplyDefaults', function() { diff --git a/test/jasmine/tests/choropleth_test.js b/test/jasmine/tests/choropleth_test.js index ae5d99ade0b..65d2ab9cf61 100644 --- a/test/jasmine/tests/choropleth_test.js +++ b/test/jasmine/tests/choropleth_test.js @@ -1,6 +1,7 @@ var Plotly = require('@src/plotly'); -describe('Test choropleth', function () { + +describe('Test choropleth', function() { 'use strict'; var Choropleth = Plotly.Choropleth; diff --git a/test/jasmine/tests/color_test.js b/test/jasmine/tests/color_test.js index 259e5084867..816e85767ac 100644 --- a/test/jasmine/tests/color_test.js +++ b/test/jasmine/tests/color_test.js @@ -1,6 +1,7 @@ var Plotly = require('@src/plotly'); -describe('Test color:', function () { + +describe('Test color:', function() { 'use strict'; describe('clean', function() { diff --git a/test/jasmine/tests/colorbar_test.js b/test/jasmine/tests/colorbar_test.js index 4b97ee01412..0b6591f0e5c 100644 --- a/test/jasmine/tests/colorbar_test.js +++ b/test/jasmine/tests/colorbar_test.js @@ -1,6 +1,7 @@ var Colorbar = require('@src/components/colorbar'); -describe('Test colorbar:', function () { + +describe('Test colorbar:', function() { 'use strict'; describe('hasColorbar', function() { diff --git a/test/jasmine/tests/colorscale_test.js b/test/jasmine/tests/colorscale_test.js index fc50044e0a5..4af568c5d7f 100644 --- a/test/jasmine/tests/colorscale_test.js +++ b/test/jasmine/tests/colorscale_test.js @@ -1,7 +1,8 @@ var Plotly = require('@src/plotly'); var Colorscale = require('@src/components/colorscale'); -describe('Test colorscale:', function () { + +describe('Test colorscale:', function() { 'use strict'; describe('isValidScale', function() { diff --git a/test/jasmine/tests/contour_test.js b/test/jasmine/tests/contour_test.js index d1387672359..f65296140e0 100644 --- a/test/jasmine/tests/contour_test.js +++ b/test/jasmine/tests/contour_test.js @@ -1,6 +1,7 @@ var Plotly = require('@src/plotly'); -describe('Test contour', function () { + +describe('Test contour', function() { 'use strict'; describe('supplyDefaults', function() { diff --git a/test/jasmine/tests/events_test.js b/test/jasmine/tests/events_test.js index bab06874df0..c68ccfd6cb2 100644 --- a/test/jasmine/tests/events_test.js +++ b/test/jasmine/tests/events_test.js @@ -9,7 +9,7 @@ var Events = require('@src/lib/events'); -describe('Events', function () { +describe('Events', function() { 'use strict'; var plotObj; @@ -38,7 +38,7 @@ describe('Events', function () { it('is idempotent', function() { Events.init(plotObj); - plotObj.emit = function () { + plotObj.emit = function() { return 'initial'; }; diff --git a/test/jasmine/tests/extend_test.js b/test/jasmine/tests/extend_test.js index d1ed10466c9..882fa387476 100644 --- a/test/jasmine/tests/extend_test.js +++ b/test/jasmine/tests/extend_test.js @@ -8,7 +8,7 @@ var str = 'me a test', arr = [1, 'what', new Date(81, 8, 4)], date = new Date(81, 4, 13); -var Foo = function () {}; +var Foo = function() {}; var obj = { str: str, diff --git a/test/jasmine/tests/geoaxes_test.js b/test/jasmine/tests/geoaxes_test.js index c043bc764b0..6127145f1f7 100644 --- a/test/jasmine/tests/geoaxes_test.js +++ b/test/jasmine/tests/geoaxes_test.js @@ -1,7 +1,8 @@ var params = require('@src/constants/geo_constants'); var supplyLayoutDefaults = require('@src/plots/geo/layout/axis_defaults'); -describe('Test geoaxes', function () { + +describe('Test geoaxes', function() { 'use strict'; describe('supplyLayoutDefaults', function() { diff --git a/test/jasmine/tests/geolayout_test.js b/test/jasmine/tests/geolayout_test.js index e3195864e63..f0928e6e48b 100644 --- a/test/jasmine/tests/geolayout_test.js +++ b/test/jasmine/tests/geolayout_test.js @@ -1,6 +1,7 @@ var Geo = require('@src/plots/geo'); -describe('Test Geo layout defaults', function () { + +describe('Test Geo layout defaults', function() { 'use strict'; var layoutAttributes = Geo.layoutAttributes; diff --git a/test/jasmine/tests/gl3daxes_test.js b/test/jasmine/tests/gl3daxes_test.js index 246cdf2bfe7..13ccafd24c7 100644 --- a/test/jasmine/tests/gl3daxes_test.js +++ b/test/jasmine/tests/gl3daxes_test.js @@ -1,7 +1,7 @@ var supplyLayoutDefaults = require('@src/plots/gl3d/layout/axis_defaults'); -describe('Test Gl3dAxes', function () { +describe('Test Gl3dAxes', function() { 'use strict'; describe('supplyLayoutDefaults supplies defaults', function() { diff --git a/test/jasmine/tests/gl3dlayout_test.js b/test/jasmine/tests/gl3dlayout_test.js index e4410f1523e..606a9c6e703 100644 --- a/test/jasmine/tests/gl3dlayout_test.js +++ b/test/jasmine/tests/gl3dlayout_test.js @@ -1,7 +1,7 @@ var Gl3d = require('@src/plots/gl3d'); -describe('Test Gl3d layout defaults', function () { +describe('Test Gl3d layout defaults', function() { 'use strict'; describe('supplyLayoutDefaults', function() { diff --git a/test/jasmine/tests/gl_plot_interact_test.js b/test/jasmine/tests/gl_plot_interact_test.js index abc7807a83e..97a0e6e8d9d 100644 --- a/test/jasmine/tests/gl_plot_interact_test.js +++ b/test/jasmine/tests/gl_plot_interact_test.js @@ -12,7 +12,7 @@ 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/heatmap_test.js b/test/jasmine/tests/heatmap_test.js index 0b05b87b601..ecde41d96cf 100644 --- a/test/jasmine/tests/heatmap_test.js +++ b/test/jasmine/tests/heatmap_test.js @@ -3,7 +3,7 @@ var Heatmap = require('@src/traces/heatmap'); var convertColumnXYZ = require('@src/traces/heatmap/convert_column_xyz'); -describe('Test heatmap', function () { +describe('Test heatmap', function() { 'use strict'; describe('supplyDefaults', function() { diff --git a/test/jasmine/tests/histogram_test.js b/test/jasmine/tests/histogram_test.js index cdbb0871a8c..7dea7663ba5 100644 --- a/test/jasmine/tests/histogram_test.js +++ b/test/jasmine/tests/histogram_test.js @@ -1,6 +1,7 @@ var supplyDefaults = require('@src/traces/histogram/defaults'); -describe('Test histogram', function () { + +describe('Test histogram', function() { 'use strict'; describe('supplyDefaults', function() { diff --git a/test/jasmine/tests/hover_pie_test.js b/test/jasmine/tests/hover_pie_test.js index 2dc18ea6099..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,7 +23,7 @@ describe('pie hovering', function () { afterEach(destroyGraphDiv); - it('should contain the correct fields', function () { + it('should contain the correct fields', function() { /* * expected = [{ @@ -45,7 +45,7 @@ describe('pie hovering', function () { var futureData; - gd.on('plotly_hover', function (data) { + gd.on('plotly_hover', function(data) { futureData = data; }); @@ -59,17 +59,17 @@ describe('pie hovering', function () { expect(futureData.points[0].i).toEqual(3); }); - it('should fire when moving from one slice to another', function (done) { + 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]); 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/plot_api_test.js b/test/jasmine/tests/plot_api_test.js index 24291dbe69d..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'}, @@ -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,7 +367,7 @@ 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() { Plotly.extendTraces({}, {x: [[1]]}, [0]); @@ -379,7 +379,7 @@ describe('Test graph_obj', function () { }); - 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() { Plotly.extendTraces(gd, undefined, [0], 8); @@ -392,7 +392,7 @@ describe('Test graph_obj', function () { }); - it('should throw an error when indices are omitted', function () { + it('should throw an error when indices are omitted', function() { expect(function() { Plotly.extendTraces(gd, {x: [[1]]}); @@ -400,7 +400,7 @@ describe('Test graph_obj', function () { }); - it('should throw 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() { Plotly.extendTraces(gd, {x: [[1]]}, [-gd.data.length - 1]); @@ -408,7 +408,7 @@ describe('Test graph_obj', function () { }); - it('should not throw an error when negative index wraps to positive', function () { + it('should not throw an error when negative index wraps to positive', function() { expect(function() { Plotly.extendTraces(gd, {x: [[1]]}, [-1]); @@ -416,7 +416,7 @@ describe('Test graph_obj', function () { }); - it('should throw 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() { Plotly.extendTraces(gd, {x: [[1, 2], [2, 3]] }, [0]); @@ -428,7 +428,7 @@ describe('Test graph_obj', function () { }); - it('should throw 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() { Plotly.extendTraces(gd, {x: [[1]]}, [0], {y: [1]}); @@ -442,7 +442,7 @@ describe('Test graph_obj', function () { }); - 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]; @@ -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 328566a4c59..bdf46fafbd7 100644 --- a/test/jasmine/tests/plot_interact_test.js +++ b/test/jasmine/tests/plot_interact_test.js @@ -6,7 +6,7 @@ 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 56840f04e7d..b42af7044db 100644 --- a/test/jasmine/tests/plot_promise_test.js +++ b/test/jasmine/tests/plot_promise_test.js @@ -2,14 +2,14 @@ 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] }]; promise = Plotly.plot(createGraphDiv(), data, {}); @@ -21,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(); @@ -29,11 +29,11 @@ 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(); @@ -48,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(); @@ -56,11 +56,11 @@ describe('Plotly.___ methods', function () { }); }); - describe('Plotly.newPlot promise', function () { + describe('Plotly.newPlot promise', function() { var promise, promiseGd; - beforeEach(function (done) { + beforeEach(function(done) { var data = [{ x: [1,2,3], y: [4,5,6] }]; promise = Plotly.newPlot(createGraphDiv(), data, {}); @@ -72,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(); @@ -80,11 +80,11 @@ 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(); @@ -99,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(); @@ -107,11 +107,11 @@ 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(); @@ -126,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(); @@ -134,11 +134,11 @@ 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(); @@ -153,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(); @@ -161,11 +161,11 @@ 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(); @@ -180,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(); @@ -188,11 +188,11 @@ 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(); @@ -207,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(); @@ -215,11 +215,11 @@ 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] } @@ -237,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(); @@ -245,11 +245,11 @@ 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(); @@ -264,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(); @@ -272,11 +272,11 @@ 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(); @@ -291,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 ec1671c5fec..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() { @@ -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 06f07b4d30e..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() { 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;