Skip to content

Legend line width #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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"
}
Expand Down
7 changes: 7 additions & 0 deletions src/components/legend/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
1 change: 1 addition & 0 deletions src/components/legend/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
3 changes: 2 additions & 1 deletion src/components/legend/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/modebar/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions tasks/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ _bundle(constants.pathToPlotlyIndex, constants.pathToPlotlyDist, {
pathToMinBundle: constants.pathToPlotlyDistMin
});


// Browserify the geo assets
_bundle(constants.pathToPlotlyGeoAssetsSrc, constants.pathToPlotlyGeoAssetsDist, {
standalone: 'PlotlyGeoAssets'
Expand Down
2 changes: 1 addition & 1 deletion tasks/stats.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down
39 changes: 18 additions & 21 deletions tasks/util/browserify_wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 3 additions & 4 deletions tasks/util/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
22 changes: 0 additions & 22 deletions tasks/util/patch_minified.js

This file was deleted.