mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-19 15:00:08 +00:00
增加Animation在重新初始化数据时自启动功能
This commit is contained in:
@@ -5,7 +5,8 @@ using XCharts;
|
||||
[ExecuteInEditMode]
|
||||
public class Demo10_LineSimple : MonoBehaviour
|
||||
{
|
||||
void Awake()
|
||||
//void Awake()
|
||||
void Start()
|
||||
{
|
||||
var chart = gameObject.GetComponent<LineChart>();
|
||||
if (chart == null) return;
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public void ClearData()
|
||||
{
|
||||
AnimationStop();
|
||||
foreach (var serie in m_Series)
|
||||
{
|
||||
serie.ClearData();
|
||||
@@ -200,6 +201,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
public void RemoveAll()
|
||||
{
|
||||
AnimationStop();
|
||||
m_Series.Clear();
|
||||
}
|
||||
|
||||
@@ -793,6 +795,9 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始初始动画
|
||||
/// </summary>
|
||||
public void AnimationStart()
|
||||
{
|
||||
foreach (var serie in m_Series)
|
||||
@@ -804,6 +809,17 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止初始动画
|
||||
/// </summary>
|
||||
public void AnimationStop()
|
||||
{
|
||||
foreach (var serie in m_Series)
|
||||
{
|
||||
if (serie.animation.enable) serie.animation.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从json中解析数据
|
||||
/// </summary>
|
||||
|
||||
@@ -57,7 +57,8 @@ namespace XCharts
|
||||
/// <value></value>
|
||||
public int delay { get { return m_Delay; } set { m_Delay = value; if (m_Delay < 0) m_Delay = 0; } }
|
||||
|
||||
private Dictionary<int,float> m_DataAnimationState = new Dictionary<int,float>();
|
||||
private Dictionary<int, float> m_DataAnimationState = new Dictionary<int, float>();
|
||||
private bool m_IsStart = false;
|
||||
private bool m_IsEnd = true;
|
||||
private bool m_Inited = false;
|
||||
|
||||
@@ -70,7 +71,9 @@ namespace XCharts
|
||||
|
||||
public void Start()
|
||||
{
|
||||
if (m_IsStart) return;
|
||||
startTime = Time.time;
|
||||
m_IsStart = true;
|
||||
m_IsEnd = false;
|
||||
m_Inited = false;
|
||||
m_CurrDataProgress = 1;
|
||||
@@ -81,6 +84,14 @@ namespace XCharts
|
||||
m_DataAnimationState.Clear();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
m_IsStart = false;
|
||||
m_IsEnd = true;
|
||||
m_Inited = false;
|
||||
m_DataAnimationState.Clear();
|
||||
}
|
||||
|
||||
public void End()
|
||||
{
|
||||
if (m_IsEnd) return;
|
||||
@@ -89,8 +100,6 @@ namespace XCharts
|
||||
m_IsEnd = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void InitProgress(int data, float curr, float dest)
|
||||
{
|
||||
if (!m_Inited)
|
||||
@@ -110,15 +119,17 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDataState(int index,float state)
|
||||
public void SetDataState(int index, float state)
|
||||
{
|
||||
m_DataAnimationState[index] = state;
|
||||
}
|
||||
|
||||
public float GetDataState(int index){
|
||||
if(IsInDelay()) return 0;
|
||||
if(!m_DataAnimationState.ContainsKey(index)){
|
||||
m_DataAnimationState.Add(index,0);
|
||||
public float GetDataState(int index)
|
||||
{
|
||||
if (IsInDelay()) return 0;
|
||||
if (!m_DataAnimationState.ContainsKey(index))
|
||||
{
|
||||
m_DataAnimationState.Add(index, 0);
|
||||
}
|
||||
return m_DataAnimationState[index];
|
||||
}
|
||||
@@ -186,11 +197,13 @@ namespace XCharts
|
||||
return m_CurrSymbolProgress;
|
||||
}
|
||||
|
||||
public float GetCurrDetail(){
|
||||
public float GetCurrDetail()
|
||||
{
|
||||
return m_CurrDetailProgress;
|
||||
}
|
||||
|
||||
public float GetCurrData(){
|
||||
public float GetCurrData()
|
||||
{
|
||||
return m_CurrDataProgress;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace XCharts
|
||||
[NonSerialized] private bool m_RefreshChart = false;
|
||||
[NonSerialized] private bool m_RefreshLabel = false;
|
||||
[NonSerialized] private bool m_ReinitLabel = false;
|
||||
[NonSerialized] private bool m_CheckAnimation = false;
|
||||
|
||||
protected Vector2 chartAnchorMax { get { return rectTransform.anchorMax; } }
|
||||
protected Vector2 chartAnchorMin { get { return rectTransform.anchorMin; } }
|
||||
@@ -79,6 +80,7 @@ namespace XCharts
|
||||
InitSerieLabel();
|
||||
InitTooltip();
|
||||
TransferOldVersionData();
|
||||
m_Series.AnimationStop();
|
||||
m_Series.AnimationStart();
|
||||
}
|
||||
|
||||
@@ -96,6 +98,7 @@ namespace XCharts
|
||||
CheckTooltip();
|
||||
CheckRefreshChart();
|
||||
CheckRefreshLabel();
|
||||
CheckAnimation();
|
||||
}
|
||||
|
||||
protected override void OnEnable()
|
||||
@@ -315,7 +318,7 @@ namespace XCharts
|
||||
var backgroundColor = serie.label.backgroundColor;
|
||||
var labelObj = ChartHelper.AddSerieLabel(textName, labelObject.transform, m_ThemeInfo.font,
|
||||
color, backgroundColor, serie.label.fontSize, serie.label.fontStyle, serie.label.rotate,
|
||||
serie.label.backgroundWidth,serie.label.backgroundHeight);
|
||||
serie.label.backgroundWidth, serie.label.backgroundHeight);
|
||||
var isAutoSize = serie.label.backgroundWidth == 0 || serie.label.backgroundHeight == 0;
|
||||
serieData.InitLabel(labelObj, isAutoSize, serie.label.paddingLeftRight, serie.label.paddingTopBottom);
|
||||
serieData.SetLabelActive(false);
|
||||
@@ -469,6 +472,15 @@ namespace XCharts
|
||||
}
|
||||
}
|
||||
|
||||
protected void CheckAnimation()
|
||||
{
|
||||
if (!m_CheckAnimation)
|
||||
{
|
||||
m_CheckAnimation = true;
|
||||
m_Series.AnimationStart();
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnRefreshLabel()
|
||||
{
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace XCharts
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public float lineSmoothStyle { get { return m_LineSmoothStyle; } set { m_LineSmoothStyle = value; } }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set the size of chart.
|
||||
/// 设置图表的大小。
|
||||
@@ -106,6 +106,7 @@ namespace XCharts
|
||||
{
|
||||
m_Series.ClearData();
|
||||
m_Legend.ClearData();
|
||||
m_CheckAnimation = false;
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
@@ -118,6 +119,7 @@ namespace XCharts
|
||||
{
|
||||
m_Legend.ClearData();
|
||||
m_Series.RemoveAll();
|
||||
m_CheckAnimation = false;
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
@@ -422,5 +424,22 @@ namespace XCharts
|
||||
OnThemeChanged();
|
||||
RefreshChart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 开始初始动画
|
||||
/// </summary>
|
||||
public void AnimationStart()
|
||||
{
|
||||
m_Series.AnimationStart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止初始化动画
|
||||
/// </summary>
|
||||
public void AnimationStop()
|
||||
{
|
||||
m_CheckAnimation = false;
|
||||
m_Series.AnimationStop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ QQ交流群:XCharts交流群(202030963)
|
||||
|
||||
## 更新日志
|
||||
|
||||
* (2019.09.05)增加`SerieLabel`的`Border`边框相关配置支持
|
||||
* (2019.09.06)增加`Animation`在重新初始化数据时自启动功能
|
||||
* (2019.09.06)增加`SerieLabel`的`Border`边框相关配置支持
|
||||
* (2019.09.05)增加`PieChart`的`Animation`初始化动画配置支持
|
||||
* (2019.09.03)增加`BarChart`的`Animation`初始化动画配置支持
|
||||
* (2019.09.02)增加`LineChart`的`Animation`初始化动画配置支持
|
||||
|
||||
Reference in New Issue
Block a user