增加AnimationInteraction交互动画配置支持

This commit is contained in:
monitor1394
2023-07-17 22:15:54 +08:00
parent 58d6d52747
commit 816e26f517
22 changed files with 113 additions and 95 deletions

View File

@@ -413,7 +413,8 @@ namespace XCharts.Runtime
public class AnimationInteraction : AnimationInfo
{
[SerializeField][Since("v3.8.0")] private float m_WidthRate = 1.3f;
[SerializeField][Since("v3.8.0")] private float m_RadiusRate = 1.3f;
[SerializeField][Since("v3.8.0")] private float m_RadiusRate = 1.1f;
[SerializeField][Since("v3.8.0")] private float m_Offset = 8f;
/// <summary>
/// the size rate of the width.
@@ -425,5 +426,16 @@ namespace XCharts.Runtime
/// |半径的放大倍率。
/// </summary>
public float radiusRate { get { return m_RadiusRate; } set { m_RadiusRate = value; } }
/// <summary>
/// the offset when interaction. Such as the offset of the pie chart when the sector is selected.
/// |交互时的偏移。如饼图的扇形选中时的偏移。
/// </summary>
public float offset { get { return m_Offset; } set { m_Offset = value; } }
public float GetRadius(float radius)
{
return radius * radiusRate;
}
}
}

View File

@@ -538,6 +538,14 @@ namespace XCharts.Runtime
return 0;
}
public float GetInteractionRadius(float radius){
if (m_Enable && m_Interaction.enable)
return m_Interaction.GetRadius(radius);
else
return radius;
}
public bool HasFadeOut()
{
return enable && m_FadeOut.context.end;

View File

@@ -15,6 +15,15 @@ namespace XCharts.Runtime
private bool m_ValueEnable = false;
internal float targetVaue { get { return m_TargetValue; } }
internal float previousValue { get { return m_PreviousValue; } }
internal bool valueEnable { get { return m_ValueEnable; } }
internal bool updateFlag { get { return m_UpdateFlag; } }
public override string ToString()
{
return string.Format("m_PreviousValue:{0},m_TargetValue:{1},m_UpdateTime:{2},m_UpdateFlag:{3},m_ValueEnable:{4}",
m_PreviousValue, m_TargetValue, m_UpdateTime, m_UpdateFlag, m_ValueEnable);
}
public void SetValue(ref bool needInteract, float size, bool highlight, float rate = 1.3f)
{
@@ -33,6 +42,10 @@ namespace XCharts.Runtime
m_PreviousValue = m_TargetValue;
m_TargetValue = size;
}
else if (m_UpdateFlag)
{
needInteract = true;
}
}
public void SetColor(ref bool needInteract, Color32 color)
@@ -49,6 +62,10 @@ namespace XCharts.Runtime
}
m_TargetColor = color;
}
else if (m_UpdateFlag)
{
needInteract = true;
}
}
public void SetColor(ref bool needInteract, Color32 color, Color32 toColor)
{
@@ -186,6 +203,7 @@ namespace XCharts.Runtime
public void Reset()
{
Debug.LogError("Reset:"+this);
m_UpdateFlag = false;
m_ValueEnable = false;
m_PreviousValue = float.NaN;

View File

@@ -161,6 +161,7 @@ namespace XCharts.Runtime
}
if (!serieData.show) return;
var serieLabel = SerieHelper.GetSerieLabel(serie, serieData);
if (serieLabel == null) return;
var isOutside = serieLabel.position == LabelStyle.Position.Outside ||
serieLabel.position == LabelStyle.Position.Default;
if (!serieLabel.show) return;
@@ -187,11 +188,11 @@ namespace XCharts.Runtime
var angle = ChartHelper.GetAngle360(Vector2.up, newPos - serie.context.center);
if (angle >= 180 && angle <= 270)
{
serieData.context.labelPosition = new Vector3(isLeft?(++lastX): (--lastX), y1);
serieData.context.labelPosition = new Vector3(isLeft ? (++lastX) : (--lastX), y1);
}
else if (angle < 180 && angle >= 90)
{
serieData.context.labelPosition = new Vector3(isLeft?(++lastX): (--lastX), y1);
serieData.context.labelPosition = new Vector3(isLeft ? (++lastX) : (--lastX), y1);
}
else
{