修复LegendBackground区域在Horizonal模式下不对的问题

This commit is contained in:
monitor1394
2026-03-29 21:48:25 +08:00
parent 99e56d238a
commit 5f66391428
2 changed files with 7 additions and 1 deletions

View File

@@ -198,11 +198,14 @@ namespace XCharts.Runtime
legend.context.eachHeight = 0;
if (legend.orient == Orient.Horizonal)
{
var maxRowWidth = 0f;
foreach (var kv in legend.context.buttonList)
{
if (width + kv.Value.width > maxWidth)
{
realWidth = width - legend.itemGap;
if (realWidth > maxRowWidth)
maxRowWidth = realWidth;
realHeight += height + legend.itemGap;
if (legend.context.eachHeight < height + legend.itemGap)
{
@@ -216,8 +219,10 @@ namespace XCharts.Runtime
height = kv.Value.height;
}
width -= legend.itemGap;
if (width > maxRowWidth)
maxRowWidth = width;
legend.context.height = realHeight + height;
legend.context.width = realWidth > 0 ? realWidth : width;
legend.context.width = maxRowWidth;
}
else
{