Skip to content

Commit

Permalink
Fix based on review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
s417-lama committed Nov 4, 2020
1 parent 60b0936 commit 1977f12
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/components/legend/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,11 @@ module.exports = {
},
itemwidth: {
valType: 'number',
min: 30,
dflt: 30,
role: 'style',
editType: 'legend',
description: 'Sets the width (in px) of the legend item symbols (the part other than the text).',
description: 'Sets the width (in px) of the legend item symbols (the part other than the title.text).',
},

itemclick: {
Expand Down
19 changes: 10 additions & 9 deletions src/components/legend/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ module.exports = function style(s, gd, legend) {
var constantItemSizing = legend.itemsizing === 'constant';
var itemWidth = legend.itemwidth;
var centerPos = (itemWidth + constants.itemGap * 2) / 2;
var centerTransform = 'translate(' + centerPos + ',0)';

var boundLineWidth = function(mlw, cont, max, cst) {
var v;
Expand Down Expand Up @@ -275,7 +276,7 @@ module.exports = function style(s, gd, legend) {
// make sure marker is on the bottom, in case it enters after text
pts.enter().insert('path', ':first-child')
.classed('scatterpts', true)
.attr('transform', 'translate(' + centerPos + ',0)');
.attr('transform', centerTransform);
pts.exit().remove();
pts.call(Drawing.pointStyle, tMod, gd);

Expand All @@ -287,7 +288,7 @@ module.exports = function style(s, gd, legend) {
.data(showText ? dMod : []);
txt.enter()
.append('g').classed('pointtext', true)
.append('text').attr('transform', 'translate(' + centerPos + ',0)');
.append('text').attr('transform', centerTransform);
txt.exit().remove();
txt.selectAll('text').call(Drawing.textPointStyle, tMod, gd);
}
Expand Down Expand Up @@ -315,7 +316,7 @@ module.exports = function style(s, gd, legend) {
.selectAll('path.legendwaterfall')
.data(ptsData);
pts.enter().append('path').classed('legendwaterfall', true)
.attr('transform', 'translate(' + centerPos + ',0)')
.attr('transform', centerTransform)
.style('stroke-miterlimit', 1);
pts.exit().remove();

Expand Down Expand Up @@ -355,7 +356,7 @@ module.exports = function style(s, gd, legend) {
.data(isVisible ? [d] : []);
barpath.enter().append('path').classed('legend' + desiredType, true)
.attr('d', 'M6,6H-6V-6H6Z')
.attr('transform', 'translate(' + centerPos + ',0)');
.attr('transform', centerTransform);
barpath.exit().remove();

barpath.each(function(d) {
Expand All @@ -379,7 +380,7 @@ module.exports = function style(s, gd, legend) {
pts.enter().append('path').classed('legendbox', true)
// if we want the median bar, prepend M6,0H-6
.attr('d', 'M6,6H-6V-6H6Z')
.attr('transform', 'translate(' + centerPos + ',0)');
.attr('transform', centerTransform);
pts.exit().remove();

pts.each(function() {
Expand Down Expand Up @@ -419,7 +420,7 @@ module.exports = function style(s, gd, legend) {
if(i) return 'M-15,0H-8M-8,6V-6H8Z'; // increasing
return 'M15,0H8M8,-6V6H-8Z'; // decreasing
})
.attr('transform', 'translate(' + centerPos + ',0)')
.attr('transform', centerTransform)
.style('stroke-miterlimit', 1);
pts.exit().remove();

Expand All @@ -446,7 +447,7 @@ module.exports = function style(s, gd, legend) {
if(i) return 'M-15,0H0M-8,-6V0'; // increasing
return 'M15,0H0M8,6V0'; // decreasing
})
.attr('transform', 'translate(' + centerPos + ',0)')
.attr('transform', centerTransform)
.style('stroke-miterlimit', 1);
pts.exit().remove();

Expand Down Expand Up @@ -482,7 +483,7 @@ module.exports = function style(s, gd, legend) {
.data(isVisible ? [d] : []);
pts.enter().append('path').classed('legend' + desiredType, true)
.attr('d', 'M6,6H-6V-6H6Z')
.attr('transform', 'translate(' + centerPos + ',0)');
.attr('transform', centerTransform);
pts.exit().remove();

if(pts.size()) {
Expand Down Expand Up @@ -580,7 +581,7 @@ module.exports = function style(s, gd, legend) {
.selectAll('path.legend3dandfriends')
.data(ptsData);
pts.enter().append('path').classed('legend3dandfriends', true)
.attr('transform', 'translate(' + centerPos + ',0)')
.attr('transform', centerTransform)
.style('stroke-miterlimit', 1);
pts.exit().remove();

Expand Down

0 comments on commit 1977f12

Please sign in to comment.