mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-21 16:00:24 +00:00
修复Tooltip在特殊情况下可能会超出屏幕显示不完整的问题
This commit is contained in:
@@ -77,6 +77,7 @@ slug: /changelog
|
||||
|
||||
## master
|
||||
|
||||
* (2024.11.26) 修复`Tooltip`在特殊情况下可能会超出屏幕显示不完整的问题
|
||||
* (2024.11.24) 修复`UITable`在拖拽时也会点选的问题
|
||||
* (2024.11.22) 修复`Time`时间轴在开启`Animation`时动态变更效果异常的问题
|
||||
* (2024.11.18) 优化`Line`在数据点过密时有更好的绘制效果
|
||||
|
||||
@@ -546,7 +546,7 @@ namespace XCharts.Runtime
|
||||
|
||||
tooltip.SetActive(m_ShowTooltip);
|
||||
tooltip.view.Refresh();
|
||||
TooltipHelper.LimitInRect(tooltip, chart.chartRect);
|
||||
TooltipHelper.LimitInRect(chart, tooltip, chart.chartRect);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ namespace XCharts.Runtime
|
||||
tooltip.SetActive(m_ShowTooltip);
|
||||
if (tooltip.view != null)
|
||||
tooltip.view.Refresh();
|
||||
TooltipHelper.LimitInRect(tooltip, chart.chartRect);
|
||||
TooltipHelper.LimitInRect(chart, tooltip, chart.chartRect);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace XCharts.Runtime
|
||||
return "-".Equals(itemFormatter) ||"{i}".Equals(itemFormatter, StringComparison.CurrentCultureIgnoreCase);
|
||||
}
|
||||
|
||||
public static void LimitInRect(Tooltip tooltip, Rect chartRect)
|
||||
public static void LimitInRect(BaseChart chart, Tooltip tooltip, Rect chartRect)
|
||||
{
|
||||
if (tooltip.view == null)
|
||||
return;
|
||||
@@ -78,6 +78,18 @@ namespace XCharts.Runtime
|
||||
}
|
||||
if (pos.y > chartRect.y + chartRect.height)
|
||||
pos.y = chartRect.y + chartRect.height;
|
||||
var screenGap = 10;
|
||||
var screenPos = chart.LocalPointToScreenPoint(pos);
|
||||
if (screenPos.x < screenGap)
|
||||
pos.x += Mathf.Abs(screenPos.x) + screenGap;
|
||||
if (screenPos.x + tooltip.context.width > Screen.width - screenGap)
|
||||
pos.x -= Mathf.Abs(screenPos.x + tooltip.context.width - Screen.width) + screenGap;
|
||||
|
||||
if (screenPos.y < tooltip.context.height + screenGap)
|
||||
pos.y += Mathf.Abs(screenPos.y - tooltip.context.height) + screenGap;
|
||||
if (screenPos.y > Screen.height - screenGap)
|
||||
pos.y -= Mathf.Abs(screenPos.y - Screen.height) + screenGap;
|
||||
|
||||
tooltip.UpdateContentPos(pos, chartRect.width / 2, chartRect.height / 2);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user