mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-28 03:58:49 +00:00
[optimize][label] support label rotate
This commit is contained in:
@@ -50,6 +50,7 @@
|
|||||||
|
|
||||||
## master
|
## master
|
||||||
|
|
||||||
|
* (2022.04.19) 增加`Label`的`rotate`支持设置旋转
|
||||||
* (2022.04.17) 修复`Bar`在数值为负数时动画无效的问题
|
* (2022.04.17) 修复`Bar`在数值为负数时动画无效的问题
|
||||||
* (2022.04.17) 增加`ItemStyle`的`BorderGap`支持设置边框间距
|
* (2022.04.17) 增加`ItemStyle`的`BorderGap`支持设置边框间距
|
||||||
* (2022.04.16) 优化`Bar`的`Border`和`Capsule`胶囊柱图
|
* (2022.04.16) 优化`Bar`的`Border`和`Capsule`胶囊柱图
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ namespace XCharts.Editor
|
|||||||
PropertyField(prop, "m_Position");
|
PropertyField(prop, "m_Position");
|
||||||
PropertyField(prop, "m_Offset");
|
PropertyField(prop, "m_Offset");
|
||||||
PropertyField(prop, "m_AutoOffset");
|
PropertyField(prop, "m_AutoOffset");
|
||||||
|
PropertyField(prop, "m_Rotate");
|
||||||
PropertyField(prop, "m_Distance");
|
PropertyField(prop, "m_Distance");
|
||||||
PropertyField(prop, "m_Formatter");
|
PropertyField(prop, "m_Formatter");
|
||||||
PropertyField(prop, "m_NumericFormatter");
|
PropertyField(prop, "m_NumericFormatter");
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ namespace XCharts.Runtime
|
|||||||
[SerializeField] protected bool m_Show = true;
|
[SerializeField] protected bool m_Show = true;
|
||||||
[SerializeField] Position m_Position = Position.Outside;
|
[SerializeField] Position m_Position = Position.Outside;
|
||||||
[SerializeField] protected Vector3 m_Offset;
|
[SerializeField] protected Vector3 m_Offset;
|
||||||
|
[SerializeField] protected float m_Rotate;
|
||||||
[SerializeField] protected float m_Distance;
|
[SerializeField] protected float m_Distance;
|
||||||
[SerializeField] protected string m_Formatter;
|
[SerializeField] protected string m_Formatter;
|
||||||
[SerializeField] protected float m_PaddingLeftRight = 2f;
|
[SerializeField] protected float m_PaddingLeftRight = 2f;
|
||||||
@@ -88,6 +89,7 @@ namespace XCharts.Runtime
|
|||||||
m_Position = Position.Outside;
|
m_Position = Position.Outside;
|
||||||
m_Offset = Vector3.zero;
|
m_Offset = Vector3.zero;
|
||||||
m_Distance = 0;
|
m_Distance = 0;
|
||||||
|
m_Rotate = 0;
|
||||||
m_PaddingLeftRight = 2f;
|
m_PaddingLeftRight = 2f;
|
||||||
m_PaddingTopBottom = 2f;
|
m_PaddingTopBottom = 2f;
|
||||||
m_BackgroundWidth = 0;
|
m_BackgroundWidth = 0;
|
||||||
@@ -142,6 +144,15 @@ namespace XCharts.Runtime
|
|||||||
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
|
set { if (PropertyUtil.SetStruct(ref m_Offset, value)) SetVerticesDirty(); }
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
/// Rotation of label.
|
||||||
|
/// |文本的旋转。
|
||||||
|
/// </summary>
|
||||||
|
public float rotate
|
||||||
|
{
|
||||||
|
get { return m_Rotate; }
|
||||||
|
set { if (PropertyUtil.SetStruct(ref m_Rotate, value)) SetComponentDirty(); }
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
/// 距离轴线的距离。
|
/// 距离轴线的距离。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float distance
|
public float distance
|
||||||
|
|||||||
@@ -27,12 +27,12 @@ namespace XCharts.Runtime
|
|||||||
m_ReleaseDic.Remove(element.GetInstanceID());
|
m_ReleaseDic.Remove(element.GetInstanceID());
|
||||||
element.name = name;
|
element.name = name;
|
||||||
element.transform.SetParent(parent);
|
element.transform.SetParent(parent);
|
||||||
element.transform.localEulerAngles = new Vector3(0, 0, label.textStyle.rotate);
|
|
||||||
var text = new ChartText(element);
|
var text = new ChartText(element);
|
||||||
text.SetColor(color);
|
text.SetColor(color);
|
||||||
text.SetFontAndSizeAndStyle(label.textStyle, theme.common);
|
text.SetFontAndSizeAndStyle(label.textStyle, theme.common);
|
||||||
ChartHelper.SetActive(element, true);
|
ChartHelper.SetActive(element, true);
|
||||||
}
|
}
|
||||||
|
element.transform.localEulerAngles = new Vector3(0, 0, label.rotate);
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ namespace XCharts.Runtime
|
|||||||
{
|
{
|
||||||
GameObject txtObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
GameObject txtObj = AddObject(name, parent, anchorMin, anchorMax, pivot, sizeDelta);
|
||||||
txtObj.transform.localEulerAngles = new Vector3(0, 0, textStyle.rotate);
|
txtObj.transform.localEulerAngles = new Vector3(0, 0, textStyle.rotate);
|
||||||
if(chartText == null)
|
if (chartText == null)
|
||||||
chartText = new ChartText();
|
chartText = new ChartText();
|
||||||
#if dUI_TextMeshPro
|
#if dUI_TextMeshPro
|
||||||
RemoveComponent<Text>(txtObj);
|
RemoveComponent<Text>(txtObj);
|
||||||
@@ -435,9 +435,29 @@ namespace XCharts.Runtime
|
|||||||
internal static GameObject AddSerieLabel(string name, Transform parent, float width, float height,
|
internal static GameObject AddSerieLabel(string name, Transform parent, float width, float height,
|
||||||
Color color, TextStyle textStyle, ThemeStyle theme)
|
Color color, TextStyle textStyle, ThemeStyle theme)
|
||||||
{
|
{
|
||||||
var anchorMin = new Vector2(0.5f, 0.5f);
|
Vector3 anchorMin, anchorMax, pivot;
|
||||||
var anchorMax = new Vector2(0.5f, 0.5f);
|
switch (textStyle.alignment)
|
||||||
var pivot = new Vector2(0.5f, 0.5f);
|
{
|
||||||
|
case TextAnchor.LowerLeft:
|
||||||
|
case TextAnchor.UpperLeft:
|
||||||
|
case TextAnchor.MiddleLeft:
|
||||||
|
anchorMin = new Vector2(0f, 0.5f);
|
||||||
|
anchorMax = new Vector2(0f, 0.5f);
|
||||||
|
pivot = new Vector2(0f, 0.5f);
|
||||||
|
break;
|
||||||
|
case TextAnchor.LowerRight:
|
||||||
|
case TextAnchor.UpperRight:
|
||||||
|
case TextAnchor.MiddleRight:
|
||||||
|
anchorMin = new Vector2(1, 0.5f);
|
||||||
|
anchorMax = new Vector2(1, 0.5f);
|
||||||
|
pivot = new Vector2(1, 0.5f);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
anchorMin = new Vector2(0.5f, 0.5f);
|
||||||
|
anchorMax = new Vector2(0.5f, 0.5f);
|
||||||
|
pivot = new Vector2(0.5f, 0.5f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
var sizeDelta = (width != 0 && height != 0)
|
var sizeDelta = (width != 0 && height != 0)
|
||||||
? new Vector2(width, height)
|
? new Vector2(width, height)
|
||||||
: new Vector2(50, textStyle.GetFontSize(theme.common) + 2);
|
: new Vector2(50, textStyle.GetFontSize(theme.common) + 2);
|
||||||
@@ -450,7 +470,6 @@ namespace XCharts.Runtime
|
|||||||
txt.SetLocalPosition(new Vector2(0, 0));
|
txt.SetLocalPosition(new Vector2(0, 0));
|
||||||
txt.SetLocalEulerAngles(Vector3.zero);
|
txt.SetLocalEulerAngles(Vector3.zero);
|
||||||
labelObj.transform.localPosition = Vector3.zero;
|
labelObj.transform.localPosition = Vector3.zero;
|
||||||
labelObj.transform.localEulerAngles = new Vector3(0, 0, textStyle.rotate);
|
|
||||||
return labelObj;
|
return labelObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user