From 3255f52c288f74c56a0d9301dcb3f15233968c30 Mon Sep 17 00:00:00 2001 From: Trevor Bedford Date: Sat, 1 Sep 2018 15:20:32 -0700 Subject: [PATCH] Tweak tree legend placement The legend wasn't fully obscuring the gray timeslice bar. This commit fixes this. --- src/components/tree/legend/legend.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/components/tree/legend/legend.js b/src/components/tree/legend/legend.js index e91fb1517..e77c159fe 100644 --- a/src/components/tree/legend/legend.js +++ b/src/components/tree/legend/legend.js @@ -52,12 +52,20 @@ class Legend extends React.Component { return Math.ceil(nItems / 2) * (legendRectSize + legendSpacing) + legendSpacing + titlePadding || 100; } + + getSVGWidth() { + if (this.state.legendVisible) { + return 290; + } + return this.getTitleWidth() + 20; + } + getTransformationForLegendItem(i) { const count = this.props.colorScale.legendValues.length; const stack = Math.ceil(count / 2); const fromRight = Math.floor(i / stack); const fromTop = (i % stack); - const horz = fromRight * 145; + const horz = fromRight * 145 + 10; const vert = fromTop * (legendRectSize + legendSpacing); return "translate(" + horz + "," + vert + ")"; } @@ -73,7 +81,7 @@ class Legend extends React.Component { "" : this.props.colorOptions[this.props.colorBy].legendTitle; } getTitleWidth() { - return 10 + 5.3 * this.getTitleString().length; + return 15 + 5.3 * this.getTitleString().length; } toggleLegend() { const newState = !this.state.legendVisible; @@ -89,7 +97,7 @@ class Legend extends React.Component { return ( - + {items} @@ -195,9 +203,9 @@ class Legend extends React.Component { return { svg: { position: "absolute", - left: 8, - top: 30, - borderRadius: 2, + left: 5, + top: 26, + borderRadius: 4, zIndex: 1000 } }; @@ -209,7 +217,7 @@ class Legend extends React.Component { return (