3.0 - animation

This commit is contained in:
monitor1394
2021-12-12 18:05:26 +08:00
parent 9c69774d35
commit 0aa476e757
37 changed files with 348 additions and 404 deletions

View File

@@ -20,6 +20,7 @@ namespace XCharts
if (MakeComponentFoldout(prop, "m_Enable"))
{
++EditorGUI.indentLevel;
PropertyField(prop, "m_Type");
PropertyField(prop, "m_FadeInDuration");
PropertyField(prop, "m_FadeInDelay");
PropertyField(prop, "m_FadeOutDuration");

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9f827513754e8436bbc63e64c5b5e6c3
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -14,16 +14,45 @@ namespace XCharts
public delegate float CustomAnimationDelay(int dataIndex);
public delegate float CustomAnimationDuration(int dataIndex);
public enum AnimationType
{
/// <summary>
/// he default. An animation playback mode will be selected according to the actual situation.
/// 默认。内部会根据实际情况选择一种动画播放方式。
/// </summary>
Default,
/// <summary>
/// Play the animation from left to right.
/// 从左往右播放动画。
/// </summary>
LeftToRight,
/// <summary>
/// Play the animation from bottom to top.
/// 从下往上播放动画。
/// </summary>
BottomToTop,
/// <summary>
/// Play animations from the inside out.
/// 由内到外播放动画。
/// </summary>
InsideOut,
/// <summary>
/// Play the animation along the path.
/// 沿着路径播放动画。
/// </summary>
AlongPath,
/// <summary>
/// Play the animation clockwise.
/// 顺时针播放动画。
/// </summary>
Clockwise,
}
public enum AnimationEasing
{
Linear,
}
/// <summary>
/// the animation of serie.
/// 动画表现。
@@ -31,12 +60,9 @@ namespace XCharts
[System.Serializable]
public class AnimationStyle : ChildComponent
{
public enum Easing
{
Linear,
}
[SerializeField] private bool m_Enable = true;
[SerializeField] private Easing m_Easting;
[SerializeField] private AnimationType m_Type;
[SerializeField] private AnimationEasing m_Easting;
[SerializeField] private int m_Threshold = 2000;
[SerializeField] private float m_FadeInDuration = 1000;
[SerializeField] private float m_FadeInDelay = 0;
@@ -62,6 +88,7 @@ namespace XCharts
/// 自定义渐出动画时长函数。返回ms值。
/// </summary>
public CustomAnimationDuration customFadeOutDuration;
public AnimationStyleContext context = new AnimationStyleContext();
/// <summary>
/// Whether to enable animation.
@@ -69,6 +96,11 @@ namespace XCharts
/// </summary>
public bool enable { get { return m_Enable; } set { m_Enable = value; } }
/// <summary>
/// The type of animation.
/// 动画类型。
/// </summary>
public AnimationType type { get { return m_Type; } set { m_Type = value; } }
/// <summary>
/// Easing method used for the first animation.
/// 动画的缓动效果。
/// </summary>
@@ -112,10 +144,6 @@ namespace XCharts
/// </summary>
public float dataChangeDuration { get { return m_DataChangeDuration; } set { m_DataChangeDuration = value < 0 ? 0 : value; } }
/// <summary>
/// 是否沿着线的轨迹进行匀速动画。
/// </summary>
public bool alongWithLinePath { get { return m_AlongWithLinePath; } set { m_AlongWithLinePath = value; } }
/// <summary>
/// 渐入动画完成回调
/// </summary>
public Action fadeInFinishCallback { get; set; }
@@ -123,8 +151,8 @@ namespace XCharts
/// 渐出动画完成回调
/// </summary>
public Action fadeOutFinishCallback { get; set; }
private Dictionary<int, float> m_DataCurrProgress = new Dictionary<int, float>();
private Dictionary<int, float> m_DataDestProgress = new Dictionary<int, float>();
private Dictionary<int, float> m_ItemCurrProgress = new Dictionary<int, float>();
private Dictionary<int, float> m_ItemDestProgress = new Dictionary<int, float>();
private bool m_FadeIn = false;
private bool m_IsEnd = true;
private bool m_IsPause = false;
@@ -133,14 +161,11 @@ namespace XCharts
private bool m_IsInit = false;
private float startTime { get; set; }
private int m_CurrDataProgress { get; set; }
private int m_DestDataProgress { get; set; }
[SerializeField] private float m_CurrDetailProgress;
[SerializeField] private float m_DestDetailProgress;
[SerializeField] private float m_TotalDetailProgress;
private float m_CurrDetailProgress;
private float m_DestDetailProgress;
private float m_TotalDetailProgress;
private float m_CurrSymbolProgress;
private Vector3 m_LinePathLastPos;
private float m_LinePathCurrTotalDist = 0f;
public void FadeIn()
{
@@ -162,13 +187,11 @@ namespace XCharts
m_IsInit = false;
m_IsPause = false;
m_FadeOuted = false;
m_CurrDataProgress = 1;
m_DestDataProgress = 1;
m_CurrDetailProgress = 0;
m_DestDetailProgress = 1;
m_CurrSymbolProgress = 0;
m_DataCurrProgress.Clear();
m_DataDestProgress.Clear();
m_ItemCurrProgress.Clear();
m_ItemDestProgress.Clear();
}
public void Restart()
@@ -191,13 +214,11 @@ namespace XCharts
m_IsEnd = false;
m_IsInit = false;
m_IsPause = false;
m_CurrDataProgress = 0;
m_DestDataProgress = 0;
m_CurrDetailProgress = 0;
m_DestDetailProgress = 1;
m_CurrSymbolProgress = 0;
m_DataCurrProgress.Clear();
m_DataDestProgress.Clear();
m_ItemCurrProgress.Clear();
m_ItemDestProgress.Clear();
}
public void Pause()
@@ -222,7 +243,6 @@ namespace XCharts
return;
m_ActualDuration = (int)((Time.time - startTime) * 1000) - (m_FadeOut ? fadeOutDelay : fadeInDelay);
m_CurrDataProgress = m_DestDataProgress + (m_FadeOut ? -1 : 1);
m_IsEnd = true;
m_IsInit = false;
@@ -253,10 +273,10 @@ namespace XCharts
m_IsPause = false;
m_FadeOut = false;
m_FadeOuted = false;
m_DataCurrProgress.Clear();
m_ItemCurrProgress.Clear();
}
public void InitProgress(int data, float curr, float dest)
public void InitProgress(float curr, float dest)
{
if (m_IsInit || m_IsEnd)
return;
@@ -264,7 +284,6 @@ namespace XCharts
return;
m_IsInit = true;
m_DestDataProgress = data;
m_TotalDetailProgress = dest - curr;
if (m_FadeOut)
@@ -286,7 +305,7 @@ namespace XCharts
var ep = paths[paths.Count - 1];
var currDetailProgress = isY ? sp.y : sp.x;
var totalDetailProgress = isY ? ep.y : ep.x;
if (m_AlongWithLinePath)
if (context.type == AnimationType.AlongPath)
{
currDetailProgress = 0;
totalDetailProgress = 0;
@@ -297,51 +316,41 @@ namespace XCharts
totalDetailProgress += Vector3.Distance(np, lp);
lp = np;
}
SetLinePathStartPos(sp);
m_LinePathLastPos = sp;
context.currentPathDistance = 0;
}
else
{
InitProgress(paths.Count, currDetailProgress, totalDetailProgress);
}
}
public void SetDataFinish(int dataIndex)
{
if (m_IsEnd)
return;
m_CurrDataProgress = dataIndex + (m_FadeOut ? -1 : 1);
InitProgress(currDetailProgress, totalDetailProgress);
}
private void SetDataCurrProgress(int index, float state)
{
m_DataCurrProgress[index] = state;
m_ItemCurrProgress[index] = state;
}
private float GetDataCurrProgress(int index, float initValue, float destValue, out bool isBarEnd)
private float GetDataCurrProgress(int index, float initValue, float destValue, ref bool isBarEnd)
{
if (IsInDelay())
{
isBarEnd = false;
return initValue;
}
var c1 = !m_DataCurrProgress.ContainsKey(index);
var c2 = !m_DataDestProgress.ContainsKey(index);
var c1 = !m_ItemCurrProgress.ContainsKey(index);
var c2 = !m_ItemDestProgress.ContainsKey(index);
if (c1 || c2)
{
if (c1)
m_DataCurrProgress.Add(index, initValue);
m_ItemCurrProgress.Add(index, initValue);
if (c2)
m_DataDestProgress.Add(index, destValue);
m_ItemDestProgress.Add(index, destValue);
isBarEnd = false;
}
else
{
isBarEnd = m_DataCurrProgress[index] == m_DataDestProgress[index];
isBarEnd = m_ItemCurrProgress[index] == m_ItemDestProgress[index];
}
return m_DataCurrProgress[index];
return m_ItemCurrProgress[index];
}
public bool IsFinish()
@@ -350,7 +359,14 @@ namespace XCharts
if (!Application.isPlaying)
return true;
#endif
return !m_Enable || m_IsEnd || (m_CurrDataProgress > m_DestDataProgress && m_CurrDetailProgress > m_DestDetailProgress);
if (!m_Enable || m_IsEnd)
return true;
if (IsIndexAnimation())
return m_CurrDetailProgress > m_DestDetailProgress;
if (IsItemAnimation())
return false;
return true;
}
public bool IsInFadeOut()
@@ -366,7 +382,19 @@ namespace XCharts
return (fadeInDelay > 0 && Time.time - startTime < fadeInDelay / 1000);
}
public float GetDataDelay(int dataIndex)
public bool IsItemAnimation()
{
return context.type == AnimationType.BottomToTop || context.type == AnimationType.InsideOut;
}
public bool IsIndexAnimation()
{
return context.type == AnimationType.LeftToRight
|| context.type == AnimationType.Clockwise
|| context.type == AnimationType.AlongPath;
}
public float GetIndexDelay(int dataIndex)
{
if (m_FadeOut && customFadeOutDelay != null)
return customFadeOutDelay(dataIndex);
@@ -376,9 +404,9 @@ namespace XCharts
return 0;
}
public bool IsInDataDelay(int dataIndex)
public bool IsInIndexDelay(int dataIndex)
{
return Time.time - startTime < GetDataDelay(dataIndex) / 1000f;
return Time.time - startTime < GetIndexDelay(dataIndex) / 1000f;
}
public bool IsAllOutDelay(int dataCount)
@@ -386,53 +414,32 @@ namespace XCharts
var nowTime = Time.time - startTime;
for (int i = 0; i < dataCount; i++)
{
if (nowTime < GetDataDelay(i) / 1000)
if (nowTime < GetIndexDelay(i) / 1000)
return false;
}
return true;
}
public bool IsAllDataFinishProgress(int dataCount)
{
for (int i = 0; i < dataCount; i++)
{
if (m_DataDestProgress.ContainsKey(i) && m_DataCurrProgress.ContainsKey(i))
{
if (m_DataCurrProgress[i] != m_DataDestProgress[i])
return false;
}
else
{
return false;
}
}
return true;
}
public bool CheckDetailBreak(float detail)
{
if (!IsIndexAnimation())
return false;
return !IsFinish() && detail > m_CurrDetailProgress;
}
public void SetLinePathStartPos(Vector3 pos)
{
if (m_AlongWithLinePath)
{
m_LinePathLastPos = pos;
m_LinePathCurrTotalDist = 0;
}
}
public bool CheckDetailBreak(Vector3 pos, bool isYAxis)
{
if (!IsIndexAnimation())
return false;
if (IsFinish())
return false;
if (m_AlongWithLinePath)
if (context.type == AnimationType.AlongPath)
{
m_LinePathCurrTotalDist += Vector3.Distance(pos, m_LinePathLastPos);
context.currentPathDistance += Vector3.Distance(pos, m_LinePathLastPos);
m_LinePathLastPos = pos;
return CheckDetailBreak(m_LinePathCurrTotalDist);
return CheckDetailBreak(context.currentPathDistance);
}
else
{
@@ -443,26 +450,17 @@ namespace XCharts
}
}
public bool NeedAnimation(int dataIndex)
{
if (!m_Enable || m_IsEnd)
return true;
if (IsInDelay())
return false;
if (m_FadeOut)
return dataIndex > 0;
else
return dataIndex <= m_CurrDataProgress;
}
internal void CheckProgress()
public void CheckProgress()
{
if (IsItemAnimation() && context.isAllItemAnimationEnd)
{
End();
return;
}
CheckProgress(m_TotalDetailProgress);
}
internal void CheckProgress(double total)
public void CheckProgress(double total)
{
if (IsFinish())
return;
@@ -512,17 +510,17 @@ namespace XCharts
return m_FadeInDuration > 0 ? m_FadeInDuration / 1000 : 1f;
}
internal float CheckBarProgress(int dataIndex, float barHig, int dataCount, out bool isBarEnd)
internal float CheckItemProgress(int dataIndex, float barHig, ref bool isEnd)
{
isBarEnd = false;
isEnd = false;
var initHig = m_FadeOut ? barHig : 0;
var destHig = m_FadeOut ? 0 : barHig;
var currHig = GetDataCurrProgress(dataIndex, initHig, destHig, out isBarEnd);
if (isBarEnd || IsFinish())
var currHig = GetDataCurrProgress(dataIndex, initHig, destHig, ref isEnd);
if (isEnd || IsFinish())
{
return m_FadeOuted ? 0 : barHig;
}
else if (IsInDelay() || IsInDataDelay(dataIndex))
else if (IsInDelay() || IsInIndexDelay(dataIndex))
{
return m_FadeOut ? barHig : 0;
}
@@ -540,24 +538,19 @@ namespace XCharts
if ((initHig > 0 && currHig <= 0) || (initHig < 0 && currHig >= 0))
{
currHig = 0;
isBarEnd = true;
isEnd = true;
}
}
else if (Mathf.Abs(currHig) >= Mathf.Abs(barHig))
{
currHig = barHig;
isBarEnd = true;
isEnd = true;
}
SetDataCurrProgress(dataIndex, currHig);
return currHig;
}
}
public void AllBarEnd()
{
End();
}
internal void CheckSymbol(float dest)
{
if (!enable || m_IsEnd || m_IsPause || !m_IsInit)
@@ -628,11 +621,6 @@ namespace XCharts
return (int)m_CurrDetailProgress;
}
public float GetCurrData()
{
return m_CurrDataProgress;
}
public float GetUpdateAnimationDuration()
{
if (m_Enable && m_DataChangeEnable && IsFinish())

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: d51f91843500c4092909a6779592b654
guid: e31c30f2ef61c48718a626f93307ce92
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,20 @@
/******************************************/
/* */
/* Copyright (c) 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System;
using System.Collections.Generic;
using UnityEngine;
namespace XCharts
{
public struct AnimationStyleContext
{
public AnimationType type;
internal float currentPathDistance;
internal bool isAllItemAnimationEnd;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b3dc504960589413fa6a76267067775c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,72 @@
/******************************************/
/* */
/* Copyright (c) 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
using XUGL;
namespace XCharts
{
public static class AnimationStyleHelper
{
public static float CheckDataAnimation(BaseChart chart, Serie serie, int dataIndex, float destProgress)
{
if (!serie.animation.IsItemAnimation())
{
serie.animation.context.isAllItemAnimationEnd = false;
return destProgress;
}
if (serie.animation.IsFinish())
{
serie.animation.context.isAllItemAnimationEnd = false;
return destProgress;
}
var isDataAnimationEnd = true;
float currHig = serie.animation.CheckItemProgress(dataIndex, destProgress, ref isDataAnimationEnd);
if (!isDataAnimationEnd)
{
serie.animation.context.isAllItemAnimationEnd = false;
}
return currHig;
}
public static void UpdateSerieAnimation(Serie serie)
{
var serieType = serie.GetType();
var animationType = AnimationType.LeftToRight;
if (serieType.IsDefined(typeof(DefaultAnimationAttribute), false))
{
animationType = serieType.GetAttribute<DefaultAnimationAttribute>().type;
}
UpdateAnimationType(serie.animation, animationType);
serie.animation.context.isAllItemAnimationEnd = true;
}
public static void UpdateAnimationType(AnimationStyle animation, AnimationType defaultType)
{
animation.context.type = animation.type == AnimationType.Default
? defaultType
: animation.type;
}
public static bool GetAnimationPosition(AnimationStyle animation, bool isY, Vector3 lp, Vector3 cp, float progress, ref Vector3 ip)
{
if (animation.context.type == AnimationType.AlongPath)
{
var dist = Vector3.Distance(lp, cp);
var rate = (dist - animation.context.currentPathDistance + animation.GetCurrDetail()) / dist;
ip = Vector3.Lerp(lp, cp, rate);
return true;
}
else
{
var startPos = isY ? new Vector3(-10000, progress) : new Vector3(progress, -10000);
var endPos = isY ? new Vector3(10000, progress) : new Vector3(progress, 10000);
return UGLHelper.GetIntersection(lp, cp, startPos, endPos, ref ip);
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 54cadaee0856b4f7085787fd450eec37
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -41,7 +41,6 @@ namespace XCharts
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
if (tempMinValue != axis.context.minValue || tempMaxValue != axis.context.maxValue)
{
chart.m_IsPlayingAnimation = true;
axis.UpdateMinMaxValue(tempMinValue, tempMaxValue);
axis.context.offset = 0;
axis.context.lastCheckInverse = axis.inverse;
@@ -51,11 +50,6 @@ namespace XCharts
chart.RefreshChart();
}
}
if (!chart.m_IsPlayingAnimation)
{
UpdateAxisLabelText(axis);
chart.RefreshChart();
}
}
internal void UpdateAxisLabelText(AngleAxis axis)

View File

@@ -132,7 +132,6 @@ namespace XCharts
{
m_LastSplitNumber = axis.splitNumber;
m_LastInterval = axis.interval;
chart.m_IsPlayingAnimation = true;
axis.UpdateMinMaxValue(tempMinValue, tempMaxValue);
axis.context.offset = 0;
@@ -178,12 +177,6 @@ namespace XCharts
chart.RefreshChart();
}
}
if ( !chart.m_IsPlayingAnimation)
{
UpdateAxisLabelText(axis);
chart.RefreshChart();
}
}
internal virtual void UpdateAxisLabelText(Axis axis)

View File

@@ -40,7 +40,6 @@ namespace XCharts
AxisHelper.AdjustMinMaxValue(axis, ref tempMinValue, ref tempMaxValue, true);
if (tempMinValue != axis.context.minValue || tempMaxValue != axis.context.maxValue)
{
chart.m_IsPlayingAnimation = true;
axis.UpdateMinMaxValue(tempMinValue, tempMaxValue);
axis.context.offset = 0;
axis.context.lastCheckInverse = axis.inverse;
@@ -51,11 +50,6 @@ namespace XCharts
chart.RefreshChart();
}
}
if (!chart.m_IsPlayingAnimation)
{
UpdateAxisLabelText(axis);
chart.RefreshChart();
}
}
internal void UpdateAxisLabelText(RadiusAxis axis)

View File

@@ -111,7 +111,7 @@ namespace XCharts
var ep = Vector3.zero;
var colorIndex = chart.GetLegendRealShowNameIndex(serie.serieName);
var serieColor = SerieHelper.GetLineColor(serie, chart.theme, colorIndex, false);
animation.InitProgress(1, 0, 1f);
animation.InitProgress(0, 1f);
ResetTempMarkLineGroupData(markLine);
if (m_TempGroupData.Count > 0)
{

View File

@@ -167,7 +167,6 @@ namespace XCharts
{
m_LastSplitNumber = axis.splitNumber;
m_LastInterval = axis.interval;
chart.m_IsPlayingAnimation = true;
axis.UpdateMinMaxValue(tempMinValue, tempMaxValue);
axis.context.offset = 0;

View File

@@ -0,0 +1,21 @@
/******************************************/
/* */
/* Copyright (c) 2021 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using System;
namespace XCharts
{
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public sealed class DefaultAnimationAttribute : Attribute
{
public readonly AnimationType type;
public DefaultAnimationAttribute(AnimationType handler)
{
this.type = handler;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b25b7b1d8388945d4bf78e54f094470f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -773,17 +773,6 @@ namespace XCharts
return 0;
}
public float CheckSerieBarAnimation(Serie serie, int dataIndex, float barHig, out bool isBarEnd)
{
float currHig = serie.animation.CheckBarProgress(dataIndex, barHig, serie.dataCount, out isBarEnd);
if (!serie.animation.IsFinish())
{
RefreshPainter(serie);
m_IsPlayingAnimation = true;
}
return currHig;
}
internal void InitSerieHandlers()
{
m_SerieHandlers.Clear();

View File

@@ -93,7 +93,6 @@ namespace XCharts
protected Action<PointerEventData, int> m_OnPointerClickBar;
internal bool m_CheckAnimation = false;
internal bool m_IsPlayingAnimation = false;
internal protected List<string> m_LegendRealShowName = new List<string>();
protected List<Painter> m_PainterList = new List<Painter>();
internal Painter m_PainterTop;
@@ -576,6 +575,7 @@ namespace XCharts
serie.context.colorIndex = GetLegendRealShowNameIndex(serie.legendName);
serie.context.dataPoints.Clear();
serie.context.dataIgnore.Clear();
AnimationStyleHelper.UpdateSerieAnimation(serie);
if (m_OnCustomDrawSerieBeforeCallback != null)
{
m_OnCustomDrawSerieBeforeCallback.Invoke(vh, serie);

View File

@@ -9,7 +9,7 @@
namespace XCharts
{
/// <summary>
/// The delegate function for AxisLabel's formatter. |
/// The delegate function for AxisLabel's formatter.
/// AxisLabel的formatter自定义委托。
/// </summary>
/// <param name="labelIndex">label索引</param>

View File

@@ -15,6 +15,7 @@ namespace XCharts
[SerieHandler(typeof(BarHandler), true)]
[SerieConvert(typeof(Line),typeof(Pie))]
[RequireChartComponent(typeof(GridCoord))]
[DefaultAnimation(AnimationType.BottomToTop)]
public class Bar : Serie, INeedSerieContainer
{
public int containerIndex { get; internal set; }

View File

@@ -67,7 +67,7 @@ namespace XCharts
public override void DrawSerie(VertexHelper vh)
{
DrawXBarSerie(vh, serie, serie.context.colorIndex);
DrawBarSerie(vh, serie, serie.context.colorIndex);
}
private void UpdateSerieContext()
@@ -91,152 +91,7 @@ namespace XCharts
}
}
private void DrawYBarSerie(VertexHelper vh, Bar serie, int colorIndex)
{
if (!serie.show) return;
if (serie.animation.HasFadeOut()) return;
XAxis xAxis;
YAxis yAxis;
GridCoord grid;
if (!chart.TryGetChartComponent<XAxis>(out xAxis, serie.xAxisIndex)) return;
if (!chart.TryGetChartComponent<YAxis>(out yAxis, serie.yAxisIndex)) return;
if (!chart.TryGetChartComponent<GridCoord>(out grid, xAxis.gridIndex)) return;
var dataZoom = chart.GetDataZoomOfAxis(yAxis);
var showData = serie.GetDataList(dataZoom);
float categoryWidth = AxisHelper.GetDataWidth(yAxis, grid.context.height, showData.Count, dataZoom);
float barGap = chart.GetSerieBarGap<Bar>();
float totalBarWidth = chart.GetSerieTotalWidth<Bar>(categoryWidth, barGap);
float barWidth = serie.GetBarWidth(categoryWidth);
float offset = (categoryWidth - totalBarWidth) / 2;
float barGapWidth = barWidth + barWidth * barGap;
float space = serie.barGap == -1 ? offset : offset + chart.GetSerieIndexIfStack<Bar>(serie) * barGapWidth;
var isStack = SeriesHelper.IsStack<Bar>(chart.series, serie.stack);
m_StackSerieData.Clear();
if (isStack) SeriesHelper.UpdateStackDataList(chart.series, serie, dataZoom, m_StackSerieData);
int maxCount = serie.maxShow > 0 ?
(serie.maxShow > showData.Count ? showData.Count : serie.maxShow)
: showData.Count;
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series, serie.stack);
bool dataChanging = false;
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
double xMinValue = xAxis.context.minValue;
double xMaxValue = xAxis.context.maxValue;
var isAllBarEnd = true;
serie.containerIndex = grid.index;
serie.containterInstanceId = grid.instanceId;
for (int i = serie.minShow; i < maxCount; i++)
{
var serieData = showData[i];
if (!serieData.show || serie.IsIgnoreValue(serieData))
{
serie.context.dataPoints.Add(Vector3.zero);
continue;
}
var highlight = serie.data[i].context.highlight
|| serie.highlight;
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, highlight);
serieData.context.canShowLabel = true;
double value = showData[i].GetCurrData(1, dataChangeDuration, xAxis.inverse, xMinValue, xMaxValue);
float borderWidth = value == 0 ? 0 : itemStyle.runtimeBorderWidth;
if (showData[i].IsDataChanged()) dataChanging = true;
float axisLineWidth = value == 0 ? 0
: ((value < 0 ? -1 : 1) * yAxis.axisLine.GetWidth(chart.theme.axis.lineWidth));
float pY = grid.context.y + i * categoryWidth;
if (!yAxis.boundaryGap) pY -= categoryWidth / 2;
float pX = grid.context.x + xAxis.context.offset + axisLineWidth;
if (isStack)
{
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
{
pX += m_StackSerieData[n][i].context.stackHeight;
}
}
var barHig = 0f;
double valueTotal = 0f;
if (isPercentStack)
{
valueTotal = chart.GetSerieSameStackTotalValue<Bar>(serie.stack, i);
barHig = valueTotal != 0 ? (float)((value / valueTotal * grid.context.width)) : 0;
}
else
{
if (yAxis.IsLog())
{
int minIndex = xAxis.GetLogMinIndex();
float nowIndex = xAxis.GetLogValue(value);
barHig = (nowIndex - minIndex) / xAxis.splitNumber * grid.context.width;
}
else
{
valueTotal = xMaxValue - xMinValue;
if (valueTotal != 0)
barHig = (float)((xMinValue > 0 ? value - xMinValue : value)
/ valueTotal * grid.context.width);
}
}
serieData.context.stackHeight = barHig;
var isBarEnd = false;
float currHig = chart.CheckSerieBarAnimation(serie, i, barHig, out isBarEnd);
if (!isBarEnd) isAllBarEnd = false;
Vector3 plt, prt, prb, plb, top;
if (value < 0)
{
plt = new Vector3(pX - borderWidth, pY + space + barWidth - borderWidth);
prt = new Vector3(pX + currHig + borderWidth, pY + space + barWidth - borderWidth);
prb = new Vector3(pX + currHig + borderWidth, pY + space + borderWidth);
plb = new Vector3(pX - borderWidth, pY + space + borderWidth);
}
else
{
plt = new Vector3(pX + borderWidth, pY + space + barWidth - borderWidth);
prt = new Vector3(pX + currHig - borderWidth, pY + space + barWidth - borderWidth);
prb = new Vector3(pX + currHig - borderWidth, pY + space + borderWidth);
plb = new Vector3(pX + borderWidth, pY + space + borderWidth);
}
top = new Vector3(pX + currHig - borderWidth, pY + space + barWidth / 2);
if (serie.clip)
{
plt = chart.ClampInGrid(grid, plt);
prt = chart.ClampInGrid(grid, prt);
prb = chart.ClampInGrid(grid, prb);
plb = chart.ClampInGrid(grid, plb);
top = chart.ClampInGrid(grid, top);
}
serieData.context.rect = Rect.MinMaxRect(plb.x, plb.y, prb.x, prt.y);
serie.context.dataPoints.Add(top);
if (serie.show)
{
switch (serie.barType)
{
case BarType.Normal:
DrawNormalBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
pX, pY, plb, plt, prt, prb, true, grid);
break;
case BarType.Zebra:
DrawZebraBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
pX, pY, plb, plt, prt, prb, true, grid);
break;
case BarType.Capsule:
DrawCapsuleBar(vh, serie, serieData, itemStyle, colorIndex, highlight, space, barWidth,
pX, pY, plb, plt, prt, prb, true, grid);
break;
}
}
}
if (isAllBarEnd) serie.animation.AllBarEnd();
if (dataChanging)
{
chart.RefreshPainter(serie);
}
}
private void DrawXBarSerie(VertexHelper vh, Bar serie, int colorIndex)
private void DrawBarSerie(VertexHelper vh, Bar serie, int colorIndex)
{
if (!serie.show || serie.animation.HasFadeOut())
return;
@@ -273,6 +128,7 @@ namespace XCharts
return;
var axisLength = isY ? grid.context.height : grid.context.width;
var axisXY = isY ? grid.context.y : grid.context.x;
var isStack = SeriesHelper.IsStack<Bar>(chart.series, serie.stack);
if (isStack)
@@ -294,9 +150,9 @@ namespace XCharts
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
double yMinValue = relativedAxis.context.minValue;
double yMaxValue = relativedAxis.context.maxValue;
var isAllBarEnd = true;
serie.containerIndex = grid.index;
serie.containterInstanceId = grid.instanceId;
serie.animation.InitProgress(axisXY, axisXY + axisLength);
for (int i = serie.minShow; i < maxCount; i++)
{
var serieData = showData[i];
@@ -305,6 +161,7 @@ namespace XCharts
serie.context.dataPoints.Add(Vector3.zero);
continue;
}
if (serieData.IsDataChanged())
dataChanging = true;
@@ -329,10 +186,7 @@ namespace XCharts
barHig = AxisHelper.GetAxisValueLength(grid, relativedAxis, categoryWidth, relativedValue);
}
var isBarEnd = false;
float currHig = chart.CheckSerieBarAnimation(serie, i, barHig, out isBarEnd);
if (!isBarEnd)
isAllBarEnd = false;
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
Vector3 plb, plt, prt, prb, top;
UpdateRectPosition(grid, isY, relativedValue, pX, pY, space, borderWidth, barWidth, currHig,
@@ -359,10 +213,16 @@ namespace XCharts
break;
}
}
if (serie.animation.CheckDetailBreak(top, isY))
{
break;
}
}
if (isAllBarEnd)
if (!serie.animation.IsFinish())
{
serie.animation.AllBarEnd();
serie.animation.CheckProgress();
chart.RefreshPainter(serie);
}
if (dataChanging)
{

View File

@@ -11,6 +11,7 @@ namespace XCharts
{
[System.Serializable]
[SerieHandler(typeof(CandlestickHandler), true)]
[DefaultAnimation(AnimationType.LeftToRight)]
public class Candlestick : Serie, INeedSerieContainer
{
public int containerIndex { get; internal set; }

View File

@@ -44,7 +44,6 @@ namespace XCharts
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
double yMinValue = yAxis.context.minValue;
double yMaxValue = yAxis.context.maxValue;
var isAllBarEnd = true;
var isYAxis = false;
serie.containerIndex = grid.index;
serie.containterInstanceId = grid.instanceId;
@@ -80,9 +79,7 @@ namespace XCharts
pY += (float)((open - minCut) / valueTotal * grid.context.height);
}
serieData.context.stackHeight = barHig;
var isBarEnd = false;
float currHig = chart.CheckSerieBarAnimation(serie, i, barHig, out isBarEnd);
if (!isBarEnd) isAllBarEnd = false;
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
Vector3 plb, plt, prt, prb, top;
plb = new Vector3(pX + space + borderWidth, pY + borderWidth);
@@ -145,9 +142,9 @@ namespace XCharts
UGL.DrawLine(vh, openCenterPos, heighPos, borderWidth, borderColor);
}
}
if (isAllBarEnd)
if (!serie.animation.IsFinish())
{
serie.animation.AllBarEnd();
serie.animation.CheckProgress();
}
if (dataChanging)
{

View File

@@ -158,7 +158,7 @@ namespace XCharts
{
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
var destAngle = GetCurrAngle(serie, true);
serie.animation.InitProgress(0, serie.startAngle, destAngle);
serie.animation.InitProgress(serie.startAngle, destAngle);
var currAngle = serie.animation.IsFinish() ? GetCurrAngle(serie, false) : serie.animation.GetCurrDetail();
DrawProgressBar(vh, serie, (float)currAngle);
DrawStageColor(vh, serie);

View File

@@ -11,6 +11,7 @@ namespace XCharts
{
[System.Serializable]
[SerieHandler(typeof(HeatmapHandler), true)]
[DefaultAnimation(AnimationType.LeftToRight)]
public class Heatmap : Serie, INeedSerieContainer
{
public int containerIndex { get; internal set; }

View File

@@ -85,7 +85,7 @@ namespace XCharts
var borderToColor = serie.itemStyle.opacity > 0 ? serie.itemStyle.borderToColor : ChartConst.clearColor32;
borderToColor.a = (byte)(borderToColor.a * serie.itemStyle.opacity);
serie.context.dataPoints.Clear();
serie.animation.InitProgress(1, 0, xCount);
serie.animation.InitProgress(0, xCount);
var animationIndex = serie.animation.GetCurrIndex();
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var dataChanging = false;
@@ -146,7 +146,6 @@ namespace XCharts
if (!serie.animation.IsFinish())
{
serie.animation.CheckProgress(xCount);
chart.m_IsPlayingAnimation = true;
chart.RefreshPainter(serie);
}
if (dataChanging)

View File

@@ -14,6 +14,7 @@ namespace XCharts
[SerieHandler(typeof(LineHandler), true)]
[SerieConvert(typeof(Bar), typeof(Pie))]
[CoordOptions(typeof(GridCoord), typeof(PolarCoord))]
[DefaultAnimation(AnimationType.LeftToRight)]
public class Line : Serie, INeedSerieContainer
{
public int containerIndex { get; internal set; }

View File

@@ -352,7 +352,6 @@ namespace XCharts
return;
serie.animation.InitProgress(serie.context.dataPoints, isY);
serie.animation.SetDataFinish(0);
VisualMapHelper.AutoSetLineMinMax(visualMap, serie, isY, axis, relativedAxis);
LineHelper.UpdateSerieDrawPoints(serie, chart.settings, chart.theme, isY);
@@ -365,7 +364,6 @@ namespace XCharts
{
serie.animation.CheckProgress();
serie.animation.CheckSymbol(serie.symbol.GetSize(null, chart.theme.serie.lineSymbolSize));
chart.m_IsPlayingAnimation = true;
chart.RefreshPainter(serie);
}
}
@@ -374,27 +372,37 @@ namespace XCharts
double yValue, int i, float scaleWid, bool isStack, ref Vector3 np)
{
float xPos, yPos;
var gridXY = isY ? grid.context.x : grid.context.y;
if (isY)
{
xPos = AxisHelper.GetAxisPosition(grid, relativedAxis, scaleWid, yValue);
var valueHig = AxisHelper.GetAxisValueLength(grid, relativedAxis, scaleWid, yValue);
valueHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, valueHig);
xPos = gridXY + valueHig;
yPos = AxisHelper.GetAxisPosition(grid, axis, scaleWid, xValue);
if (isStack)
{
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
yPos += m_StackSerieData[n][i].context.stackHeight;
}
}
else
{
xPos = AxisHelper.GetAxisPosition(grid, axis, scaleWid, xValue);
yPos = AxisHelper.GetAxisPosition(grid, relativedAxis, scaleWid, yValue);
if (isStack)
{
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
xPos += m_StackSerieData[n][i].context.stackHeight;
}
}
else
{
var valueHig = AxisHelper.GetAxisValueLength(grid, relativedAxis, scaleWid, yValue);
valueHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, valueHig);
yPos = gridXY + valueHig;
xPos = AxisHelper.GetAxisPosition(grid, axis, scaleWid, xValue);
if (isStack)
{
for (int n = 0; n < m_StackSerieData.Count - 1; n++)
yPos += m_StackSerieData[n][i].context.stackHeight;
}
}
np = new Vector3(xPos, yPos);
return yPos;
}

View File

@@ -44,8 +44,7 @@ namespace XCharts
var currDetailProgress = 0f;
var totalDetailProgress = datas.Count;
serie.animation.InitProgress(serie.context.dataPoints.Count, currDetailProgress, totalDetailProgress);
serie.animation.SetDataFinish(0);
serie.animation.InitProgress(currDetailProgress, totalDetailProgress);
for (int i = 1; i < datas.Count; i++)
{
@@ -62,7 +61,6 @@ namespace XCharts
{
serie.animation.CheckProgress(totalDetailProgress);
serie.animation.CheckSymbol(serie.symbol.GetSize(null, chart.theme.serie.lineSymbolSize));
chart.m_IsPlayingAnimation = true;
chart.RefreshChart();
}
}

View File

@@ -259,9 +259,6 @@ namespace XCharts
var lastDataIsIgnore = datas[0].isIgnoreBreak;
for (int i = 1; i < dataCount; i++)
{
if (!serie.animation.NeedAnimation(i))
break;
var cdata = datas[i];
var isIgnore = cdata.isIgnoreBreak;
@@ -272,16 +269,10 @@ namespace XCharts
if (serie.animation.CheckDetailBreak(cp, isY))
{
isBreak = true;
var progress = serie.animation.GetCurrDetail();
var ip = Vector3.zero;
var axisStartPos = isY ? new Vector3(-10000, progress) : new Vector3(progress, -10000);
var axisEndPos = isY ? new Vector3(10000, progress) : new Vector3(progress, 10000);
if (UGLHelper.GetIntersection(lp, cp, axisStartPos, axisEndPos, ref ip))
var progress = serie.animation.GetCurrDetail();
if (AnimationStyleHelper.GetAnimationPosition(serie.animation, isY, lp, cp, progress, ref ip))
cp = np = ip;
}
bool bitp = true, bibp = true;
UGLHelper.GetLinePoints(lp, cp, np, lineWidth,
@@ -320,9 +311,7 @@ namespace XCharts
}
}
lastDataIsIgnore = isIgnore;
if (!isBreak)
serie.animation.SetDataFinish(i);
else
if (isBreak)
break;
}
}

View File

@@ -169,7 +169,7 @@ namespace XCharts
var colorIndex = chart.m_LegendRealShowName.IndexOf(serie.serieName);
var realHig = (float)((value - serie.min) / (serie.max - serie.min) * radius * 2);
serie.animation.InitProgress(1, 0, realHig);
serie.animation.InitProgress(0, realHig);
var hig = serie.animation.IsFinish() ? realHig : serie.animation.GetCurrDetail();
var a = Mathf.Abs(radius - hig + (hig > radius ? serie.waveHeight : -serie.waveHeight));
@@ -256,7 +256,6 @@ namespace XCharts
if (!serie.animation.IsFinish())
{
serie.animation.CheckProgress(realHig);
chart.m_IsPlayingAnimation = true;
chart.RefreshPainter(serie);
}
}
@@ -282,7 +281,7 @@ namespace XCharts
var colorIndex = chart.m_LegendRealShowName.IndexOf(serie.serieName);
var realHig = (value - serie.min) / (serie.max - serie.min) * vessel.context.height;
serie.animation.InitProgress(1, 0, (float)realHig);
serie.animation.InitProgress(0, (float)realHig);
var hig = serie.animation.IsFinish() ? realHig : serie.animation.GetCurrDetail();
var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, colorIndex, false);
var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, colorIndex, false);
@@ -371,7 +370,6 @@ namespace XCharts
if (!serie.animation.IsFinish())
{
serie.animation.CheckProgress(realHig);
chart.m_IsPlayingAnimation = true;
chart.RefreshPainter(serie);
}
}

View File

@@ -59,8 +59,7 @@ namespace XCharts
? parallel.context.x + parallel.context.width
: parallel.context.y + parallel.context.height;
serie.animation.InitProgress(serie.showDataDimension, currDetailProgress, totalDetailProgress);
serie.animation.SetDataFinish(0);
serie.animation.InitProgress(currDetailProgress, totalDetailProgress);
serie.context.dataPoints.Clear();
serie.containerIndex = parallel.index;
@@ -86,7 +85,6 @@ namespace XCharts
else if (pos.x <= currProgress)
{
m_Points.Add(pos);
serie.animation.SetDataFinish(i);
}
else
{
@@ -110,7 +108,6 @@ namespace XCharts
else if (pos.y <= currProgress)
{
m_Points.Add(pos);
serie.animation.SetDataFinish(i);
}
else
{
@@ -135,7 +132,6 @@ namespace XCharts
if (!serie.animation.IsFinish())
{
serie.animation.CheckProgress(totalDetailProgress - currDetailProgress);
chart.m_IsPlayingAnimation = true;
chart.RefreshPainter(serie);
}
}

View File

@@ -10,6 +10,7 @@ namespace XCharts
[System.Serializable]
[SerieConvert(typeof(Line), typeof(Bar))]
[SerieHandler(typeof(PieHandler), true)]
[DefaultAnimation(AnimationType.Clockwise)]
public class Pie : Serie
{
public override bool useDataNameForColor { get { return true; } }

View File

@@ -188,7 +188,6 @@ namespace XCharts
{
dataTotalFilterMinAngle = GetTotalAngle(serie, runtimePieDataTotal, ref totalDegree);
}
serie.animation.InitProgress(data.Count, 0, 360);
for (int n = 0; n < data.Count; n++)
{
var serieData = data[n];
@@ -297,13 +296,13 @@ namespace XCharts
private void DrawPie(VertexHelper vh, Serie serie)
{
var data = serie.data;
serie.animation.InitProgress(data.Count, 0, 360);
if (!serie.show || serie.animation.HasFadeOut())
{
return;
}
bool dataChanging = false;
var dataChanging = false;
var data = serie.data;
serie.animation.InitProgress(0, 360);
for (int n = 0; n < data.Count; n++)
{
var serieData = data[n];
@@ -311,41 +310,51 @@ namespace XCharts
{
continue;
}
if (serieData.IsDataChanged())
dataChanging = true;
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, serieData.context.highlight);
if (serieData.IsDataChanged()) dataChanging = true;
var serieNameCount = chart.m_LegendRealShowName.IndexOf(serieData.legendName);
var color = SerieHelper.GetItemColor(serie, serieData, chart.theme, serieNameCount,
serieData.context.highlight);
var toColor = SerieHelper.GetItemToColor(serie, serieData, chart.theme, serieNameCount,
serieData.context.highlight);
var borderWidth = itemStyle.borderWidth;
var borderColor = itemStyle.borderColor;
var progress = AnimationStyleHelper.CheckDataAnimation(chart, serie, n, 1);
var insideRadius = serieData.context.insideRadius * progress;
var outsideRadius = serieData.context.outsideRadius * progress;
if (serie.pieClickOffset && serieData.selected)
{
var drawEndDegree = serieData.context.currentAngle;
var needRoundCap = serie.roundCap && serieData.context.insideRadius > 0;
UGL.DrawDoughnut(vh, serieData.context.offsetCenter, serieData.context.insideRadius,
serieData.context.outsideRadius, color, toColor, Color.clear, serieData.context.startAngle,
var needRoundCap = serie.roundCap && insideRadius > 0;
UGL.DrawDoughnut(vh, serieData.context.offsetCenter, insideRadius,
outsideRadius, color, toColor, Color.clear, serieData.context.startAngle,
drawEndDegree, borderWidth, borderColor, serie.pieSpace / 2, chart.settings.cicleSmoothness,
needRoundCap, true);
}
else
{
var drawEndDegree = serieData.context.currentAngle;
var needRoundCap = serie.roundCap && serieData.context.insideRadius > 0;
UGL.DrawDoughnut(vh, serie.context.center, serieData.context.insideRadius,
serieData.context.outsideRadius, color, toColor, Color.clear, serieData.context.startAngle,
var needRoundCap = serie.roundCap && insideRadius > 0;
UGL.DrawDoughnut(vh, serie.context.center, insideRadius,
outsideRadius, color, toColor, Color.clear, serieData.context.startAngle,
drawEndDegree, borderWidth, borderColor, serie.pieSpace / 2, chart.settings.cicleSmoothness,
needRoundCap, true);
DrawPieCenter(vh, serie, itemStyle, serieData.context.insideRadius);
DrawPieCenter(vh, serie, itemStyle, insideRadius);
}
if (!serie.animation.CheckDetailBreak(serieData.context.toAngle)) serie.animation.SetDataFinish(n);
else break;
if (serie.animation.CheckDetailBreak(serieData.context.toAngle))
break;
}
if (!serie.animation.IsFinish())
{
serie.animation.CheckProgress(360);
serie.animation.CheckProgress();
serie.animation.CheckSymbol(serie.symbol.GetSize(null, chart.theme.serie.lineSymbolSize));
chart.RefreshPainter(serie);
}

View File

@@ -122,7 +122,7 @@ namespace XCharts
var angle = 2 * Mathf.PI / indicatorNum;
var centerPos = radar.context.center;
var serieNameCount = -1;
serie.animation.InitProgress(1, 0, 1);
serie.animation.InitProgress(0, 1);
if (!serie.show || serie.animation.HasFadeOut())
{
return;
@@ -288,7 +288,7 @@ namespace XCharts
var angle = 2 * Mathf.PI / indicatorNum;
var centerPos = radar.context.center;
var serieNameCount = -1;
serie.animation.InitProgress(1, 0, 1);
serie.animation.InitProgress(0, 1);
if (!serie.show || serie.animation.HasFadeOut())
{
return;

View File

@@ -69,7 +69,7 @@ namespace XCharts
{
if (!serie.show || serie.animation.HasFadeOut()) return;
var data = serie.data;
serie.animation.InitProgress(data.Count, serie.startAngle, serie.startAngle + 360);
serie.animation.InitProgress(serie.startAngle, serie.startAngle + 360);
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var ringWidth = serie.context.outsideRadius - serie.context.insideRadius;

View File

@@ -149,7 +149,7 @@ namespace XCharts
int maxCount = serie.maxShow > 0 ?
(serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow)
: serie.dataCount;
serie.animation.InitProgress(1, 0, 1);
serie.animation.InitProgress(0, 1);
var rate = serie.animation.GetCurrRate();
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
var dataChanging = false;
@@ -221,7 +221,6 @@ namespace XCharts
if (!serie.animation.IsFinish())
{
serie.animation.CheckProgress(1);
chart.m_IsPlayingAnimation = true;
chart.RefreshPainter(serie);
}
if (dataChanging)
@@ -250,7 +249,7 @@ namespace XCharts
int maxCount = serie.maxShow > 0 ?
(serie.maxShow > serie.dataCount ? serie.dataCount : serie.maxShow)
: serie.dataCount;
serie.animation.InitProgress(1, 0, 1);
serie.animation.InitProgress(0, 1);
var rate = serie.animation.GetCurrRate();
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
@@ -324,7 +323,6 @@ namespace XCharts
if (!serie.animation.IsFinish())
{
serie.animation.CheckProgress(1);
chart.m_IsPlayingAnimation = true;
chart.RefreshPainter(serie);
}
if (dataChanging)

View File

@@ -71,31 +71,6 @@ namespace XCharts
return (T)type.GetCustomAttributes(typeof(T), false)[0];
}
public static D Mapper<D, S>(S s)
{
D d = Activator.CreateInstance<D>();
try
{
var Types = s.GetType();//获得类型
var Typed = typeof(D);
foreach (PropertyInfo sp in Types.GetProperties())//获得类型的属性字段
{
foreach (PropertyInfo dp in Typed.GetProperties())
{
if (dp.Name == sp.Name)//判断属性名是否相同
{
dp.SetValue(d, sp.GetValue(s, null), null);//获得s对象属性的值复制给d对象的属性
}
}
}
}
catch (Exception ex)
{
throw ex;
}
return d;
}
public static bool CopyFolder(string sourPath, string destPath)
{
try