增加LabelStyleautoRotate可设置有角度的竖版文本的自动旋转

This commit is contained in:
monitor1394
2023-03-12 22:56:36 +08:00
parent adbd88c411
commit dbb867e0ab
8 changed files with 45 additions and 16 deletions

View File

@@ -576,13 +576,7 @@ namespace XCharts.Runtime
{
total = context.labelValueList.Count;
}
var labelShow = axisLabel.show && (axisLabel.interval == 0 || index % (axisLabel.interval + 1) == 0);
if (labelShow)
{
if (!axisLabel.showStartLabel && index == 0) labelShow = false;
else if (!axisLabel.showEndLabel && index == total - 1) labelShow = false;
}
return labelShow;
return axisLabel.IsNeedShowLabel(index, total);
}
public void SetNeedUpdateFilterData()

View File

@@ -96,10 +96,10 @@ namespace XCharts.Runtime
return new AxisLabel()
{
m_Show = true,
m_Interval = 0,
m_Inside = false,
m_Distance = 8,
m_TextStyle = new TextStyle(),
m_Interval = 0,
m_Inside = false,
m_Distance = 8,
m_TextStyle = new TextStyle(),
};
}
}
@@ -168,5 +168,16 @@ namespace XCharts.Runtime
}
return base.GetFormatterContent(labelIndex, value, minValue, maxValue, isLog);
}
public bool IsNeedShowLabel(int index, int total)
{
var labelShow = show && (interval == 0 || index % (interval + 1) == 0);
if (labelShow)
{
if (!showStartLabel && index == 0) labelShow = false;
else if (!showEndLabel && index == total - 1) labelShow = false;
}
return labelShow;
}
}
}

View File

@@ -74,6 +74,7 @@ namespace XCharts.Runtime
[SerializeField] protected bool m_AutoOffset = false;
[SerializeField] protected Vector3 m_Offset;
[SerializeField] protected float m_Rotate;
[SerializeField][Since("v3.6.0")] protected bool m_AutoRotate = false;
[SerializeField] protected float m_Distance;
[SerializeField] protected string m_Formatter;
[SerializeField] protected string m_NumericFormatter = "";
@@ -155,6 +156,15 @@ namespace XCharts.Runtime
set { if (PropertyUtil.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
}
/// <summary>
/// auto rotate of label.
/// |是否自动旋转。
/// </summary>
public bool autoRotate
{
get { return m_AutoRotate; }
set { if (PropertyUtil.SetStruct(ref m_AutoRotate, value)) SetComponentDirty(); }
}
/// <summary>
/// 距离轴线的距离。
/// </summary>
public float distance