修复MarkArea指定yValuexValue时绘制区域不准确的问题

This commit is contained in:
monitor1394
2025-04-25 22:42:11 +08:00
parent a0dba26318
commit 06bd26dc5f
2 changed files with 21 additions and 25 deletions

View File

@@ -80,6 +80,9 @@ slug: /changelog
## master
* (2025.04.25) 修复`MarkArea`指定`yValue``xValue`时绘制区域不准确的问题
* (2025.04.17) 增加`UITable``Title`支持设置标题
* (2025.04.17) 增加`UITable``Viewport`支持设置表格视口边距边框
* (2025.04.15) 增加`Bar`支持通过`VisualMap`设置颜色
* (2025.04.14) 增加`AxisLabel``showZeroLabel`设置是否显示0刻度
* (2025.04.08) 增加`UIStatistic``desc`描述文本设置支持

View File

@@ -40,7 +40,7 @@ namespace XCharts.Runtime
private void InitMarkArea(MarkArea markArea)
{
markArea.painter = chart.m_PainterUpper;
markArea.refreshComponent = delegate()
markArea.refreshComponent = delegate ()
{
var label = ChartHelper.AddChartLabel("label", m_MarkLineLabelRoot.transform, markArea.label, chart.theme.axis,
component.text, Color.clear, TextAnchor.MiddleCenter);
@@ -142,31 +142,12 @@ namespace XCharts.Runtime
else if (data.yValue != 0)
{
data.runtimeValue = data.yValue;
if (yAxis.IsCategory())
{
var pY = AxisHelper.GetAxisPosition(grid, yAxis, data.yValue, showData.Count, dataZoom);
return start ?
new Vector3(grid.context.x, pY) :
new Vector3(grid.context.x + grid.context.width, pY);
}
else
{
return GetPosition(xAxis, yAxis, grid, data.runtimeValue, start);
}
return GetPosition(yAxis, grid, data.runtimeValue, start);
}
else
{
data.runtimeValue = data.xValue;
if (xAxis.IsCategory())
{
var pX = AxisHelper.GetAxisPosition(grid, xAxis, data.xValue, showData.Count, dataZoom);
return start ? new Vector3(pX, grid.context.y + grid.context.height) :
new Vector3(pX, grid.context.y);
}
else
{
return GetPosition(xAxis, yAxis, grid, data.xValue, start);
}
return GetPosition(xAxis, grid, data.xValue, start);
}
default:
break;
@@ -178,16 +159,28 @@ namespace XCharts.Runtime
{
if (yAxis.IsCategory())
{
var pX = AxisHelper.GetAxisPosition(grid, xAxis, value);
return GetPosition(xAxis, grid, value, start);
}
else
{
return GetPosition(yAxis, grid, value, start);
}
}
private Vector3 GetPosition(Axis axis, GridCoord grid, double value, bool start)
{
if (axis is XAxis)
{
var pX = AxisHelper.GetAxisPosition(grid, axis, value);
return start ?
new Vector3(pX, grid.context.y + grid.context.height) :
new Vector3(pX, grid.context.y);
}
else
{
var pY = AxisHelper.GetAxisPosition(grid, yAxis, value);
var pY = AxisHelper.GetAxisPosition(grid, axis, value);
return start ?
new Vector3(grid.context.x, pY + grid.context.height) :
new Vector3(grid.context.x, pY) :
new Vector3(grid.context.x + grid.context.width, pY);
}
}