修复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

@@ -81,6 +81,7 @@ slug: /changelog
## master
* (2026.03.29) 修复`Legend``Background`区域在`Horizonal`模式下不对的问题
* (2026.03.25) 增加`Chart``Json`导出导入
* (2026.03.10) 增加`Sankey`的线条tooltip触发显示
* (2026.03.10) 增加`UITable`的排序功能支持

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
{