[optimaze][tooltip] content rect limit (#202)

This commit is contained in:
monitor1394
2022-06-20 13:41:28 +08:00
parent b11e8fcb3a
commit 5bc14dd37a
2 changed files with 9 additions and 2 deletions

View File

@@ -64,13 +64,18 @@ namespace XCharts.Runtime
var pos = tooltip.view.GetTargetPos();
if (pos.x + tooltip.context.width > chartRect.x + chartRect.width)
{
//pos.x = chartRect.x + chartRect.width - tooltip.context.width;
pos.x = pos.x - tooltip.context.width - tooltip.offset.x;
pos.x = tooltip.context.pointer.x - tooltip.context.width - tooltip.offset.x;
}
else if (pos.x < chartRect.x)
{
pos.x = tooltip.context.pointer.x - tooltip.context.width + Mathf.Abs(tooltip.offset.x);
}
if (pos.y - tooltip.context.height < chartRect.y)
{
pos.y = chartRect.y + tooltip.context.height;
}
if (pos.y > chartRect.y + chartRect.height)
pos.y = chartRect.y + chartRect.height;
tooltip.UpdateContentPos(pos);
}