增加AxisLabelonZero参数可将Label显示在0刻度上

This commit is contained in:
monitor1394
2020-04-19 22:08:40 +08:00
parent 42eec0c3e3
commit d93a62608c
6 changed files with 20 additions and 3 deletions

View File

@@ -29,6 +29,7 @@ namespace XCharts
[SerializeField] private FontStyle m_FontStyle;
[SerializeField] private bool m_ForceENotation = false;
[SerializeField] private bool m_ShowAsPositiveNumber = false;
[SerializeField] private bool m_OnZero = false;
[SerializeField] private TextLimit m_TextLimit = new TextLimit();
/// <summary>
@@ -131,6 +132,15 @@ namespace XCharts
set { if (PropertyUtility.SetStruct(ref m_ShowAsPositiveNumber, value)) SetComponentDirty(); }
}
/// <summary>
/// 刻度标签显示在0刻度上。
/// </summary>
public bool onZero
{
get { return m_OnZero; }
set { if (PropertyUtility.SetStruct(ref m_OnZero, value)) SetComponentDirty(); }
}
/// <summary>
/// 文本限制。
/// </summary>

View File

@@ -757,7 +757,8 @@ namespace XCharts
private Vector3 GetLabelXPosition(float scaleWid, int i, int xAxisIndex, XAxis xAxis)
{
var startY = xAxisIndex == 0 ? coordinateY : coordinateY + coordinateHeight;
var startY = coordinateY + (xAxis.axisLabel.onZero ? m_YAxises[xAxisIndex].runtimeZeroYOffset : 0);
if (xAxisIndex > 0) startY += coordinateHeight;
var posY = 0f;
var inside = xAxis.axisLabel.inside;
if ((inside && xAxisIndex == 0) || (!inside && xAxisIndex == 1))