diff --git a/package.json b/package.json index 303f6c4993e..1f15d00c564 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,7 @@ "has-hover": "^1.0.1", "mapbox-gl": "^0.22.0", "matrix-camera-controller": "^2.1.3", + "minify-stream": "^1.1.0", "mouse-change": "^1.4.0", "mouse-event-offset": "^3.0.2", "mouse-wheel": "^1.0.2", @@ -109,6 +110,7 @@ "brfs": "^1.4.3", "browserify": "^14.1.0", "browserify-transform-tools": "^1.7.0", + "cross-spawn": "^5.1.0", "deep-equal": "^1.0.1", "ecstatic": "^2.1.0", "eslint": "^3.17.1", @@ -140,7 +142,6 @@ "read-last-lines": "^1.1.0", "requirejs": "^2.3.1", "through2": "^2.0.3", - "uglify-js": "^2.8.12", "watchify": "^3.9.0", "xml2js": "^0.4.16" } diff --git a/src/components/legend/attributes.js b/src/components/legend/attributes.js index 8b92707afaa..ac2d10ad635 100644 --- a/src/components/legend/attributes.js +++ b/src/components/legend/attributes.js @@ -34,6 +34,13 @@ module.exports = { editType: 'legend', description: 'Sets the width (in px) of the border enclosing the legend.' }, + linewidth: { + valType: 'number', + min: 0, + role: 'style', + editType: 'legend', + description: 'Sets the width (in px) of the legend lines.' + }, font: fontAttrs({ editType: 'legend', description: 'Sets the font used to text the legend items.' diff --git a/src/components/legend/defaults.js b/src/components/legend/defaults.js index a094d5799ba..917c801cc48 100644 --- a/src/components/legend/defaults.js +++ b/src/components/legend/defaults.js @@ -61,6 +61,7 @@ module.exports = function legendDefaults(layoutIn, layoutOut, fullData) { coerce('bgcolor', layoutOut.paper_bgcolor); coerce('bordercolor'); coerce('borderwidth'); + coerce('linewidth'); Lib.coerceFont(coerce, 'font', layoutOut.font); coerce('orientation'); diff --git a/src/components/legend/style.js b/src/components/legend/style.js index 08199c2a888..f3a1a53ee9d 100644 --- a/src/components/legend/style.js +++ b/src/components/legend/style.js @@ -78,10 +78,11 @@ module.exports = function style(s, gd) { var line = d3.select(this).select('.legendlines').selectAll('path') .data(showLine ? [d] : []); + var lineWidth = gd._fullLayout.legend.linewidth; line.enter().append('path').classed('js-line', true) .attr('d', 'M5,0h30'); line.exit().remove(); - line.call(Drawing.lineGroupStyle); + line.call(Drawing.lineGroupStyle, lineWidth); } function stylePoints(d) { diff --git a/src/components/modebar/buttons.js b/src/components/modebar/buttons.js index 3f2875c55b7..0008398bfdd 100644 --- a/src/components/modebar/buttons.js +++ b/src/components/modebar/buttons.js @@ -71,7 +71,7 @@ modeBarButtons.toImage = { modeBarButtons.sendDataToCloud = { name: 'sendDataToCloud', - title: 'Save and edit plot in cloud', + title: 'Edit in Chart Studio', icon: Icons.disk, click: function(gd) { Plots.sendDataToCloud(gd); diff --git a/tasks/bundle.js b/tasks/bundle.js index b1a175d4654..dd767f018ff 100644 --- a/tasks/bundle.js +++ b/tasks/bundle.js @@ -33,6 +33,7 @@ _bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDist, { pathToMinBundle: constants.pathToPlotlyDistMin }); + // Browserify the geo assets _bundle(constants.pathToPlotlyGeoAssetsSrc, constants.pathToPlotlyGeoAssetsDist, { standalone: 'PlotlyGeoAssets' diff --git a/tasks/stats.js b/tasks/stats.js index 6478db4a47a..63227f1f5b4 100644 --- a/tasks/stats.js +++ b/tasks/stats.js @@ -1,6 +1,6 @@ var path = require('path'); var fs = require('fs'); -var spawn = require('child_process').spawn; +var spawn = require('cross-spawn'); var falafel = require('falafel'); var gzipSize = require('gzip-size'); diff --git a/tasks/util/browserify_wrapper.js b/tasks/util/browserify_wrapper.js index fa57092764e..65a8de6c07b 100644 --- a/tasks/util/browserify_wrapper.js +++ b/tasks/util/browserify_wrapper.js @@ -2,11 +2,10 @@ var fs = require('fs'); var path = require('path'); var browserify = require('browserify'); -var UglifyJS = require('uglify-js'); +var minify = require('minify-stream'); var constants = require('./constants'); var compressAttributes = require('./compress_attributes'); -var patchMinified = require('./patch_minified'); var strictD3 = require('./strict_d3'); /** Convenience browserify wrapper @@ -46,30 +45,28 @@ module.exports = function _bundle(pathToIndex, pathToBundle, opts) { } var b = browserify(pathToIndex, browserifyOpts); - var bundleWriteStream = fs.createWriteStream(pathToBundle); - bundleWriteStream.on('finish', function() { - logger(pathToBundle); - if(opts.then) { - opts.then(); - } - }); - - b.bundle(function(err, buf) { + var bundleStream = b.bundle(function(err) { if(err) throw err; + }); - if(outputMinified) { - var minifiedCode = UglifyJS.minify(buf.toString(), constants.uglifyOptions).code; - minifiedCode = patchMinified(minifiedCode); - - fs.writeFile(pathToMinBundle, minifiedCode, function(err) { - if(err) throw err; - + if(outputMinified) { + bundleStream + .pipe(minify(constants.uglifyOptions)) + .pipe(fs.createWriteStream(pathToMinBundle)) + .on('finish', function() { logger(pathToMinBundle); }); - } - }) - .pipe(bundleWriteStream); + } + + bundleStream + .pipe(fs.createWriteStream(pathToBundle)) + .on('finish', function() { + logger(pathToBundle); + if(opts.then) { + opts.then(); + } + }); }; function logger(pathToOutput) { diff --git a/tasks/util/constants.js b/tasks/util/constants.js index 1815c740616..46f0ba357d4 100644 --- a/tasks/util/constants.js +++ b/tasks/util/constants.js @@ -84,16 +84,15 @@ module.exports = { testContainerHome: '/var/www/streambed/image_server/plotly.js', uglifyOptions: { - fromString: true, mangle: true, compress: { - warnings: false, - screw_ie8: true + warnings: false }, output: { beautify: false, ascii_only: true - } + }, + sourceMap: false }, licenseDist: [ diff --git a/tasks/util/patch_minified.js b/tasks/util/patch_minified.js deleted file mode 100644 index e1388c71fa4..00000000000 --- a/tasks/util/patch_minified.js +++ /dev/null @@ -1,22 +0,0 @@ -var PATTERN = /require\("\+(\w)\((\w)\)\+"\)/; -var NEW_SUBSTR = 'require("+ $1($2) +")'; - -/* Uber hacky in-house fix to - * - * https://github.com/substack/webworkify/issues/29 - * - * so that plotly.min.js loads in Jupyter NBs, more info here: - * - * - https://github.com/plotly/plotly.py/pull/545 - * - https://github.com/plotly/plotly.js/pull/914 - * - https://github.com/plotly/plotly.js/pull/1094 - * - * For example, this routine replaces - * 'require("+o(s)+")' -> 'require("+ o(s) +")' - * - * But works for any 1-letter variable that uglify-js may output. - * - */ -module.exports = function patchMinified(minifiedCode) { - return minifiedCode.replace(PATTERN, NEW_SUBSTR); -};