增加Serieclip参数控制是否超出坐标系外裁剪

This commit is contained in:
monitor1394
2020-02-10 18:30:05 +08:00
parent 11a68d9b7b
commit cd3f933764
12 changed files with 312 additions and 79 deletions

View File

@@ -556,5 +556,34 @@ namespace XCharts
OnLegendButtonClick(legendIndex, legendName, show);
RefreshChart();
}
/// <summary>
/// 坐标是否在图表范围内
/// </summary>
/// <param name="local"></param>
/// <returns></returns>
public bool IsInChart(Vector2 local)
{
if (local.x < 0 || local.x > chartWidth ||
local.y < 0 || local.y > chartHeight)
{
return false;
}
return true;
}
public Vector3 ClampInChart(Vector3 pos)
{
if (IsInChart(pos)) return pos;
else
{
var np = new Vector3(pos.x, pos.y);
if (np.x < 0) np.x = 0;
if (np.x > chartWidth) np.x = chartWidth;
if (np.y < 0) np.y = 0;
if (np.y > chartHeight) np.y = chartHeight;
return np;
}
}
}
}