mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 09:50:15 +00:00
增加自由锚点支持,任意对齐方式
This commit is contained in:
@@ -321,9 +321,9 @@ namespace XCharts
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInZoom(Vector2 pos, float startX, float width)
|
||||
public bool IsInZoom(Vector2 pos, float startX, float startY, float width)
|
||||
{
|
||||
Rect rect = Rect.MinMaxRect(startX, m_Bottom, startX + width, m_Bottom + m_Height);
|
||||
Rect rect = Rect.MinMaxRect(startX, startY + m_Bottom, startX + width, startY + m_Bottom + m_Height);
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
@@ -334,11 +334,11 @@ namespace XCharts
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInSelectedZoom(Vector2 pos, float startX, float width)
|
||||
public bool IsInSelectedZoom(Vector2 pos, float startX, float startY, float width)
|
||||
{
|
||||
var start = startX + width * m_Start / 100;
|
||||
var end = startX + width * m_End / 100;
|
||||
Rect rect = Rect.MinMaxRect(start, m_Bottom, end, m_Bottom + m_Height);
|
||||
Rect rect = Rect.MinMaxRect(start, startY + m_Bottom, end, startY + m_Bottom + m_Height);
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
@@ -349,10 +349,10 @@ namespace XCharts
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInStartZoom(Vector2 pos, float startX, float width)
|
||||
public bool IsInStartZoom(Vector2 pos, float startX, float startY, float width)
|
||||
{
|
||||
var start = startX + width * m_Start / 100;
|
||||
Rect rect = Rect.MinMaxRect(start - 10, m_Bottom, start + 10, m_Bottom + m_Height);
|
||||
Rect rect = Rect.MinMaxRect(start - 10, startY + m_Bottom, start + 10, startY + m_Bottom + m_Height);
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
@@ -363,10 +363,10 @@ namespace XCharts
|
||||
/// <param name="startX"></param>
|
||||
/// <param name="width"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsInEndZoom(Vector2 pos, float startX, float width)
|
||||
public bool IsInEndZoom(Vector2 pos, float startX, float startY, float width)
|
||||
{
|
||||
var end = startX + width * m_End / 100;
|
||||
Rect rect = Rect.MinMaxRect(end - 10, m_Bottom, end + 10, m_Bottom + m_Height);
|
||||
Rect rect = Rect.MinMaxRect(end - 10, startY + m_Bottom, end + 10, startY + m_Bottom + m_Height);
|
||||
return rect.Contains(pos);
|
||||
}
|
||||
|
||||
|
||||
@@ -282,12 +282,12 @@ namespace XCharts
|
||||
return 0;
|
||||
}
|
||||
|
||||
internal void UpdateRadarCenter(float chartWidth, float chartHeight)
|
||||
internal void UpdateRadarCenter(Vector3 chartPosition, float chartWidth, float chartHeight)
|
||||
{
|
||||
if (center.Length < 2) return;
|
||||
var centerX = center[0] <= 1 ? chartWidth * center[0] : center[0];
|
||||
var centerY = center[1] <= 1 ? chartHeight * center[1] : center[1];
|
||||
runtimeCenterPos = new Vector2(centerX, centerY);
|
||||
runtimeCenterPos = chartPosition + new Vector3(centerX, centerY);
|
||||
if (radius <= 0)
|
||||
{
|
||||
runtimeRadius = 0;
|
||||
|
||||
@@ -1572,21 +1572,7 @@ namespace XCharts
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新运行时中心点和半径
|
||||
/// </summary>
|
||||
/// <param name="chartWidth"></param>
|
||||
/// <param name="chartHeight"></param>
|
||||
internal void UpdateCenter(float chartWidth, float chartHeight)
|
||||
{
|
||||
if (center.Length < 2) return;
|
||||
var centerX = center[0] <= 1 ? chartWidth * center[0] : center[0];
|
||||
var centerY = center[1] <= 1 ? chartHeight * center[1] : center[1];
|
||||
runtimeCenterPos = new Vector2(centerX, centerY);
|
||||
var minWidth = Mathf.Min(chartWidth, chartHeight);
|
||||
runtimeInsideRadius = radius[0] <= 1 ? minWidth * radius[0] : radius[0];
|
||||
runtimeOutsideRadius = radius[1] <= 1 ? minWidth * radius[1] : radius[1];
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 设置指定index的数据图标的尺寸
|
||||
|
||||
@@ -381,9 +381,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public float GetValue(Vector3 pos, float chartWidth, float chartHeight)
|
||||
public float GetValue(Vector3 pos, Rect chartRect)
|
||||
{
|
||||
var centerPos = location.GetPosition(chartWidth, chartHeight);
|
||||
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
|
||||
var pos1 = centerPos + (runtimeIsVertical ? Vector3.down : Vector3.left) * itemHeight / 2;
|
||||
var pos2 = centerPos + (runtimeIsVertical ? Vector3.up : Vector3.right) * itemHeight / 2;
|
||||
if (runtimeIsVertical)
|
||||
@@ -400,9 +400,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInRect(Vector3 local, float chartWidth, float chartHeight, float triangleLen = 20)
|
||||
public bool IsInRect(Vector3 local, Rect chartRect, float triangleLen = 20)
|
||||
{
|
||||
var centerPos = location.GetPosition(chartWidth, chartHeight);
|
||||
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
|
||||
var diff = calculable ? triangleLen : 0;
|
||||
if (local.x >= centerPos.x - itemWidth / 2 - diff && local.x <= centerPos.x + itemWidth / 2 + diff &&
|
||||
local.y >= centerPos.y - itemHeight / 2 - diff && local.y <= centerPos.y + itemHeight / 2 + diff)
|
||||
@@ -415,9 +415,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInRangeRect(Vector3 local, float chartWidth, float chartHeight)
|
||||
public bool IsInRangeRect(Vector3 local, Rect chartRect)
|
||||
{
|
||||
var centerPos = location.GetPosition(chartWidth, chartHeight);
|
||||
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
|
||||
if (orient == Orient.Vertical)
|
||||
{
|
||||
var pos1 = centerPos + Vector3.down * itemHeight / 2;
|
||||
@@ -432,9 +432,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInRangeMinRect(Vector3 local, float chartWidth, float chartHeight, float triangleLen)
|
||||
public bool IsInRangeMinRect(Vector3 local, Rect chartRect, float triangleLen)
|
||||
{
|
||||
var centerPos = location.GetPosition(chartWidth, chartHeight);
|
||||
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
|
||||
if (orient == Orient.Vertical)
|
||||
{
|
||||
var radius = triangleLen / 2;
|
||||
@@ -454,9 +454,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsInRangeMaxRect(Vector3 local, float chartWidth, float chartHeight, float triangleLen)
|
||||
public bool IsInRangeMaxRect(Vector3 local, Rect chartRect, float triangleLen)
|
||||
{
|
||||
var centerPos = location.GetPosition(chartWidth, chartHeight);
|
||||
var centerPos = new Vector3(chartRect.x, chartRect.y) + location.GetPosition(chartRect.width, chartRect.height);
|
||||
if (orient == Orient.Vertical)
|
||||
{
|
||||
var radius = triangleLen / 2;
|
||||
|
||||
Reference in New Issue
Block a user