mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-24 18:00:26 +00:00
增加Animation的Addition动画支持
This commit is contained in:
@@ -13,7 +13,6 @@ namespace XCharts.Editor
|
||||
if (MakeComponentFoldout(prop, "m_Enable", true))
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
//PropertyField(prop, "m_Type");
|
||||
PropertyField(prop, "m_Delay");
|
||||
PropertyField(prop, "m_Duration");
|
||||
--EditorGUI.indentLevel;
|
||||
@@ -21,6 +20,36 @@ namespace XCharts.Editor
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(XCharts.Runtime.AnimationChange), true)]
|
||||
public class AnimationChangeDrawer : BasePropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
base.OnGUI(pos, prop, label);
|
||||
if (MakeComponentFoldout(prop, "m_Enable", true))
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField(prop, "m_Duration");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(XCharts.Runtime.AnimationAddition), true)]
|
||||
public class AnimationAdditionDrawer : BasePropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
|
||||
{
|
||||
base.OnGUI(pos, prop, label);
|
||||
if (MakeComponentFoldout(prop, "m_Enable", true))
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField(prop, "m_Duration");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(AnimationStyle), true)]
|
||||
public class AnimationDrawer : BasePropertyDrawer
|
||||
{
|
||||
@@ -33,10 +62,10 @@ namespace XCharts.Editor
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField(prop, "m_Type");
|
||||
PropertyField(prop, "m_UnscaledTime");
|
||||
PropertyField(prop, "m_FadeIn");
|
||||
PropertyField(prop, "m_FadeOut");
|
||||
PropertyField(prop, "m_Updated");
|
||||
PropertyField(prop, "m_Added");
|
||||
PropertyField(prop, "m_Fadein");
|
||||
PropertyField(prop, "m_Fadeout");
|
||||
PropertyField(prop, "m_Change");
|
||||
PropertyField(prop, "m_Addition");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace XCharts.Example
|
||||
var serie = chart.GetSerie(0);
|
||||
serie.animation.enable = true;
|
||||
//自定义每个数据项的渐入延时
|
||||
serie.animation.fadeIn.delayFunction = CustomFadeInDelay;
|
||||
serie.animation.fadein.delayFunction = CustomFadeInDelay;
|
||||
//自定义每个数据项的渐入时长
|
||||
serie.animation.fadeIn.durationFunction = CustomFadeInDuration;
|
||||
serie.animation.fadein.durationFunction = CustomFadeInDuration;
|
||||
}
|
||||
|
||||
float CustomFadeInDelay(int dataIndex)
|
||||
|
||||
@@ -12,8 +12,16 @@ namespace XCharts.Example
|
||||
//[ExecuteInEditMode]
|
||||
public class Example_RandomData : MonoBehaviour
|
||||
{
|
||||
public int initDataNum = 3;
|
||||
public bool loopAdd = false;
|
||||
public float loopAddTime = 1f;
|
||||
public bool loopUpdate = false;
|
||||
public float loopUpadteTime = 1f;
|
||||
public int maxCache = 0;
|
||||
|
||||
BaseChart chart;
|
||||
float lastAddTime;
|
||||
float lastUpdateTime;
|
||||
int dataCount;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@@ -22,9 +30,11 @@ namespace XCharts.Example
|
||||
|
||||
void Start()
|
||||
{
|
||||
//chart.ClearData();
|
||||
// for (int i = 0; i < initDataNum; i++)
|
||||
// AddData();
|
||||
if (maxCache > 0)
|
||||
{
|
||||
chart.SetMaxCache(maxCache);
|
||||
}
|
||||
dataCount = chart.GetSerie(0).dataCount;
|
||||
}
|
||||
|
||||
void Update()
|
||||
@@ -37,6 +47,19 @@ namespace XCharts.Example
|
||||
{
|
||||
UpdateData();
|
||||
}
|
||||
lastAddTime += Time.deltaTime;
|
||||
if (loopAdd && lastAddTime >= loopAddTime)
|
||||
{
|
||||
lastAddTime = 0;
|
||||
AddData();
|
||||
}
|
||||
|
||||
lastUpdateTime += Time.deltaTime;
|
||||
if (loopUpdate && lastUpdateTime >= loopUpadteTime)
|
||||
{
|
||||
lastUpdateTime = 0;
|
||||
UpdateData();
|
||||
}
|
||||
}
|
||||
|
||||
void AddData()
|
||||
@@ -90,7 +113,10 @@ namespace XCharts.Example
|
||||
}
|
||||
else
|
||||
{
|
||||
chart.AddData(serie.index, Random.Range(10, 90), Random.Range(10, 90), "data" + serie.dataCount);
|
||||
if (serie is Line)
|
||||
chart.AddData(serie.index, dataCount++, Random.Range(10, 90), "data" + serie.dataCount);
|
||||
else
|
||||
chart.AddData(serie.index, Random.Range(10, 90), Random.Range(10, 90), "data" + serie.dataCount);
|
||||
}
|
||||
}
|
||||
else if (serie is Ring)
|
||||
@@ -123,7 +149,7 @@ namespace XCharts.Example
|
||||
var index = Random.Range(0, serie.dataCount);
|
||||
if (serie is Ring)
|
||||
{
|
||||
chart.UpdateData(serie.index, index, Random.Range(10, 90), 100);
|
||||
chart.UpdateData(serie.index, index, 0, Random.Range(10, 90));
|
||||
}
|
||||
else if (serie is Radar)
|
||||
{
|
||||
|
||||
305
Runtime/Component/Animation/AnimationInfo.cs
Normal file
305
Runtime/Component/Animation/AnimationInfo.cs
Normal file
@@ -0,0 +1,305 @@
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
[Since("v3.8.0")]
|
||||
[System.Serializable]
|
||||
public class AnimationInfo
|
||||
{
|
||||
[SerializeField][Since("v3.8.0")] private bool m_Enable = true;
|
||||
[SerializeField][Since("v3.8.0")] private bool m_Reverse = false;
|
||||
[SerializeField][Since("v3.8.0")] private float m_Delay = 0;
|
||||
[SerializeField][Since("v3.8.0")] private float m_Duration = 1000;
|
||||
public AnimationInfoContext context = new AnimationInfoContext();
|
||||
|
||||
public bool enable { get { return m_Enable; } set { m_Enable = value; } }
|
||||
public bool reverse { get { return m_Reverse; } set { m_Reverse = value; } }
|
||||
public float delay { get { return m_Delay; } set { m_Delay = value; } }
|
||||
public float duration { get { return m_Duration; } set { m_Duration = value; } }
|
||||
|
||||
public Action OnAnimationStart { get; set; }
|
||||
public Action OnAnimationEnd { get; set; }
|
||||
|
||||
public AnimationDelayFunction delayFunction { get; set; }
|
||||
public AnimationDurationFunction durationFunction { get; set; }
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (!enable) return;
|
||||
context.init = false;
|
||||
context.start = false;
|
||||
context.pause = false;
|
||||
context.end = false;
|
||||
context.startTime = 0;
|
||||
context.itemCurrProgress.Clear();
|
||||
}
|
||||
|
||||
public void Start(bool reset = true)
|
||||
{
|
||||
if (!enable) return;
|
||||
if (context.start) return;
|
||||
if (context.pause)
|
||||
{
|
||||
context.pause = false;
|
||||
return;
|
||||
}
|
||||
context.init = false;
|
||||
context.start = true;
|
||||
context.end = false;
|
||||
context.pause = false;
|
||||
context.startTime = Time.time;
|
||||
if (reset)
|
||||
{
|
||||
context.currProgress = 0;
|
||||
context.destProgress = 1;
|
||||
context.totalProgress = 0;
|
||||
context.sizeProgress = 0;
|
||||
context.itemCurrProgress.Clear();
|
||||
context.itemDestProgress.Clear();
|
||||
}
|
||||
if (OnAnimationStart != null)
|
||||
{
|
||||
OnAnimationStart();
|
||||
}
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
if (!enable) return;
|
||||
if (!context.start || context.end) return;
|
||||
context.pause = true;
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
if (!enable) return;
|
||||
if (!context.pause) return;
|
||||
context.pause = false;
|
||||
}
|
||||
|
||||
public void End()
|
||||
{
|
||||
if (!enable) return;
|
||||
if (!context.start || context.end) return;
|
||||
context.start = false;
|
||||
context.end = true;
|
||||
context.currPointIndex = context.destPointIndex;
|
||||
context.startTime = Time.time;
|
||||
if (OnAnimationEnd != null)
|
||||
{
|
||||
OnAnimationEnd();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Init(float curr, float dest, int totalPointIndex)
|
||||
{
|
||||
if (!enable || !context.start) return false;
|
||||
if (context.init || context.end) return false;
|
||||
context.init = true;
|
||||
context.totalProgress = dest - curr;
|
||||
context.destPointIndex = totalPointIndex;
|
||||
if (reverse)
|
||||
{
|
||||
context.currProgress = dest;
|
||||
context.destProgress = curr;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.currProgress = curr;
|
||||
context.destProgress = dest;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsFinish()
|
||||
{
|
||||
if (!context.start) return true;
|
||||
if (context.end) return true;
|
||||
if (context.pause) return false;
|
||||
return context.currProgress == context.destProgress;
|
||||
}
|
||||
|
||||
public bool IsInDelay()
|
||||
{
|
||||
if (!context.start)
|
||||
return false;
|
||||
else
|
||||
return (m_Delay > 0 && Time.time - context.startTime < m_Delay / 1000);
|
||||
}
|
||||
|
||||
public bool IsInIndexDelay(int dataIndex)
|
||||
{
|
||||
if (context.start)
|
||||
return Time.time - context.startTime < GetIndexDelay(dataIndex) / 1000f;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public float GetIndexDelay(int dataIndex)
|
||||
{
|
||||
if (!context.start) return 0;
|
||||
if (delayFunction != null)
|
||||
return delayFunction(dataIndex);
|
||||
return delay;
|
||||
}
|
||||
|
||||
internal float GetCurrAnimationDuration(int dataIndex = -1)
|
||||
{
|
||||
if (dataIndex >= 0)
|
||||
{
|
||||
if (context.start && durationFunction != null)
|
||||
return durationFunction(dataIndex) / 1000f;
|
||||
}
|
||||
return m_Duration > 0 ? m_Duration / 1000 : 1f;
|
||||
}
|
||||
|
||||
internal void SetDataCurrProgress(int index, float state)
|
||||
{
|
||||
context.itemCurrProgress[index] = state;
|
||||
}
|
||||
|
||||
|
||||
internal float GetDataCurrProgress(int index, float initValue, float destValue, ref bool isBarEnd)
|
||||
{
|
||||
if (IsInDelay())
|
||||
{
|
||||
isBarEnd = false;
|
||||
return initValue;
|
||||
}
|
||||
var c1 = !context.itemCurrProgress.ContainsKey(index);
|
||||
var c2 = !context.itemDestProgress.ContainsKey(index);
|
||||
if (c1 || c2)
|
||||
{
|
||||
if (c1)
|
||||
context.itemCurrProgress.Add(index, initValue);
|
||||
|
||||
if (c2)
|
||||
context.itemDestProgress.Add(index, destValue);
|
||||
|
||||
isBarEnd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
isBarEnd = context.itemCurrProgress[index] == context.itemDestProgress[index];
|
||||
}
|
||||
return context.itemCurrProgress[index];
|
||||
}
|
||||
|
||||
internal void CheckProgress(double total, bool m_UnscaledTime)
|
||||
{
|
||||
if (!context.start || !context.init || context.pause) return;
|
||||
if (IsInDelay()) return;
|
||||
var duration = GetCurrAnimationDuration();
|
||||
var delta = (float)(total / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime));
|
||||
if (reverse)
|
||||
{
|
||||
context.currProgress -= delta;
|
||||
if (context.currProgress <= context.destProgress)
|
||||
{
|
||||
context.currProgress = context.destProgress;
|
||||
End();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
context.currProgress += delta;
|
||||
if (context.currProgress >= context.destProgress)
|
||||
{
|
||||
context.currProgress = context.destProgress;
|
||||
End();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal float CheckItemProgress(int dataIndex, float destProgress, ref bool isEnd, float startProgress, bool m_UnscaledTime)
|
||||
{
|
||||
var currHig = GetDataCurrProgress(dataIndex, startProgress, destProgress, ref isEnd);
|
||||
if (IsFinish())
|
||||
{
|
||||
return reverse ? startProgress : destProgress;
|
||||
}
|
||||
else if (IsInDelay() || IsInIndexDelay(dataIndex))
|
||||
{
|
||||
return reverse ? destProgress : startProgress;
|
||||
}
|
||||
else if (context.pause)
|
||||
{
|
||||
return currHig;
|
||||
}
|
||||
else
|
||||
{
|
||||
var duration = GetCurrAnimationDuration(dataIndex);
|
||||
var delta = (destProgress - startProgress) / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
|
||||
currHig = currHig + (reverse ? -delta : delta);
|
||||
if (reverse)
|
||||
{
|
||||
if ((destProgress > 0 && currHig <= 0) || (destProgress < 0 && currHig >= 0))
|
||||
{
|
||||
currHig = 0;
|
||||
isEnd = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((destProgress - startProgress > 0 && currHig > destProgress) ||
|
||||
(destProgress - startProgress < 0 && currHig < destProgress))
|
||||
{
|
||||
currHig = destProgress;
|
||||
isEnd = true;
|
||||
}
|
||||
}
|
||||
SetDataCurrProgress(dataIndex, currHig);
|
||||
return currHig;
|
||||
}
|
||||
}
|
||||
|
||||
internal void CheckSymbol(float dest, bool m_UnscaledTime)
|
||||
{
|
||||
if (!context.start || !context.init || context.pause) return;
|
||||
|
||||
if (IsInDelay())
|
||||
return;
|
||||
|
||||
var duration = GetCurrAnimationDuration();
|
||||
var delta = dest / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
|
||||
if (reverse)
|
||||
{
|
||||
context.sizeProgress -= delta;
|
||||
if (context.sizeProgress < 0)
|
||||
context.sizeProgress = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.sizeProgress += delta;
|
||||
if (context.sizeProgress > dest)
|
||||
context.sizeProgress = dest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Since("v3.8.0")]
|
||||
[System.Serializable]
|
||||
public class AnimationFadeIn : AnimationInfo
|
||||
{
|
||||
}
|
||||
|
||||
[Since("v3.8.0")]
|
||||
[System.Serializable]
|
||||
public class AnimationFadeOut : AnimationInfo
|
||||
{
|
||||
}
|
||||
|
||||
[Since("v3.8.0")]
|
||||
[System.Serializable]
|
||||
public class AnimationChange : AnimationInfo
|
||||
{
|
||||
}
|
||||
|
||||
[Since("v3.8.0")]
|
||||
[System.Serializable]
|
||||
public class AnimationAddition : AnimationInfo
|
||||
{
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Animation/AnimationInfo.cs.meta
Normal file
11
Runtime/Component/Animation/AnimationInfo.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae54b92d6276445ac9524b598bfb6e84
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
23
Runtime/Component/Animation/AnimationInfoContext.cs
Normal file
23
Runtime/Component/Animation/AnimationInfoContext.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace XCharts.Runtime
|
||||
{
|
||||
public sealed class AnimationInfoContext
|
||||
{
|
||||
public bool init;
|
||||
public bool start;
|
||||
public bool pause;
|
||||
public bool end;
|
||||
public float startTime;
|
||||
public float currProgress;
|
||||
public float destProgress;
|
||||
public float totalProgress;
|
||||
public float sizeProgress;
|
||||
public int currPointIndex;
|
||||
public int destPointIndex;
|
||||
public Dictionary<int, float> itemCurrProgress = new Dictionary<int, float>();
|
||||
public Dictionary<int, float> itemDestProgress = new Dictionary<int, float>();
|
||||
}
|
||||
}
|
||||
11
Runtime/Component/Animation/AnimationInfoContext.cs.meta
Normal file
11
Runtime/Component/Animation/AnimationInfoContext.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 023c7390605c34a72b13f5db7a647f06
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -43,55 +43,9 @@ namespace XCharts.Runtime
|
||||
Linear,
|
||||
}
|
||||
|
||||
[Since("v3.8.0")]
|
||||
[System.Serializable]
|
||||
public class AnimationInfo
|
||||
{
|
||||
[SerializeField][Since("v3.8.0")] private bool m_Enable = true;
|
||||
[SerializeField][Since("v3.8.0")] private float m_Delay = 0;
|
||||
[SerializeField][Since("v3.8.0")] private float m_Duration = 1000;
|
||||
|
||||
public bool enable { get { return m_Enable; } set { m_Enable = value; } }
|
||||
public float delay { get { return m_Delay; } set { m_Delay = value; } }
|
||||
public float duration { get { return m_Duration; } set { m_Duration = value; } }
|
||||
|
||||
public Action OnAnimationStart { get; set; }
|
||||
public Action OnAnimationEnd { get; set; }
|
||||
|
||||
public AnimationDelayFunction delayFunction { get; set; }
|
||||
public AnimationDurationFunction durationFunction { get; set; }
|
||||
|
||||
internal bool start { get; set; }
|
||||
internal bool end { get; set; }
|
||||
}
|
||||
|
||||
[Since("v3.8.0")]
|
||||
[System.Serializable]
|
||||
public class AnimationFadeIn : AnimationInfo
|
||||
{
|
||||
}
|
||||
|
||||
[Since("v3.8.0")]
|
||||
[System.Serializable]
|
||||
public class AnimationFadeOut : AnimationInfo
|
||||
{
|
||||
}
|
||||
|
||||
[Since("v3.8.0")]
|
||||
[System.Serializable]
|
||||
public class AnimationUpdated : AnimationInfo
|
||||
{
|
||||
}
|
||||
|
||||
[Since("v3.8.0")]
|
||||
[System.Serializable]
|
||||
public class AnimationAdded : AnimationInfo
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// the animation of serie.
|
||||
/// |动画表现。
|
||||
/// the animation of serie. support animation type: fadeIn, fadeOut, change, addition.
|
||||
/// |动画表现。支持配置四种动画表现:FadeIn(渐入动画),FadeOut(渐出动画),Change(变更动画),Addition(新增动画)。
|
||||
/// </summary>
|
||||
[System.Serializable]
|
||||
public class AnimationStyle : ChildComponent
|
||||
@@ -101,10 +55,10 @@ namespace XCharts.Runtime
|
||||
[SerializeField] private AnimationEasing m_Easting;
|
||||
[SerializeField] private int m_Threshold = 2000;
|
||||
[SerializeField][Since("v3.4.0")] private bool m_UnscaledTime;
|
||||
[SerializeField][Since("v3.8.0")] private AnimationFadeIn m_FadeIn = new AnimationFadeIn();
|
||||
[SerializeField][Since("v3.8.0")] private AnimationFadeOut m_FadeOut = new AnimationFadeOut();
|
||||
[SerializeField][Since("v3.8.0")] private AnimationUpdated m_Updated = new AnimationUpdated() { duration = 500 };
|
||||
[SerializeField][Since("v3.8.0")] private AnimationAdded m_Added = new AnimationAdded() { duration = 500 };
|
||||
[SerializeField][Since("v3.8.0")] private AnimationFadeIn m_Fadein = new AnimationFadeIn();
|
||||
[SerializeField][Since("v3.8.0")] private AnimationFadeOut m_Fadeout = new AnimationFadeOut() { reverse = true };
|
||||
[SerializeField][Since("v3.8.0")] private AnimationChange m_Change = new AnimationChange() { duration = 500 };
|
||||
[SerializeField][Since("v3.8.0")] private AnimationAddition m_Addition = new AnimationAddition() { duration = 500 };
|
||||
|
||||
[Obsolete("Use animation.fadeIn.delayFunction instead.", true)]
|
||||
public AnimationDelayFunction fadeInDelayFunction;
|
||||
@@ -144,168 +98,146 @@ namespace XCharts.Runtime
|
||||
/// Fade in animation configuration.
|
||||
/// |渐入动画配置。
|
||||
/// </summary>
|
||||
public AnimationFadeIn fadeIn { get { return m_FadeIn; } }
|
||||
public AnimationFadeIn fadein { get { return m_Fadein; } }
|
||||
/// <summary>
|
||||
/// Fade out animation configuration.
|
||||
/// |渐出动画配置。
|
||||
/// </summary>
|
||||
public AnimationFadeOut fadeOut { get { return m_FadeOut; } }
|
||||
public AnimationFadeOut fadeout { get { return m_Fadeout; } }
|
||||
/// <summary>
|
||||
/// Update data animation configuration.
|
||||
/// |更新数据动画配置。
|
||||
/// |数据变更动画配置。
|
||||
/// </summary>
|
||||
public AnimationUpdated updated { get { return m_Updated; } }
|
||||
public AnimationChange change { get { return m_Change; } }
|
||||
/// <summary>
|
||||
/// Add data animation configuration.
|
||||
/// |添加数据动画配置。
|
||||
/// |数据新增动画配置。
|
||||
/// </summary>
|
||||
public AnimationAdded added { get { return m_Added; } }
|
||||
public AnimationAddition addition { get { return m_Addition; } }
|
||||
|
||||
private Dictionary<int, float> m_ItemCurrProgress = new Dictionary<int, float>();
|
||||
private Dictionary<int, float> m_ItemDestProgress = new Dictionary<int, float>();
|
||||
private bool m_IsEnd = true;
|
||||
private bool m_IsPause = false;
|
||||
private bool m_IsInit = false;
|
||||
|
||||
private float startTime { get; set; }
|
||||
private float m_CurrDetailProgress;
|
||||
private float m_DestDetailProgress;
|
||||
private float m_TotalDetailProgress;
|
||||
private float m_CurrSymbolProgress;
|
||||
private Vector3 m_LinePathLastPos;
|
||||
|
||||
public void FadeIn()
|
||||
private List<AnimationInfo> m_Animations;
|
||||
private List<AnimationInfo> animations
|
||||
{
|
||||
if (m_FadeOut.start)
|
||||
return;
|
||||
|
||||
if (m_IsPause)
|
||||
get
|
||||
{
|
||||
m_IsPause = false;
|
||||
return;
|
||||
if (m_Animations == null)
|
||||
{
|
||||
m_Animations = new List<AnimationInfo>();
|
||||
m_Animations.Add(m_Fadein);
|
||||
m_Animations.Add(m_Fadeout);
|
||||
m_Animations.Add(m_Change);
|
||||
m_Animations.Add(m_Addition);
|
||||
}
|
||||
return m_Animations;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_FadeIn.start)
|
||||
return;
|
||||
public AnimationInfo activedAnimation
|
||||
{
|
||||
get
|
||||
{
|
||||
foreach (var anim in animations)
|
||||
{
|
||||
if (anim.context.start) return anim;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
startTime = Time.time;
|
||||
m_FadeIn.start = true;
|
||||
m_IsEnd = false;
|
||||
m_IsInit = false;
|
||||
m_IsPause = false;
|
||||
m_FadeOut.end = false;
|
||||
m_CurrDetailProgress = 0;
|
||||
m_DestDetailProgress = 1;
|
||||
m_CurrSymbolProgress = 0;
|
||||
m_ItemCurrProgress.Clear();
|
||||
m_ItemDestProgress.Clear();
|
||||
public void Fadein()
|
||||
{
|
||||
if (m_Fadeout.context.start) return;
|
||||
m_Fadein.Start();
|
||||
}
|
||||
|
||||
public void Restart()
|
||||
{
|
||||
var anim = activedAnimation;
|
||||
Reset();
|
||||
FadeIn();
|
||||
if (anim != null)
|
||||
{
|
||||
anim.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeOut()
|
||||
public void Fadeout()
|
||||
{
|
||||
if (m_IsPause)
|
||||
{
|
||||
m_IsPause = false;
|
||||
return;
|
||||
}
|
||||
m_Fadeout.Start();
|
||||
}
|
||||
|
||||
m_FadeOut.start = true;
|
||||
startTime = Time.time;
|
||||
m_FadeIn.start = true;
|
||||
m_IsEnd = false;
|
||||
m_IsInit = false;
|
||||
m_IsPause = false;
|
||||
m_CurrDetailProgress = 0;
|
||||
m_DestDetailProgress = 1;
|
||||
m_CurrSymbolProgress = 0;
|
||||
m_ItemCurrProgress.Clear();
|
||||
m_ItemDestProgress.Clear();
|
||||
public void Addition()
|
||||
{
|
||||
if (!enable) return;
|
||||
if (!m_Fadein.context.start && !m_Fadeout.context.start)
|
||||
{
|
||||
m_Addition.Start(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
if (!m_IsPause)
|
||||
foreach (var anim in animations)
|
||||
{
|
||||
m_IsPause = true;
|
||||
anim.Pause();
|
||||
}
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
if (m_IsPause)
|
||||
foreach (var anim in animations)
|
||||
{
|
||||
m_IsPause = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void End()
|
||||
{
|
||||
if (m_IsEnd)
|
||||
return;
|
||||
|
||||
m_IsEnd = true;
|
||||
m_IsInit = false;
|
||||
|
||||
if (m_FadeIn.start)
|
||||
{
|
||||
m_FadeIn.start = false;
|
||||
if (m_FadeIn.OnAnimationEnd != null)
|
||||
{
|
||||
m_FadeIn.OnAnimationEnd();
|
||||
}
|
||||
}
|
||||
if (m_FadeOut.start)
|
||||
{
|
||||
m_FadeOut.start = false;
|
||||
m_FadeOut.end = true;
|
||||
if (m_FadeOut.OnAnimationEnd != null)
|
||||
{
|
||||
m_FadeOut.OnAnimationEnd();
|
||||
}
|
||||
anim.Resume();
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_FadeIn.start = false;
|
||||
m_IsEnd = true;
|
||||
m_IsInit = false;
|
||||
m_IsPause = false;
|
||||
m_FadeOut.start = false;
|
||||
m_FadeOut.end = false;
|
||||
m_ItemCurrProgress.Clear();
|
||||
m_Fadein.Reset();
|
||||
m_Fadeout.Reset();
|
||||
}
|
||||
|
||||
public void InitProgress(float curr, float dest)
|
||||
{
|
||||
if (m_IsInit || m_IsEnd)
|
||||
return;
|
||||
|
||||
m_IsInit = true;
|
||||
m_TotalDetailProgress = dest - curr;
|
||||
|
||||
if (m_FadeOut.start)
|
||||
var anim = activedAnimation;
|
||||
if (anim == null) return;
|
||||
var isAddedAnim = anim is AnimationAddition;
|
||||
if (IsIndexAnimation())
|
||||
{
|
||||
m_CurrDetailProgress = dest;
|
||||
m_DestDetailProgress = curr;
|
||||
if (isAddedAnim)
|
||||
{
|
||||
anim.Init(anim.context.currPointIndex, dest, (int)dest - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Addition.context.currPointIndex = (int)dest - 1;
|
||||
anim.Init(curr, dest, (int)dest - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CurrDetailProgress = curr;
|
||||
m_DestDetailProgress = dest;
|
||||
anim.Init(curr, dest, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void InitProgress(List<Vector3> paths, bool isY)
|
||||
{
|
||||
if (paths.Count < 1) return;
|
||||
var sp = paths[0];
|
||||
var anim = activedAnimation;
|
||||
if (anim == null) return;
|
||||
var isAddedAnim = anim is AnimationAddition;
|
||||
var startIndex = 0;
|
||||
if (isAddedAnim)
|
||||
{
|
||||
startIndex = anim.context.currPointIndex == paths.Count - 1 ?
|
||||
paths.Count - 2 :
|
||||
anim.context.currPointIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Addition.context.currPointIndex = paths.Count - 1;
|
||||
}
|
||||
var sp = paths[startIndex];
|
||||
var ep = paths[paths.Count - 1];
|
||||
var currDetailProgress = isY ? sp.y : sp.x;
|
||||
var totalDetailProgress = isY ? ep.y : ep.x;
|
||||
@@ -319,43 +251,25 @@ namespace XCharts.Runtime
|
||||
var np = paths[i];
|
||||
totalDetailProgress += Vector3.Distance(np, lp);
|
||||
lp = np;
|
||||
if (startIndex > 0 && i == startIndex)
|
||||
currDetailProgress = totalDetailProgress;
|
||||
}
|
||||
m_LinePathLastPos = sp;
|
||||
context.currentPathDistance = 0;
|
||||
}
|
||||
InitProgress(currDetailProgress, totalDetailProgress);
|
||||
anim.Init(currDetailProgress, totalDetailProgress, paths.Count - 1);
|
||||
}
|
||||
|
||||
private void SetDataCurrProgress(int index, float state)
|
||||
public bool IsEnd()
|
||||
{
|
||||
m_ItemCurrProgress[index] = state;
|
||||
foreach (var animation in animations)
|
||||
{
|
||||
if (animation.context.start)
|
||||
return animation.context.end;
|
||||
}
|
||||
return m_Fadein.context.end;
|
||||
}
|
||||
|
||||
private float GetDataCurrProgress(int index, float initValue, float destValue, ref bool isBarEnd)
|
||||
{
|
||||
if (IsInDelay())
|
||||
{
|
||||
isBarEnd = false;
|
||||
return initValue;
|
||||
}
|
||||
var c1 = !m_ItemCurrProgress.ContainsKey(index);
|
||||
var c2 = !m_ItemDestProgress.ContainsKey(index);
|
||||
if (c1 || c2)
|
||||
{
|
||||
if (c1)
|
||||
m_ItemCurrProgress.Add(index, initValue);
|
||||
|
||||
if (c2)
|
||||
m_ItemDestProgress.Add(index, destValue);
|
||||
|
||||
isBarEnd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
isBarEnd = m_ItemCurrProgress[index] == m_ItemDestProgress[index];
|
||||
}
|
||||
return m_ItemCurrProgress[index];
|
||||
}
|
||||
|
||||
public bool IsFinish()
|
||||
{
|
||||
@@ -363,29 +277,34 @@ namespace XCharts.Runtime
|
||||
if (!Application.isPlaying)
|
||||
return true;
|
||||
#endif
|
||||
if (!m_Enable || m_IsEnd)
|
||||
if (!m_Enable)
|
||||
return true;
|
||||
foreach (var animation in animations)
|
||||
{
|
||||
if (animation.context.start && animation.context.end)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (IsIndexAnimation())
|
||||
{
|
||||
if (m_FadeOut.start) return m_CurrDetailProgress <= m_DestDetailProgress;
|
||||
else return m_CurrDetailProgress > m_DestDetailProgress;
|
||||
if (m_Fadeout.context.start) return m_Fadeout.context.currProgress <= m_Fadeout.context.destProgress;
|
||||
else if (m_Addition.context.start) return m_Addition.context.currProgress >= m_Addition.context.destProgress;
|
||||
else return m_Fadein.context.currProgress >= m_Fadein.context.destProgress;
|
||||
}
|
||||
if (IsItemAnimation())
|
||||
else if (IsItemAnimation())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsInFadeOut()
|
||||
{
|
||||
return m_FadeOut.start;
|
||||
}
|
||||
|
||||
public bool IsInDelay()
|
||||
{
|
||||
if (m_FadeOut.start)
|
||||
return (m_FadeOut.delay > 0 && Time.time - startTime < m_FadeOut.delay / 1000);
|
||||
else
|
||||
return (m_FadeIn.delay > 0 && Time.time - startTime < m_FadeIn.delay / 1000);
|
||||
var anim = activedAnimation;
|
||||
if (anim != null)
|
||||
return anim.IsInDelay();
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsItemAnimation()
|
||||
@@ -396,41 +315,19 @@ namespace XCharts.Runtime
|
||||
public bool IsIndexAnimation()
|
||||
{
|
||||
return context.type == AnimationType.LeftToRight ||
|
||||
context.type == AnimationType.Clockwise ||
|
||||
context.type == AnimationType.AlongPath;
|
||||
}
|
||||
|
||||
public float GetIndexDelay(int dataIndex)
|
||||
{
|
||||
if (m_FadeOut.start && m_FadeOut.delayFunction != null)
|
||||
return m_FadeOut.delayFunction(dataIndex);
|
||||
else if (m_FadeIn.start && m_FadeIn.delayFunction != null)
|
||||
return m_FadeIn.delayFunction(dataIndex);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public bool IsInIndexDelay(int dataIndex)
|
||||
{
|
||||
return Time.time - startTime < GetIndexDelay(dataIndex) / 1000f;
|
||||
}
|
||||
|
||||
public bool IsAllOutDelay(int dataCount)
|
||||
{
|
||||
var nowTime = Time.time - startTime;
|
||||
for (int i = 0; i < dataCount; i++)
|
||||
{
|
||||
if (nowTime < GetIndexDelay(i) / 1000)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
context.type == AnimationType.AlongPath || context.type == AnimationType.Clockwise;
|
||||
}
|
||||
|
||||
public bool CheckDetailBreak(float detail)
|
||||
{
|
||||
if (!IsIndexAnimation())
|
||||
return false;
|
||||
return !IsFinish() && detail > m_CurrDetailProgress;
|
||||
foreach (var animation in animations)
|
||||
{
|
||||
if (animation.context.start)
|
||||
return !IsFinish() && detail > animation.context.currProgress;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool CheckDetailBreak(Vector3 pos, bool isYAxis)
|
||||
@@ -450,9 +347,9 @@ namespace XCharts.Runtime
|
||||
else
|
||||
{
|
||||
if (isYAxis)
|
||||
return pos.y > m_CurrDetailProgress;
|
||||
return pos.y > GetCurrDetail();
|
||||
else
|
||||
return pos.x > m_CurrDetailProgress;
|
||||
return pos.x > GetCurrDetail();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,128 +357,40 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (IsItemAnimation() && context.isAllItemAnimationEnd)
|
||||
{
|
||||
End();
|
||||
foreach (var animation in animations)
|
||||
{
|
||||
animation.End();
|
||||
}
|
||||
return;
|
||||
}
|
||||
CheckProgress(m_TotalDetailProgress);
|
||||
foreach (var animation in animations)
|
||||
{
|
||||
animation.CheckProgress(animation.context.totalProgress, m_UnscaledTime);
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckProgress(double total)
|
||||
{
|
||||
if (IsFinish())
|
||||
return;
|
||||
|
||||
if (!m_IsInit || m_IsPause || m_IsEnd)
|
||||
return;
|
||||
|
||||
if (IsInDelay())
|
||||
return;
|
||||
|
||||
var duration = GetCurrAnimationDuration();
|
||||
var delta = (float)(total / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime));
|
||||
if (m_FadeOut.start)
|
||||
foreach (var animation in animations)
|
||||
{
|
||||
m_CurrDetailProgress -= delta;
|
||||
if (m_CurrDetailProgress <= m_DestDetailProgress)
|
||||
{
|
||||
m_CurrDetailProgress = m_DestDetailProgress;
|
||||
End();
|
||||
}
|
||||
animation.CheckProgress(total, m_UnscaledTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CurrDetailProgress += delta;
|
||||
if (m_CurrDetailProgress >= m_DestDetailProgress)
|
||||
{
|
||||
m_CurrDetailProgress = m_DestDetailProgress;
|
||||
End();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal float GetCurrAnimationDuration(int dataIndex = -1)
|
||||
{
|
||||
if (dataIndex >= 0)
|
||||
{
|
||||
if (m_FadeOut.start && m_FadeOut.durationFunction != null)
|
||||
return m_FadeOut.durationFunction(dataIndex) / 1000f;
|
||||
if (m_FadeIn.start && m_FadeIn.durationFunction != null)
|
||||
return m_FadeIn.durationFunction(dataIndex) / 1000f;
|
||||
}
|
||||
|
||||
if (m_FadeOut.start)
|
||||
return m_FadeOut.delay > 0 ? m_FadeOut.delay / 1000 : 1f;
|
||||
else
|
||||
return m_FadeIn.delay > 0 ? m_FadeIn.delay / 1000 : 1f;
|
||||
}
|
||||
|
||||
internal float CheckItemProgress(int dataIndex, float destProgress, ref bool isEnd, float startProgress = 0)
|
||||
{
|
||||
isEnd = false;
|
||||
var initHig = m_FadeOut.start ? destProgress : startProgress;
|
||||
var destHig = m_FadeOut.start ? startProgress : destProgress;
|
||||
var currHig = GetDataCurrProgress(dataIndex, initHig, destHig, ref isEnd);
|
||||
if (isEnd || IsFinish())
|
||||
{
|
||||
return m_FadeOut.end ? startProgress : destProgress;
|
||||
}
|
||||
else if (IsInDelay() || IsInIndexDelay(dataIndex))
|
||||
{
|
||||
return m_FadeOut.start ? destProgress : startProgress;
|
||||
}
|
||||
else if (m_IsPause)
|
||||
{
|
||||
return currHig;
|
||||
}
|
||||
else
|
||||
{
|
||||
var duration = GetCurrAnimationDuration(dataIndex);
|
||||
var delta = (destProgress - startProgress) / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
|
||||
currHig = currHig + (m_FadeOut.start ? -delta : delta);
|
||||
if (m_FadeOut.start)
|
||||
{
|
||||
if ((initHig > 0 && currHig <= 0) || (initHig < 0 && currHig >= 0))
|
||||
{
|
||||
currHig = 0;
|
||||
isEnd = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((destProgress - startProgress > 0 && currHig > destProgress) ||
|
||||
(destProgress - startProgress < 0 && currHig < destProgress))
|
||||
{
|
||||
currHig = destProgress;
|
||||
isEnd = true;
|
||||
}
|
||||
}
|
||||
SetDataCurrProgress(dataIndex, currHig);
|
||||
return currHig;
|
||||
}
|
||||
var anim = activedAnimation;
|
||||
if (anim == null) return destProgress;
|
||||
return anim.CheckItemProgress(dataIndex, destProgress, ref isEnd, startProgress, m_UnscaledTime);
|
||||
}
|
||||
|
||||
public void CheckSymbol(float dest)
|
||||
{
|
||||
if (!enable || m_IsEnd || m_IsPause || !m_IsInit)
|
||||
return;
|
||||
|
||||
if (IsInDelay())
|
||||
return;
|
||||
|
||||
var duration = GetCurrAnimationDuration();
|
||||
var delta = dest / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
|
||||
if (m_FadeOut.start)
|
||||
{
|
||||
m_CurrSymbolProgress -= delta;
|
||||
if (m_CurrSymbolProgress < 0)
|
||||
m_CurrSymbolProgress = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CurrSymbolProgress += delta;
|
||||
if (m_CurrSymbolProgress > dest)
|
||||
m_CurrSymbolProgress = dest;
|
||||
}
|
||||
m_Fadein.CheckSymbol(dest, m_UnscaledTime);
|
||||
m_Fadeout.CheckSymbol(dest, m_UnscaledTime);
|
||||
}
|
||||
|
||||
public float GetSysmbolSize(float dest)
|
||||
@@ -593,19 +402,30 @@ namespace XCharts.Runtime
|
||||
if (!enable)
|
||||
return dest;
|
||||
|
||||
if (m_IsEnd)
|
||||
return m_FadeOut.start ? 0 : dest;
|
||||
if (IsEnd())
|
||||
return m_Fadeout.context.start ? 0 : dest;
|
||||
|
||||
return m_CurrSymbolProgress;
|
||||
return m_Fadeout.context.start ? m_Fadeout.context.sizeProgress : m_Fadein.context.sizeProgress;
|
||||
}
|
||||
|
||||
public float GetCurrDetail()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
return m_DestDetailProgress;
|
||||
{
|
||||
foreach (var animation in animations)
|
||||
{
|
||||
if (animation.context.start)
|
||||
return animation.context.destProgress;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return m_CurrDetailProgress;
|
||||
foreach (var animation in animations)
|
||||
{
|
||||
if (animation.context.start)
|
||||
return animation.context.currProgress;
|
||||
}
|
||||
return m_Fadein.context.currProgress;
|
||||
}
|
||||
|
||||
public float GetCurrRate()
|
||||
@@ -614,9 +434,9 @@ namespace XCharts.Runtime
|
||||
if (!Application.isPlaying)
|
||||
return 1;
|
||||
#endif
|
||||
if (!enable || m_IsEnd)
|
||||
if (!enable || IsEnd())
|
||||
return 1;
|
||||
return m_CurrDetailProgress;
|
||||
return m_Fadeout.context.start ? m_Fadeout.context.currProgress : m_Fadein.context.currProgress;
|
||||
}
|
||||
|
||||
public int GetCurrIndex()
|
||||
@@ -625,30 +445,33 @@ namespace XCharts.Runtime
|
||||
if (!Application.isPlaying)
|
||||
return -1;
|
||||
#endif
|
||||
if (!enable || m_IsEnd)
|
||||
if (!enable)
|
||||
return -1;
|
||||
return (int)m_CurrDetailProgress;
|
||||
var anim = activedAnimation;
|
||||
if (anim == null)
|
||||
return -1;
|
||||
return (int)anim.context.currProgress;
|
||||
}
|
||||
|
||||
public float GetDataChangeDuration()
|
||||
public float GetChangeDuration()
|
||||
{
|
||||
if (m_Enable && m_Updated.enable)
|
||||
return m_Updated.duration;
|
||||
if (m_Enable && m_Change.enable)
|
||||
return m_Change.duration;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float GetDataAddDuration()
|
||||
public float GetAdditionDuration()
|
||||
{
|
||||
if (m_Enable && m_Added.enable)
|
||||
return m_Added.duration;
|
||||
if (m_Enable && m_Addition.enable)
|
||||
return m_Addition.duration;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public bool HasFadeOut()
|
||||
public bool HasFadeout()
|
||||
{
|
||||
return enable && m_FadeOut.end && m_IsEnd;
|
||||
return enable && m_Fadeout.context.end;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ namespace XCharts.Runtime
|
||||
public struct AnimationStyleContext
|
||||
{
|
||||
public AnimationType type;
|
||||
public bool enableSerieDataAddedAnimation;
|
||||
public float currentPathDistance;
|
||||
public bool isAllItemAnimationEnd;
|
||||
}
|
||||
|
||||
@@ -30,18 +30,22 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var serieType = serie.GetType();
|
||||
var animationType = AnimationType.LeftToRight;
|
||||
var enableSerieDataAnimation = true;
|
||||
if (serieType.IsDefined(typeof(DefaultAnimationAttribute), false))
|
||||
{
|
||||
animationType = serieType.GetAttribute<DefaultAnimationAttribute>().type;
|
||||
var attribute = serieType.GetAttribute<DefaultAnimationAttribute>();
|
||||
animationType = attribute.type;
|
||||
enableSerieDataAnimation = attribute.enableSerieDataAddedAnimation;
|
||||
}
|
||||
UpdateAnimationType(serie.animation, animationType);
|
||||
UpdateAnimationType(serie.animation, animationType,enableSerieDataAnimation);
|
||||
}
|
||||
|
||||
public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType)
|
||||
public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType, bool enableSerieDataAnimation)
|
||||
{
|
||||
animation.context.type = animation.type == AnimationType.Default ?
|
||||
defaultType :
|
||||
animation.type;
|
||||
animation.context.enableSerieDataAddedAnimation = enableSerieDataAnimation;
|
||||
}
|
||||
|
||||
public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip)
|
||||
|
||||
@@ -152,7 +152,6 @@ namespace XCharts
|
||||
else
|
||||
dataZoom.SetYAxisIndexValueInfo(axisIndex, ref tempMinValue, ref tempMaxValue);
|
||||
}
|
||||
|
||||
if (tempMinValue != axis.context.minValue ||
|
||||
tempMaxValue != axis.context.maxValue ||
|
||||
m_LastInterval != axis.interval ||
|
||||
|
||||
@@ -543,8 +543,8 @@ namespace XCharts.Runtime
|
||||
var totalAverage = serie.sampleAverage > 0 ? serie.sampleAverage :
|
||||
DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
||||
var dataChanging = false;
|
||||
var animationDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var animationDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
|
||||
for (int i = 0; i < maxCount; i += rate)
|
||||
@@ -635,8 +635,8 @@ namespace XCharts.Runtime
|
||||
var totalAverage = serie.sampleAverage > 0 ? serie.sampleAverage :
|
||||
DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
||||
var dataChanging = false;
|
||||
var animationDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var animationDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
|
||||
for (int i = 0; i < maxCount; i += rate)
|
||||
|
||||
@@ -6,10 +6,17 @@ namespace XCharts.Runtime
|
||||
public sealed class DefaultAnimationAttribute : Attribute
|
||||
{
|
||||
public readonly AnimationType type;
|
||||
public readonly bool enableSerieDataAddedAnimation = true;
|
||||
|
||||
public DefaultAnimationAttribute(AnimationType handler)
|
||||
{
|
||||
this.type = handler;
|
||||
}
|
||||
|
||||
public DefaultAnimationAttribute(AnimationType handler, bool enableSerieDataAddedAnimation)
|
||||
{
|
||||
this.type = handler;
|
||||
this.enableSerieDataAddedAnimation = enableSerieDataAddedAnimation;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -395,20 +395,30 @@ namespace XCharts.Runtime
|
||||
/// fadeIn animation.
|
||||
/// |开始渐入动画。
|
||||
/// </summary>
|
||||
public void AnimationFadeIn(bool reset = true)
|
||||
public void AnimationFadein(bool reset = true)
|
||||
{
|
||||
if (reset)
|
||||
AnimationReset();
|
||||
foreach (var serie in m_Series) serie.AnimationFadeIn();
|
||||
foreach (var serie in m_Series) serie.AnimationFadein();
|
||||
}
|
||||
|
||||
[Obsolete("Use AnimationFadein() instead.", true)]
|
||||
public void AnimationFadeIn(bool reset = true)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// fadeIn animation.
|
||||
/// |开始渐出动画。
|
||||
/// </summary>
|
||||
public void AnimationFadeout()
|
||||
{
|
||||
foreach (var serie in m_Series) serie.AnimationFadeout();
|
||||
}
|
||||
|
||||
[Obsolete("Use AnimationFadeout() instead.", true)]
|
||||
public void AnimationFadeOut()
|
||||
{
|
||||
foreach (var serie in m_Series) serie.AnimationFadeOut();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -649,7 +649,7 @@ namespace XCharts.Runtime
|
||||
serie.show = active;
|
||||
serie.RefreshLabel();
|
||||
serie.AnimationReset();
|
||||
if (active) serie.AnimationFadeIn();
|
||||
if (active) serie.AnimationFadein();
|
||||
UpdateLegendColor(serie.serieName, active);
|
||||
}
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace XCharts.Runtime
|
||||
InitComponentHandlers();
|
||||
InitSerieHandlers();
|
||||
AnimationReset();
|
||||
AnimationFadeIn();
|
||||
AnimationFadein();
|
||||
XChartsMgr.AddChart(this);
|
||||
}
|
||||
|
||||
@@ -416,7 +416,7 @@ namespace XCharts.Runtime
|
||||
if (!m_CheckAnimation)
|
||||
{
|
||||
m_CheckAnimation = true;
|
||||
AnimationFadeIn();
|
||||
AnimationFadein();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ namespace XCharts.Runtime
|
||||
serie.context.dataIndexs.Clear();
|
||||
serie.context.dataIgnores.Clear();
|
||||
serie.animation.context.isAllItemAnimationEnd = true;
|
||||
if (serie.show && !serie.animation.HasFadeOut())
|
||||
if (serie.show && !serie.animation.HasFadeout())
|
||||
{
|
||||
if (!serie.context.pointerEnter)
|
||||
serie.ResetInteract();
|
||||
|
||||
@@ -142,7 +142,7 @@ namespace XCharts.Runtime
|
||||
|
||||
private void DrawBarSerie(VertexHelper vh, Bar serie)
|
||||
{
|
||||
if (!serie.show || serie.animation.HasFadeOut())
|
||||
if (!serie.show || serie.animation.HasFadeout())
|
||||
return;
|
||||
|
||||
Axis axis;
|
||||
@@ -184,8 +184,8 @@ namespace XCharts.Runtime
|
||||
showData.Count;
|
||||
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series, serie.stack);
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
float dataChangeDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
double yMinValue = relativedAxis.context.minValue;
|
||||
double yMaxValue = relativedAxis.context.maxValue;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace XCharts.Runtime
|
||||
[SerieHandler(typeof(SimplifiedBarHandler), true)]
|
||||
[SerieConvert(typeof(SimplifiedLine), typeof(Bar))]
|
||||
[CoordOptions(typeof(GridCoord))]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[DefaultAnimation(AnimationType.LeftToRight, false)]
|
||||
[SerieComponent()]
|
||||
[SerieDataComponent()]
|
||||
[SerieDataExtraField()]
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace XCharts.Runtime
|
||||
|
||||
private void DrawBarSerie(VertexHelper vh, SimplifiedBar serie, int colorIndex)
|
||||
{
|
||||
if (!serie.show || serie.animation.HasFadeOut())
|
||||
if (!serie.show || serie.animation.HasFadeout())
|
||||
return;
|
||||
|
||||
Axis axis;
|
||||
@@ -134,8 +134,8 @@ namespace XCharts.Runtime
|
||||
showData.Count;
|
||||
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
float dataChangeDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
double yMinValue = relativedAxis.context.minValue;
|
||||
double yMaxValue = relativedAxis.context.maxValue;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(CandlestickHandler), true)]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[DefaultAnimation(AnimationType.LeftToRight, false)]
|
||||
[SerieComponent()]
|
||||
[SerieDataComponent(typeof(ItemStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
[SerieDataExtraField()]
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace XCharts.Runtime
|
||||
private void DrawCandlestickSerie(VertexHelper vh, Candlestick serie)
|
||||
{
|
||||
if (!serie.show) return;
|
||||
if (serie.animation.HasFadeOut()) return;
|
||||
if (serie.animation.HasFadeout()) return;
|
||||
XAxis xAxis;
|
||||
YAxis yAxis;
|
||||
GridCoord grid;
|
||||
@@ -99,8 +99,8 @@ namespace XCharts.Runtime
|
||||
showData.Count;
|
||||
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
float dataChangeDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
double yMinValue = yAxis.context.minValue;
|
||||
double yMaxValue = yAxis.context.maxValue;
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(SimplifiedCandlestickHandler), true)]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[DefaultAnimation(AnimationType.LeftToRight, false)]
|
||||
[SerieComponent()]
|
||||
[SerieDataComponent()]
|
||||
[SerieDataExtraField()]
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace XCharts.Runtime
|
||||
private void DrawCandlestickSerie(VertexHelper vh, SimplifiedCandlestick serie)
|
||||
{
|
||||
if (!serie.show) return;
|
||||
if (serie.animation.HasFadeOut()) return;
|
||||
if (serie.animation.HasFadeout()) return;
|
||||
XAxis xAxis;
|
||||
YAxis yAxis;
|
||||
GridCoord grid;
|
||||
@@ -99,8 +99,8 @@ namespace XCharts.Runtime
|
||||
showData.Count;
|
||||
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
float dataChangeDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
double yMinValue = yAxis.context.minValue;
|
||||
double yMaxValue = yAxis.context.maxValue;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace XCharts.Runtime
|
||||
|
||||
[System.Serializable]
|
||||
[SerieHandler(typeof(HeatmapHandler), true)]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[DefaultAnimation(AnimationType.LeftToRight, false)]
|
||||
[RequireChartComponent(typeof(VisualMap))]
|
||||
[CoordOptions(typeof(GridCoord), typeof(PolarCoord))]
|
||||
[SerieComponent(typeof(LabelStyle), typeof(EmphasisStyle), typeof(BlurStyle), typeof(SelectStyle))]
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace XCharts.Runtime
|
||||
|
||||
private void DrawDataHeatmapSerie(VertexHelper vh, Heatmap serie)
|
||||
{
|
||||
if (!serie.show || serie.animation.HasFadeOut()) return;
|
||||
if (!serie.show || serie.animation.HasFadeout()) return;
|
||||
XAxis xAxis;
|
||||
YAxis yAxis;
|
||||
if (!chart.TryGetChartComponent<XAxis>(out xAxis, serie.xAxisIndex)) return;
|
||||
@@ -209,8 +209,8 @@ namespace XCharts.Runtime
|
||||
|
||||
serie.animation.InitProgress(0, xCount);
|
||||
var animationIndex = serie.animation.GetCurrIndex();
|
||||
var dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var dataChangeDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
var dataChanging = false;
|
||||
serie.containerIndex = m_SerieGrid.index;
|
||||
@@ -332,7 +332,7 @@ namespace XCharts.Runtime
|
||||
|
||||
private void DrawCountHeatmapSerie(VertexHelper vh, Heatmap serie)
|
||||
{
|
||||
if (!serie.show || serie.animation.HasFadeOut()) return;
|
||||
if (!serie.show || serie.animation.HasFadeout()) return;
|
||||
XAxis xAxis;
|
||||
YAxis yAxis;
|
||||
if (!chart.TryGetChartComponent<XAxis>(out xAxis, serie.xAxisIndex)) return;
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace XCharts.Runtime
|
||||
[SerieHandler(typeof(LineHandler), true)]
|
||||
[SerieConvert(typeof(Bar), typeof(Pie))]
|
||||
[CoordOptions(typeof(GridCoord), typeof(PolarCoord))]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[DefaultAnimation(AnimationType.LeftToRight, false)]
|
||||
[SerieComponent(
|
||||
typeof(LabelStyle),
|
||||
typeof(EndLabelStyle),
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace XCharts.Runtime
|
||||
|
||||
private void DrawLineSerie(VertexHelper vh, Line serie)
|
||||
{
|
||||
if (serie.animation.HasFadeOut())
|
||||
if (serie.animation.HasFadeout())
|
||||
return;
|
||||
|
||||
Axis axis;
|
||||
@@ -288,8 +288,7 @@ namespace XCharts.Runtime
|
||||
serie.sampleAverage :
|
||||
DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
||||
var dataChanging = false;
|
||||
var dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var dataChangeDuration = serie.animation.GetChangeDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
|
||||
var interacting = false;
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace XCharts.Runtime
|
||||
[SerieHandler(typeof(SimplifiedLineHandler), true)]
|
||||
[SerieConvert(typeof(SimplifiedBar), typeof(Line))]
|
||||
[CoordOptions(typeof(GridCoord))]
|
||||
[DefaultAnimation(AnimationType.LeftToRight)]
|
||||
[DefaultAnimation(AnimationType.LeftToRight, false)]
|
||||
[SerieComponent(typeof(AreaStyle))]
|
||||
[SerieDataComponent()]
|
||||
[SerieDataExtraField()]
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (!serie.show)
|
||||
return;
|
||||
if (serie.animation.HasFadeOut())
|
||||
if (serie.animation.HasFadeout())
|
||||
return;
|
||||
|
||||
Axis axis;
|
||||
@@ -172,8 +172,8 @@ namespace XCharts.Runtime
|
||||
serie.sampleAverage :
|
||||
DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
||||
var dataChanging = false;
|
||||
var dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var dataChangeDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
|
||||
var interacting = false;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace XCharts.Runtime
|
||||
private void DrawParallelSerie(VertexHelper vh, Parallel serie)
|
||||
{
|
||||
if (!serie.show) return;
|
||||
if (serie.animation.HasFadeOut()) return;
|
||||
if (serie.animation.HasFadeout()) return;
|
||||
|
||||
var parallel = chart.GetChartComponent<ParallelCoord>(serie.parallelIndex);
|
||||
if (parallel == null)
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace XCharts.Runtime
|
||||
|
||||
private void DrawPie(VertexHelper vh, Serie serie)
|
||||
{
|
||||
if (!serie.show || serie.animation.HasFadeOut())
|
||||
if (!serie.show || serie.animation.HasFadeout())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace XCharts.Runtime
|
||||
var angle = 2 * Mathf.PI / indicatorNum;
|
||||
var centerPos = m_RadarCoord.context.center;
|
||||
serie.animation.InitProgress(0, 1);
|
||||
if (!serie.show || serie.animation.HasFadeOut())
|
||||
if (!serie.show || serie.animation.HasFadeout())
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -365,7 +365,7 @@ namespace XCharts.Runtime
|
||||
var angle = 2 * Mathf.PI / indicatorNum;
|
||||
var centerPos = m_RadarCoord.context.center;
|
||||
serie.animation.InitProgress(0, 1);
|
||||
if (!serie.show || serie.animation.HasFadeOut())
|
||||
if (!serie.show || serie.animation.HasFadeout())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace XCharts.Runtime
|
||||
|
||||
public override void DrawSerie(VertexHelper vh)
|
||||
{
|
||||
if (!serie.show || serie.animation.HasFadeOut()) return;
|
||||
if (!serie.show || serie.animation.HasFadeout()) return;
|
||||
var data = serie.data;
|
||||
serie.animation.InitProgress(serie.startAngle, serie.startAngle + 360);
|
||||
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace XCharts.Runtime
|
||||
|
||||
protected virtual void DrawScatterSerie(VertexHelper vh, BaseScatter serie)
|
||||
{
|
||||
if (serie.animation.HasFadeOut())
|
||||
if (serie.animation.HasFadeout())
|
||||
return;
|
||||
|
||||
if (!serie.show)
|
||||
@@ -133,7 +133,7 @@ namespace XCharts.Runtime
|
||||
serie.dataCount;
|
||||
serie.animation.InitProgress(0, 1);
|
||||
var rate = serie.animation.GetCurrRate();
|
||||
var dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataChangeDuration = serie.animation.GetChangeDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
var dataChanging = false;
|
||||
var interacting = false;
|
||||
@@ -216,7 +216,7 @@ namespace XCharts.Runtime
|
||||
|
||||
protected virtual void DrawSingAxisScatterSerie(VertexHelper vh, BaseScatter serie)
|
||||
{
|
||||
if (serie.animation.HasFadeOut())
|
||||
if (serie.animation.HasFadeout())
|
||||
return;
|
||||
|
||||
if (!serie.show)
|
||||
@@ -237,7 +237,7 @@ namespace XCharts.Runtime
|
||||
serie.animation.InitProgress(0, 1);
|
||||
|
||||
var rate = serie.animation.GetCurrRate();
|
||||
var dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataChangeDuration = serie.animation.GetChangeDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
var dataChanging = false;
|
||||
var dataList = serie.GetDataList(xDataZoom);
|
||||
|
||||
@@ -1176,8 +1176,8 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else
|
||||
{
|
||||
var duration = animation.GetDataChangeDuration();
|
||||
var dataAddDuration = animation.GetDataAddDuration();
|
||||
var duration = animation.GetChangeDuration();
|
||||
var dataAddDuration = animation.GetAdditionDuration();
|
||||
var unscaledTime = animation.unscaledTime;
|
||||
foreach (var sdata in data)
|
||||
{
|
||||
@@ -1537,7 +1537,7 @@ namespace XCharts.Runtime
|
||||
var serieData = GetDataList(dataZoom);
|
||||
if (index < serieData.Count)
|
||||
{
|
||||
var value = serieData[index].GetCurrData(1, 0, animation.GetDataChangeDuration(), animation.unscaledTime);
|
||||
var value = serieData[index].GetCurrData(1, 0, animation.GetChangeDuration(), animation.unscaledTime);
|
||||
if (showAsPositiveNumber)
|
||||
value = Math.Abs(value);
|
||||
return value;
|
||||
@@ -1699,7 +1699,7 @@ namespace XCharts.Runtime
|
||||
if (index >= 0 && index < m_Data.Count)
|
||||
{
|
||||
var animationOpen = animation.enable;
|
||||
var animationDuration = animation.GetDataChangeDuration();
|
||||
var animationDuration = animation.GetChangeDuration();
|
||||
var unscaledTime = animation.unscaledTime;
|
||||
var flag = m_Data[index].UpdateData(dimension, value, animationOpen, unscaledTime, animationDuration);
|
||||
if (flag)
|
||||
@@ -1726,7 +1726,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var serieData = m_Data[index];
|
||||
var animationOpen = animation.enable;
|
||||
var animationDuration = animation.GetDataChangeDuration();
|
||||
var animationDuration = animation.GetChangeDuration();
|
||||
var unscaledTime = animation.unscaledTime;
|
||||
for (int i = 0; i < values.Count; i++)
|
||||
serieData.UpdateData(i, values[i], animationOpen, unscaledTime, animationDuration);
|
||||
@@ -1907,18 +1907,32 @@ namespace XCharts.Runtime
|
||||
/// <summary>
|
||||
/// 渐入动画
|
||||
/// </summary>
|
||||
public void AnimationFadein()
|
||||
{
|
||||
if (animation.enable) animation.Fadein();
|
||||
SetVerticesDirty();
|
||||
}
|
||||
|
||||
[Obsolete("Use Serie.AnimationFadein() instead.", true)]
|
||||
public void AnimationFadeIn()
|
||||
{
|
||||
if (animation.enable) animation.FadeIn();
|
||||
if (animation.enable) animation.Fadein();
|
||||
SetVerticesDirty();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 渐出动画
|
||||
/// </summary>
|
||||
public void AnimationFadeout()
|
||||
{
|
||||
if (animation.enable) animation.Fadeout();
|
||||
SetVerticesDirty();
|
||||
}
|
||||
|
||||
[Obsolete("Use Serie.AnimationFadeout() instead.", true)]
|
||||
public void AnimationFadeOut()
|
||||
{
|
||||
if (animation.enable) animation.FadeOut();
|
||||
if (animation.enable) animation.Fadeout();
|
||||
SetVerticesDirty();
|
||||
}
|
||||
|
||||
|
||||
@@ -240,13 +240,19 @@ namespace XCharts.Runtime
|
||||
|
||||
public void OnAdd(AnimationStyle animation, double startValue = 0)
|
||||
{
|
||||
if (!animation.enable) return;
|
||||
if (!animation.context.enableSerieDataAddedAnimation)
|
||||
{
|
||||
animation.Addition();
|
||||
return;
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
return;
|
||||
#endif
|
||||
m_DataAddTime.Clear();
|
||||
m_DataAddFlag.Clear();
|
||||
if (animation.GetDataAddDuration() > 0)
|
||||
if (animation.GetAdditionDuration() > 0)
|
||||
{
|
||||
for (int i = 0; i < m_Data.Count; i++)
|
||||
{
|
||||
@@ -506,7 +512,7 @@ namespace XCharts.Runtime
|
||||
if (animation == null || !animation.enable)
|
||||
return GetData(index, inverse);
|
||||
else
|
||||
return GetCurrData(index, animation.GetDataAddDuration(), animation.GetDataChangeDuration(),
|
||||
return GetCurrData(index, animation.GetAdditionDuration(), animation.GetChangeDuration(),
|
||||
inverse, 0, 0, animation.unscaledTime, loop);
|
||||
}
|
||||
|
||||
@@ -515,7 +521,7 @@ namespace XCharts.Runtime
|
||||
if (animation == null || !animation.enable)
|
||||
return GetData(index, inverse);
|
||||
else
|
||||
return GetCurrData(index, animation.GetDataAddDuration(), animation.GetDataChangeDuration(),
|
||||
return GetCurrData(index, animation.GetAdditionDuration(), animation.GetChangeDuration(),
|
||||
inverse, min, max, animation.unscaledTime, loop);
|
||||
}
|
||||
|
||||
|
||||
@@ -401,8 +401,8 @@ namespace XCharts.Runtime
|
||||
if (!m_InitedLabel)
|
||||
return;
|
||||
|
||||
var dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var dataChangeDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
var needCheck = serie.context.dataIndexs.Count > 0;
|
||||
foreach (var serieData in serie.data)
|
||||
|
||||
@@ -698,7 +698,7 @@ namespace XCharts.Runtime
|
||||
var symbol = stateStyle.symbol;
|
||||
size = symbol.GetSize(serieData == null ? null : serieData.data, defaultSize);
|
||||
}
|
||||
size = (float)serieData.GetAddAnimationData(0, size, serie.animation.GetDataAddDuration());
|
||||
size = (float)serieData.GetAddAnimationData(0, size, serie.animation.GetAdditionDuration());
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
@@ -346,8 +346,8 @@ namespace XCharts.Runtime
|
||||
if ((isPolar && serie.polarIndex != axisIndex) ||
|
||||
(!isPolar && serie.yAxisIndex != axisIndex) ||
|
||||
!serie.show) continue;
|
||||
var updateDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var updateDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
if (isPercentStack && SeriesHelper.IsPercentStack<Bar>(series, serie.serieName))
|
||||
{
|
||||
@@ -406,6 +406,9 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else
|
||||
{
|
||||
var updateDuration = serie.animation.GetChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetAdditionDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
for (int j = 0; j < showData.Count; j++)
|
||||
{
|
||||
if (!_serieTotalValueForMinMax.ContainsKey(j))
|
||||
@@ -417,9 +420,10 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else
|
||||
{
|
||||
currData = yValue ? showData[j].GetData(1) : showData[j].GetData(0);
|
||||
//currData = yValue ? showData[j].GetData(1) : showData[j].GetData(0);
|
||||
currData = showData[j].GetCurrData(yValue ? 1 : 0, dataAddDuration, updateDuration, unscaledTime, inverse);
|
||||
}
|
||||
if (inverse) currData = -currData;
|
||||
//if (inverse) currData = -currData;
|
||||
if (!serie.IsIgnoreValue(showData[j], currData))
|
||||
_serieTotalValueForMinMax[j] = _serieTotalValueForMinMax[j] + currData;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user