mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-21 16:00:24 +00:00
增加LineChart的Label配置
This commit is contained in:
@@ -48,6 +48,8 @@ namespace XCharts
|
||||
/// 该数据项的文本标签。
|
||||
/// </summary>
|
||||
public Text label { get; set; }
|
||||
public RectTransform labelRect { get; set; }
|
||||
public Image labelImage { get; set; }
|
||||
/// <summary>
|
||||
/// the maxinum value.
|
||||
/// 最大值。
|
||||
@@ -64,5 +66,31 @@ namespace XCharts
|
||||
if (index >= 0 && index < m_Data.Count) return m_Data[index];
|
||||
else return 0;
|
||||
}
|
||||
|
||||
public void SetLabelActive(bool active)
|
||||
{
|
||||
if (labelImage)
|
||||
{
|
||||
ChartHelper.SetActive(labelImage.gameObject, active);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLabelText(string text)
|
||||
{
|
||||
if (label)
|
||||
{
|
||||
label.text = text;
|
||||
labelRect.sizeDelta = new Vector2(label.preferredWidth + 4,
|
||||
label.preferredHeight + 4);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLabelPosition(Vector3 position)
|
||||
{
|
||||
if (labelImage)
|
||||
{
|
||||
labelImage.transform.localPosition = position;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user