Skip to content

Commit a7301be

Browse files
committed
[legend] let legend size overflow for arbitrary sizing
The overflow check for the legend is not super useful. If one wishes to move the legend position to somewhere else (e.g. in a facet plot with 3 plots there's empty space at the bottom right), it makes sense to allow the plot range to fill the full plot, which depending on inputs might cause an overflow in the layout logic.
1 parent 3f3e5bb commit a7301be

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/ggplotnim.nim

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,8 @@ proc genDiscreteLegend(view: var Viewport,
16441644
colWidths = @[quant(width, ukCentimeter),
16451645
quant(0.3 * bScale, ukCentimeter),
16461646
quant(0.0, ukRelative)],
1647-
rowHeights = rH)
1647+
rowHeights = rH,
1648+
ignoreOverflow = true)
16481649
# iterate only over added children, skip first, because we actual legend first
16491650
var j = 0
16501651

@@ -1694,7 +1695,8 @@ proc genContinuousLegend(view: var Viewport,
16941695
geomKind: GeomKind) =
16951696
case cat.scKind
16961697
of scSize:
1697-
view.layout(1, rows = 5 + 1)
1698+
view.layout(1, rows = 5 + 1,
1699+
ignoreOverflow = true)
16981700
of scColor, scFillColor:
16991701
# create following legend layout
17001702
# _______________________
@@ -1713,13 +1715,15 @@ proc genContinuousLegend(view: var Viewport,
17131715
colWidths = @[quant(0.5 * bScale, ukCentimeter), # for space to plot
17141716
quant(0.0, ukRelative)], # for legend. incl header
17151717
rowHeights = @[quant(legendHeaderHeight, ukCentimeter), # for header
1716-
quant(legendHeight, ukCentimeter)]) # for act. legend
1718+
quant(legendHeight, ukCentimeter)],
1719+
ignoreOverflow = true) # for act. legend
17171720
var legView = view[3] # bottom right
17181721
legView.yScale = cat.dataScale
17191722
let width = theme.continuousLegendWidth.get(1.0)
17201723
legView.layout(3, 1, colWidths = @[quant(width * bScale, ukCentimeter),
17211724
quant(0.5 * bScale, ukCentimeter),
1722-
quant(0.0, ukRelative)])
1725+
quant(0.0, ukRelative)],
1726+
ignoreOverflow = true)
17231727
var legGrad = legView[0]
17241728
# add markers
17251729
let markers = legGrad.generateLegendMarkers(cat, theme, geomKind)

0 commit comments

Comments
 (0)