diff --git a/CHANGELOG-EN.md b/CHANGELOG-EN.md index be5422e2..a1cb254c 100644 --- a/CHANGELOG-EN.md +++ b/CHANGELOG-EN.md @@ -42,6 +42,7 @@ ## branch-2.0 +* (2022.02.08) Fixed `YAxis` `AxisLabel`'s `onZero` does not work * (2022.01.06) Improved `Zebra` bar chart ## v2.6.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c5788f1..a62474dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ ## branch-2.0 +* (2022.02.08) 修复`YAxis`的`AxisLabel`的`onZero`参数不生效的问题 * (2022.01.06) 优化`Zebra`斑马柱图 ## v2.6.0 diff --git a/Runtime/Internal/CoordinateChart.cs b/Runtime/Internal/CoordinateChart.cs index 5e7c10bc..76eb9125 100644 --- a/Runtime/Internal/CoordinateChart.cs +++ b/Runtime/Internal/CoordinateChart.cs @@ -848,7 +848,8 @@ namespace XCharts private Vector3 GetLabelYPosition(float scaleWid, int i, int yAxisIndex, YAxis yAxis) { var grid = GetAxisGridOrDefault(yAxis); - var startX = yAxis.IsLeft() ? grid.runtimeX : grid.runtimeX + grid.runtimeWidth; + var startX = grid.runtimeX + (yAxis.axisLabel.onZero ? m_XAxes[yAxisIndex].runtimeZeroXOffset : 0); + if (yAxis.IsRight()) startX += grid.runtimeWidth; var posX = 0f; var inside = yAxis.axisLabel.inside; if ((inside && yAxis.IsLeft()) || (!inside && yAxis.IsRight())) @@ -1700,7 +1701,7 @@ namespace XCharts { ClampInChart(ref p1); ClampInChart(ref p2); - UGL.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color, toColor,maxDistance); + UGL.DrawZebraLine(vh, p1, p2, size, zebraWidth, zebraGap, color, toColor, maxDistance); } protected Color32 GetXLerpColor(Color32 areaColor, Color32 areaToColor, Vector3 pos, Grid grid)