Skip to content

Commit

Permalink
Add solid bg for text area in legend
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Jul 22, 2022
1 parent ccbaf61 commit fb7ef12
Showing 1 changed file with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,31 +101,41 @@ const ColorLegend = observer(
const {
needsCustomLegend,
needsScalebar,
needsFullHeightScalebar,
rowHeightTooSmallForScalebar,
renderColorBoxes,
sources,
} = model
const svgFontSize = Math.min(rowHeight, 12)
const canDisplayLabel = rowHeight > 11

const colorBoxWidth = renderColorBoxes ? 15 : 0
const legendWidth = labelWidth + colorBoxWidth + 5
const extraOffset = needsScalebar && !rowHeightTooSmallForScalebar ? 50 : 0
return sources ? (
<>
{needsFullHeightScalebar ? (
<RectBg
y={0}
x={extraOffset}
width={legendWidth}
height={
(sources.length + 0.25) *
rowHeight /* 0.25 for hanging letters like g */
}
/>
) : null}
{sources.map((source, idx) => {
// put the subtrack labels to the right of the scalebar
const extraOffset =
needsScalebar && !rowHeightTooSmallForScalebar ? 50 : 0
const colorBoxWidth = renderColorBoxes ? 15 : 0
const legendWidth = labelWidth + colorBoxWidth + 5
const boxHeight = Math.min(20, rowHeight)

return (
<React.Fragment key={source.name + '-' + idx}>
<RectBg
y={idx * rowHeight + 1}
x={extraOffset}
width={legendWidth}
height={boxHeight}
/>
{!needsFullHeightScalebar ? (
<RectBg
y={idx * rowHeight + 1}
x={extraOffset}
width={legendWidth}
height={boxHeight}
/>
) : null}
{source.color ? (
<RectBg
y={idx * rowHeight + 1}
Expand Down

0 comments on commit fb7ef12

Please sign in to comment.