mirror of
https://github.com/XCharts-Team/XCharts.git
synced 2026-05-14 20:00:09 +00:00
增加Animation的添加动画支持
This commit is contained in:
@@ -234,6 +234,8 @@ the animation of serie.
|
||||
|dataChangeDuration|500||The milliseconds duration of the data change animation.
|
||||
|actualDuration|||The milliseconds actual duration of the first animation.
|
||||
|unscaledTime||v3.4.0|Animation updates independently of Time.timeScale.
|
||||
|dataAddEnable|true|v3.8.0|Whether to enable data add animation.
|
||||
|dataAddDuration|500|v3.8.0|The milliseconds duration of the data add animation.
|
||||
|
||||
```mdx-code-block
|
||||
</APITable>
|
||||
@@ -1500,6 +1502,7 @@ Polar coordinate can be used in scatter and line chart. Every polar coordinate h
|
||||
|center|||The center of ploar. The center[0] is the x-coordinate, and the center[1] is the y-coordinate. When value between 0 and 1 represents a percentage relative to the chart.
|
||||
|radius|||the radius of polar.
|
||||
|backgroundColor|||Background color of polar, which is transparent by default.
|
||||
|indicatorLabelOffset|30f|v3.8.0|The offset of indicator label.
|
||||
|
||||
```mdx-code-block
|
||||
</APITable>
|
||||
|
||||
@@ -66,6 +66,13 @@ slug: /changelog
|
||||
|
||||
## master
|
||||
|
||||
版本要点:
|
||||
|
||||
* 新增数据动画
|
||||
|
||||
日志详情:
|
||||
|
||||
* (2023.07.03) 增加`Animation`的添加动画支持
|
||||
* (2023.06.30) 增加`PolarCood`的`indicatorLabelOffset`设置指示文本偏移的支持
|
||||
* (2023.06.30) 修复`Axis`的`IndicatorLabel`的背景颜色可能不正常的问题
|
||||
* (2023.06.30) 增加`Axis`的`IndicatorLabel`可自定义`color`的支持
|
||||
|
||||
@@ -234,6 +234,8 @@ import APITable from '@site/src/components/APITable';
|
||||
|dataChangeDuration|500||数据变更的动画时长(毫秒)。
|
||||
|actualDuration|||实际的动画时长(毫秒)。
|
||||
|unscaledTime||v3.4.0|动画是否受TimeScaled的影响。默认为 false 受TimeScaled的影响。
|
||||
|dataAddEnable|true|v3.8.0|是否开启数据增加动画。
|
||||
|dataAddDuration|500|v3.8.0|数据增加的动画时长(毫秒)。
|
||||
|
||||
```mdx-code-block
|
||||
</APITable>
|
||||
@@ -1500,6 +1502,7 @@ Drawing grid in rectangular coordinate. Line chart, bar chart, and scatter chart
|
||||
|center|||极坐标的中心点。数组的第一项是横坐标,第二项是纵坐标。 当值为0-1之间时表示百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度。
|
||||
|radius|||半径。radius[0]表示内径,radius[1]表示外径。
|
||||
|backgroundColor|||极坐标的背景色,默认透明。
|
||||
|indicatorLabelOffset|30f|v3.8.0|指示器标签的偏移量。
|
||||
|
||||
```mdx-code-block
|
||||
</APITable>
|
||||
|
||||
@@ -4,6 +4,23 @@ using XCharts.Runtime;
|
||||
|
||||
namespace XCharts.Editor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(XCharts.Runtime.AnimationInfo), true)]
|
||||
public class AnimationInfoDrawer : 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_Type");
|
||||
PropertyField(prop, "m_Delay");
|
||||
PropertyField(prop, "m_Duration");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(AnimationStyle), true)]
|
||||
public class AnimationDrawer : BasePropertyDrawer
|
||||
{
|
||||
@@ -15,17 +32,11 @@ namespace XCharts.Editor
|
||||
{
|
||||
++EditorGUI.indentLevel;
|
||||
PropertyField(prop, "m_Type");
|
||||
PropertyField(prop, "m_FadeInDuration");
|
||||
PropertyField(prop, "m_FadeInDelay");
|
||||
PropertyField(prop, "m_FadeOutDuration");
|
||||
PropertyField(prop, "m_FadeOutDelay");
|
||||
PropertyField(prop, "m_DataChangeEnable");
|
||||
PropertyField(prop, "m_DataChangeDuration");
|
||||
PropertyField(prop, "m_UnscaledTime");
|
||||
// using(new EditorGUI.DisabledGroupScope(true))
|
||||
// {
|
||||
// PropertyField(prop, "m_ActualDuration");
|
||||
// }
|
||||
PropertyField(prop, "m_FadeIn");
|
||||
PropertyField(prop, "m_FadeOut");
|
||||
PropertyField(prop, "m_Updated");
|
||||
PropertyField(prop, "m_Added");
|
||||
--EditorGUI.indentLevel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@ namespace XCharts.Example
|
||||
var serie = chart.GetSerie(0);
|
||||
serie.animation.enable = true;
|
||||
//自定义每个数据项的渐入延时
|
||||
serie.animation.fadeInDelayFunction = CustomFadeInDelay;
|
||||
serie.animation.fadeIn.delayFunction = CustomFadeInDelay;
|
||||
//自定义每个数据项的渐入时长
|
||||
serie.animation.fadeInDurationFunction = CustomFadeInDuration;
|
||||
serie.animation.fadeIn.durationFunction = CustomFadeInDuration;
|
||||
}
|
||||
|
||||
float CustomFadeInDelay(int dataIndex)
|
||||
|
||||
155
Examples/Example_RandomData.cs
Normal file
155
Examples/Example_RandomData.cs
Normal file
@@ -0,0 +1,155 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
using XCharts.Runtime;
|
||||
#if INPUT_SYSTEM_ENABLED
|
||||
using Input = XCharts.Runtime.InputHelper;
|
||||
#endif
|
||||
namespace XCharts.Example
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
//[ExecuteInEditMode]
|
||||
public class Example_RandomData : MonoBehaviour
|
||||
{
|
||||
public int initDataNum = 3;
|
||||
BaseChart chart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
chart = gameObject.GetComponent<BaseChart>();
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
//chart.ClearData();
|
||||
// for (int i = 0; i < initDataNum; i++)
|
||||
// AddData();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
{
|
||||
AddData();
|
||||
}
|
||||
else if (Input.GetKeyDown(KeyCode.U))
|
||||
{
|
||||
UpdateData();
|
||||
}
|
||||
}
|
||||
|
||||
void AddData()
|
||||
{
|
||||
if (chart is HeatmapChart)
|
||||
{
|
||||
var xAxis = chart.GetChartComponent<XAxis>();
|
||||
var yAxis = chart.GetChartComponent<YAxis>();
|
||||
if (xAxis != null && yAxis != null)
|
||||
{
|
||||
chart.AddXAxisData((xAxis.data.Count + 1).ToString());
|
||||
for (int i = 0; i < yAxis.data.Count; i++)
|
||||
{
|
||||
chart.AddData(0, xAxis.data.Count - 1, i, Random.Range(10, 90));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
var xAxis = chart.GetChartComponent<XAxis>();
|
||||
if (xAxis != null)
|
||||
{
|
||||
if (xAxis.type == Axis.AxisType.Category)
|
||||
{
|
||||
chart.AddXAxisData("x" + (xAxis.data.Count + 1));
|
||||
}
|
||||
}
|
||||
foreach (var serie in chart.series)
|
||||
{
|
||||
AddSerieRandomData(serie, xAxis);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateData()
|
||||
{
|
||||
foreach (var serie in chart.series)
|
||||
{
|
||||
UpdateSerieRandomData(serie);
|
||||
}
|
||||
}
|
||||
|
||||
void AddSerieRandomData(Serie serie, XAxis xAxis)
|
||||
{
|
||||
if (serie is Line || serie is Bar || serie is Scatter || serie is EffectScatter)
|
||||
{
|
||||
if (xAxis.type == Axis.AxisType.Category)
|
||||
{
|
||||
chart.AddData(serie.index, 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)
|
||||
{
|
||||
chart.AddData(serie.index, Random.Range(10, 90), 100, "data" + serie.dataCount);
|
||||
}
|
||||
else if (serie is Radar)
|
||||
{
|
||||
var list = new System.Collections.Generic.List<double>();
|
||||
for (int i = 0; i < 5; i++)
|
||||
list.Add(Random.Range(10, 90));
|
||||
chart.AddData(serie.index, list, "data" + serie.dataCount);
|
||||
}
|
||||
else if (serie is Candlestick)
|
||||
{
|
||||
var open = Random.Range(20, 60);
|
||||
var close = Random.Range(40, 90);
|
||||
var lowest = Random.Range(0, 50);
|
||||
var heighest = Random.Range(50, 100);
|
||||
chart.AddData(serie.index, serie.dataCount, open, close, lowest, heighest);
|
||||
}
|
||||
else
|
||||
{
|
||||
chart.AddData(serie.index, Random.Range(10, 90), "data" + serie.dataCount);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateSerieRandomData(Serie serie)
|
||||
{
|
||||
var index = Random.Range(0, serie.dataCount);
|
||||
if (serie is Ring)
|
||||
{
|
||||
chart.UpdateData(serie.index, index, Random.Range(10, 90), 100);
|
||||
}
|
||||
else if (serie is Radar)
|
||||
{
|
||||
var dimension = Random.Range(0, 5);
|
||||
chart.UpdateData(serie.index, index, dimension, Random.Range(10, 90));
|
||||
}
|
||||
else if (serie is Heatmap)
|
||||
{
|
||||
var xAxis = chart.GetChartComponent<XAxis>();
|
||||
var yAxis = chart.GetChartComponent<YAxis>();
|
||||
var xIndex = Random.Range(0, xAxis.data.Count);
|
||||
var yIndex = Random.Range(0, yAxis.data.Count);
|
||||
chart.UpdateData(serie.index, xIndex, yIndex, Random.Range(10, 90));
|
||||
}
|
||||
else if (serie is Candlestick)
|
||||
{
|
||||
var open = Random.Range(20, 60);
|
||||
var close = Random.Range(40, 90);
|
||||
var lowest = Random.Range(0, 50);
|
||||
var heighest = Random.Range(50, 100);
|
||||
chart.UpdateData(serie.index, index, new List<double> { open, close, lowest, heighest });
|
||||
}
|
||||
else
|
||||
{
|
||||
chart.UpdateData(serie.index, index, Random.Range(10, 90));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Examples/Example_RandomData.cs.meta
Normal file
11
Examples/Example_RandomData.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 40c5e5447025744389f5aa5f7b21573d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -43,6 +43,52 @@ 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.
|
||||
/// |动画表现。
|
||||
@@ -54,30 +100,24 @@ namespace XCharts.Runtime
|
||||
[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;
|
||||
[SerializeField] private float m_FadeOutDuration = 1000f;
|
||||
[SerializeField] private float m_FadeOutDelay = 0;
|
||||
[SerializeField] private bool m_DataChangeEnable = true;
|
||||
[SerializeField] private float m_DataChangeDuration = 500;
|
||||
[SerializeField] private float m_ActualDuration;
|
||||
[SerializeField][Since("v3.4.0")] private bool m_UnscaledTime;
|
||||
/// <summary>
|
||||
/// 自定义渐入动画延时函数。返回ms值。
|
||||
/// </summary>
|
||||
[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 };
|
||||
|
||||
[Obsolete("Use animation.fadeIn.delayFunction instead.", true)]
|
||||
public AnimationDelayFunction fadeInDelayFunction;
|
||||
/// <summary>
|
||||
/// 自定义渐入动画时长函数。返回ms值。
|
||||
/// </summary>
|
||||
[Obsolete("Use animation.fadeIn.durationFunction instead.", true)]
|
||||
public AnimationDurationFunction fadeInDurationFunction;
|
||||
/// <summary>
|
||||
/// 自定义渐出动画延时函数。返回ms值。
|
||||
/// </summary>
|
||||
[Obsolete("Use animation.fadeOut.delayFunction instead.", true)]
|
||||
public AnimationDelayFunction fadeOutDelayFunction;
|
||||
/// <summary>
|
||||
/// 自定义渐出动画时长函数。返回ms值。
|
||||
/// </summary>
|
||||
[Obsolete("Use animation.fadeOut.durationFunction instead.", true)]
|
||||
public AnimationDurationFunction fadeOutDurationFunction;
|
||||
[Obsolete("Use animation.fadeIn.OnAnimationEnd() instead.", true)]
|
||||
public Action fadeInFinishCallback { get; set; }
|
||||
[Obsolete("Use animation.fadeOut.OnAnimationEnd() instead.", true)]
|
||||
public Action fadeOutFinishCallback { get; set; }
|
||||
public AnimationStyleContext context = new AnimationStyleContext();
|
||||
|
||||
/// <summary>
|
||||
@@ -91,68 +131,40 @@ namespace XCharts.Runtime
|
||||
/// </summary>
|
||||
public AnimationType type { get { return m_Type; } set { m_Type = value; } }
|
||||
/// <summary>
|
||||
/// Easing method used for the first animation.
|
||||
/// |动画的缓动效果。
|
||||
/// </summary>
|
||||
//public Easing easting { get { return m_Easting; } set { m_Easting = value; } }
|
||||
/// <summary>
|
||||
/// The milliseconds duration of the fadeIn animation.
|
||||
/// |设定的渐入动画时长(毫秒)。如果要设置单个数据项的渐入时长,可以用代码定制:customFadeInDuration。
|
||||
/// </summary>
|
||||
public float fadeInDuration { get { return m_FadeInDuration; } set { m_FadeInDuration = value < 0 ? 0 : value; } }
|
||||
/// <summary>
|
||||
/// The milliseconds duration of the fadeOut animation.
|
||||
/// |设定的渐出动画时长(毫秒)。如果要设置单个数据项的渐出时长,可以用代码定制:customFadeOutDuration。
|
||||
/// </summary>
|
||||
public float fadeOutDuration { get { return m_FadeOutDuration; } set { m_FadeOutDuration = value < 0 ? 0 : value; } }
|
||||
/// <summary>
|
||||
/// The milliseconds actual duration of the first animation.
|
||||
/// |实际的动画时长(毫秒)。
|
||||
/// </summary>
|
||||
public float actualDuration { get { return m_ActualDuration; } }
|
||||
/// <summary>
|
||||
/// Whether to set graphic number threshold to animation. Animation will be disabled when graphic number is larger than threshold.
|
||||
/// |是否开启动画的阈值,当单个系列显示的图形数量大于这个阈值时会关闭动画。
|
||||
/// </summary>
|
||||
public int threshold { get { return m_Threshold; } set { m_Threshold = value; } }
|
||||
/// <summary>
|
||||
/// The milliseconds delay before updating the first animation.
|
||||
/// |渐入动画延时(毫秒)。如果要设置单个数据项的延时,可以用代码定制:customFadeInDelay。
|
||||
/// </summary>
|
||||
public float fadeInDelay { get { return m_FadeInDelay; } set { m_FadeInDelay = value < 0 ? 0 : value; } }
|
||||
/// <summary>
|
||||
/// 渐出动画延时(毫秒)。如果要设置单个数据项的延时,可以用代码定制:customFadeOutDelay。
|
||||
/// </summary>
|
||||
public float fadeOutDelay { get { return m_FadeOutDelay; } set { m_FadeInDelay = value < 0 ? 0 : value; } }
|
||||
/// <summary>
|
||||
/// 是否开启数据变更动画。
|
||||
/// </summary>
|
||||
public bool dataChangeEnable { get { return m_DataChangeEnable; } set { m_DataChangeEnable = value; } }
|
||||
/// <summary>
|
||||
/// The milliseconds duration of the data change animation.
|
||||
/// |数据变更的动画时长(毫秒)。
|
||||
/// </summary>
|
||||
public float dataChangeDuration { get { return m_DataChangeDuration; } set { m_DataChangeDuration = value < 0 ? 0 : value; } }
|
||||
/// <summary>
|
||||
/// Animation updates independently of Time.timeScale.
|
||||
/// |动画是否受TimeScaled的影响。默认为 false 受TimeScaled的影响。
|
||||
/// </summary>
|
||||
public bool unscaledTime { get { return m_UnscaledTime; } set { m_UnscaledTime = value; } }
|
||||
/// <summary>
|
||||
/// 渐入动画完成回调
|
||||
/// Fade in animation configuration.
|
||||
/// |渐入动画配置。
|
||||
/// </summary>
|
||||
public Action fadeInFinishCallback { get; set; }
|
||||
public AnimationFadeIn fadeIn { get { return m_FadeIn; } }
|
||||
/// <summary>
|
||||
/// 渐出动画完成回调
|
||||
/// Fade out animation configuration.
|
||||
/// |渐出动画配置。
|
||||
/// </summary>
|
||||
public Action fadeOutFinishCallback { get; set; }
|
||||
public AnimationFadeOut fadeOut { get { return m_FadeOut; } }
|
||||
/// <summary>
|
||||
/// Update data animation configuration.
|
||||
/// |更新数据动画配置。
|
||||
/// </summary>
|
||||
public AnimationUpdated updated { get { return m_Updated; } }
|
||||
/// <summary>
|
||||
/// Add data animation configuration.
|
||||
/// |添加数据动画配置。
|
||||
/// </summary>
|
||||
public AnimationAdded added { get { return m_Added; } }
|
||||
|
||||
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;
|
||||
private bool m_FadeOut = false;
|
||||
private bool m_FadeOuted = false;
|
||||
private bool m_IsInit = false;
|
||||
|
||||
private float startTime { get; set; }
|
||||
@@ -164,7 +176,7 @@ namespace XCharts.Runtime
|
||||
|
||||
public void FadeIn()
|
||||
{
|
||||
if (m_FadeOut)
|
||||
if (m_FadeOut.start)
|
||||
return;
|
||||
|
||||
if (m_IsPause)
|
||||
@@ -173,15 +185,15 @@ namespace XCharts.Runtime
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_FadeIn)
|
||||
if (m_FadeIn.start)
|
||||
return;
|
||||
|
||||
startTime = Time.time;
|
||||
m_FadeIn = true;
|
||||
m_FadeIn.start = true;
|
||||
m_IsEnd = false;
|
||||
m_IsInit = false;
|
||||
m_IsPause = false;
|
||||
m_FadeOuted = false;
|
||||
m_FadeOut.end = false;
|
||||
m_CurrDetailProgress = 0;
|
||||
m_DestDetailProgress = 1;
|
||||
m_CurrSymbolProgress = 0;
|
||||
@@ -203,9 +215,9 @@ namespace XCharts.Runtime
|
||||
return;
|
||||
}
|
||||
|
||||
m_FadeOut = true;
|
||||
m_FadeOut.start = true;
|
||||
startTime = Time.time;
|
||||
m_FadeIn = true;
|
||||
m_FadeIn.start = true;
|
||||
m_IsEnd = false;
|
||||
m_IsInit = false;
|
||||
m_IsPause = false;
|
||||
@@ -237,37 +249,36 @@ namespace XCharts.Runtime
|
||||
if (m_IsEnd)
|
||||
return;
|
||||
|
||||
m_ActualDuration = (int) ((Time.time - startTime) * 1000) - (m_FadeOut ? fadeOutDelay : fadeInDelay);
|
||||
m_IsEnd = true;
|
||||
m_IsInit = false;
|
||||
|
||||
if (m_FadeIn)
|
||||
if (m_FadeIn.start)
|
||||
{
|
||||
m_FadeIn = false;
|
||||
if (fadeInFinishCallback != null)
|
||||
m_FadeIn.start = false;
|
||||
if (m_FadeIn.OnAnimationEnd != null)
|
||||
{
|
||||
fadeInFinishCallback();
|
||||
m_FadeIn.OnAnimationEnd();
|
||||
}
|
||||
}
|
||||
if (m_FadeOut)
|
||||
if (m_FadeOut.start)
|
||||
{
|
||||
m_FadeOut = false;
|
||||
m_FadeOuted = true;
|
||||
if (fadeOutFinishCallback != null)
|
||||
m_FadeOut.start = false;
|
||||
m_FadeOut.end = true;
|
||||
if (m_FadeOut.OnAnimationEnd != null)
|
||||
{
|
||||
fadeOutFinishCallback();
|
||||
m_FadeOut.OnAnimationEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
m_FadeIn = false;
|
||||
m_FadeIn.start = false;
|
||||
m_IsEnd = true;
|
||||
m_IsInit = false;
|
||||
m_IsPause = false;
|
||||
m_FadeOut = false;
|
||||
m_FadeOuted = false;
|
||||
m_FadeOut.start = false;
|
||||
m_FadeOut.end = false;
|
||||
m_ItemCurrProgress.Clear();
|
||||
}
|
||||
|
||||
@@ -279,7 +290,7 @@ namespace XCharts.Runtime
|
||||
m_IsInit = true;
|
||||
m_TotalDetailProgress = dest - curr;
|
||||
|
||||
if (m_FadeOut)
|
||||
if (m_FadeOut.start)
|
||||
{
|
||||
m_CurrDetailProgress = dest;
|
||||
m_DestDetailProgress = curr;
|
||||
@@ -356,7 +367,7 @@ namespace XCharts.Runtime
|
||||
return true;
|
||||
if (IsIndexAnimation())
|
||||
{
|
||||
if (m_FadeOut) return m_CurrDetailProgress <= m_DestDetailProgress;
|
||||
if (m_FadeOut.start) return m_CurrDetailProgress <= m_DestDetailProgress;
|
||||
else return m_CurrDetailProgress > m_DestDetailProgress;
|
||||
}
|
||||
if (IsItemAnimation())
|
||||
@@ -366,15 +377,15 @@ namespace XCharts.Runtime
|
||||
|
||||
public bool IsInFadeOut()
|
||||
{
|
||||
return m_FadeOut;
|
||||
return m_FadeOut.start;
|
||||
}
|
||||
|
||||
public bool IsInDelay()
|
||||
{
|
||||
if (m_FadeOut)
|
||||
return (fadeOutDelay > 0 && Time.time - startTime < fadeOutDelay / 1000);
|
||||
if (m_FadeOut.start)
|
||||
return (m_FadeOut.delay > 0 && Time.time - startTime < m_FadeOut.delay / 1000);
|
||||
else
|
||||
return (fadeInDelay > 0 && Time.time - startTime < fadeInDelay / 1000);
|
||||
return (m_FadeIn.delay > 0 && Time.time - startTime < m_FadeIn.delay / 1000);
|
||||
}
|
||||
|
||||
public bool IsItemAnimation()
|
||||
@@ -391,10 +402,10 @@ namespace XCharts.Runtime
|
||||
|
||||
public float GetIndexDelay(int dataIndex)
|
||||
{
|
||||
if (m_FadeOut && fadeOutDelayFunction != null)
|
||||
return fadeOutDelayFunction(dataIndex);
|
||||
else if (m_FadeIn && fadeInDelayFunction != null)
|
||||
return fadeInDelayFunction(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;
|
||||
}
|
||||
@@ -466,10 +477,9 @@ namespace XCharts.Runtime
|
||||
if (IsInDelay())
|
||||
return;
|
||||
|
||||
m_ActualDuration = (int) ((Time.time - startTime) * 1000) - fadeInDelay;
|
||||
var duration = GetCurrAnimationDuration();
|
||||
var delta = (float) (total / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime));
|
||||
if (m_FadeOut)
|
||||
var delta = (float)(total / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime));
|
||||
if (m_FadeOut.start)
|
||||
{
|
||||
m_CurrDetailProgress -= delta;
|
||||
if (m_CurrDetailProgress <= m_DestDetailProgress)
|
||||
@@ -493,31 +503,31 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (dataIndex >= 0)
|
||||
{
|
||||
if (m_FadeOut && fadeOutDurationFunction != null)
|
||||
return fadeOutDurationFunction(dataIndex) / 1000f;
|
||||
if (m_FadeIn && fadeInDurationFunction != null)
|
||||
return fadeInDurationFunction(dataIndex) / 1000f;
|
||||
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)
|
||||
return m_FadeOutDuration > 0 ? m_FadeOutDuration / 1000 : 1f;
|
||||
if (m_FadeOut.start)
|
||||
return m_FadeOut.delay > 0 ? m_FadeOut.delay / 1000 : 1f;
|
||||
else
|
||||
return m_FadeInDuration > 0 ? m_FadeInDuration / 1000 : 1f;
|
||||
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 ? destProgress : startProgress;
|
||||
var destHig = m_FadeOut ? startProgress : destProgress;
|
||||
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_FadeOuted ? startProgress : destProgress;
|
||||
return m_FadeOut.end ? startProgress : destProgress;
|
||||
}
|
||||
else if (IsInDelay() || IsInIndexDelay(dataIndex))
|
||||
{
|
||||
return m_FadeOut ? destProgress : startProgress;
|
||||
return m_FadeOut.start ? destProgress : startProgress;
|
||||
}
|
||||
else if (m_IsPause)
|
||||
{
|
||||
@@ -527,8 +537,8 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var duration = GetCurrAnimationDuration(dataIndex);
|
||||
var delta = (destProgress - startProgress) / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
|
||||
currHig = currHig + (m_FadeOut ? -delta : delta);
|
||||
if (m_FadeOut)
|
||||
currHig = currHig + (m_FadeOut.start ? -delta : delta);
|
||||
if (m_FadeOut.start)
|
||||
{
|
||||
if ((initHig > 0 && currHig <= 0) || (initHig < 0 && currHig >= 0))
|
||||
{
|
||||
@@ -560,7 +570,7 @@ namespace XCharts.Runtime
|
||||
|
||||
var duration = GetCurrAnimationDuration();
|
||||
var delta = dest / duration * (m_UnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime);
|
||||
if (m_FadeOut)
|
||||
if (m_FadeOut.start)
|
||||
{
|
||||
m_CurrSymbolProgress -= delta;
|
||||
if (m_CurrSymbolProgress < 0)
|
||||
@@ -584,7 +594,7 @@ namespace XCharts.Runtime
|
||||
return dest;
|
||||
|
||||
if (m_IsEnd)
|
||||
return m_FadeOut ? 0 : dest;
|
||||
return m_FadeOut.start ? 0 : dest;
|
||||
|
||||
return m_CurrSymbolProgress;
|
||||
}
|
||||
@@ -617,20 +627,28 @@ namespace XCharts.Runtime
|
||||
#endif
|
||||
if (!enable || m_IsEnd)
|
||||
return -1;
|
||||
return (int) m_CurrDetailProgress;
|
||||
return (int)m_CurrDetailProgress;
|
||||
}
|
||||
|
||||
public float GetUpdateAnimationDuration()
|
||||
public float GetDataChangeDuration()
|
||||
{
|
||||
if (m_Enable && m_DataChangeEnable)
|
||||
return m_DataChangeDuration;
|
||||
if (m_Enable && m_Updated.enable)
|
||||
return m_Updated.duration;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public float GetDataAddDuration()
|
||||
{
|
||||
if (m_Enable && m_Added.enable)
|
||||
return m_Added.duration;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
public bool HasFadeOut()
|
||||
{
|
||||
return enable && m_FadeOuted && m_IsEnd;
|
||||
return enable && m_FadeOut.end && m_IsEnd;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -543,13 +543,14 @@ 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.GetUpdateAnimationDuration();
|
||||
var animationDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
|
||||
for (int i = 0; i < maxCount; i += rate)
|
||||
{
|
||||
double value = DataHelper.SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
|
||||
animationDuration, ref dataChanging, axis, unscaledTime);
|
||||
dataAddDuration, animationDuration, ref dataChanging, axis, unscaledTime);
|
||||
float pX = dataZoom.context.x + i * scaleWid;
|
||||
float dataHig = (float)((maxValue - minValue) == 0 ? 0 :
|
||||
(value - minValue) / (maxValue - minValue) * dataZoom.context.height);
|
||||
@@ -634,13 +635,14 @@ 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.GetUpdateAnimationDuration();
|
||||
var animationDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
|
||||
for (int i = 0; i < maxCount; i += rate)
|
||||
{
|
||||
double value = DataHelper.SampleValue(ref showData, serie.sampleType, rate, serie.minShow, maxCount, totalAverage, i,
|
||||
animationDuration, ref dataChanging, axis, unscaledTime);
|
||||
dataAddDuration, animationDuration, ref dataChanging, axis, unscaledTime);
|
||||
float pY = dataZoom.context.y + i * scaleWid;
|
||||
float dataHig = (maxValue - minValue) == 0 ? 0 :
|
||||
(float)((value - minValue) / (maxValue - minValue) * dataZoom.context.width);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
|
||||
public static double SampleValue(ref List<SerieData> showData, SampleType sampleType, int rate,
|
||||
int minCount, int maxCount, double totalAverage, int index, float dataChangeDuration,
|
||||
int minCount, int maxCount, double totalAverage, int index, float dataAddDuration, float dataChangeDuration,
|
||||
ref bool dataChanging, Axis axis, bool unscaledTime)
|
||||
{
|
||||
var inverse = axis.inverse;
|
||||
@@ -33,7 +33,7 @@ namespace XCharts.Runtime
|
||||
if (showData[index].IsDataChanged())
|
||||
dataChanging = true;
|
||||
|
||||
return showData[index].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
|
||||
return showData[index].GetCurrData(1, dataAddDuration, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
|
||||
}
|
||||
switch (sampleType)
|
||||
{
|
||||
@@ -44,7 +44,7 @@ namespace XCharts.Runtime
|
||||
for (int i = index; i > index - rate; i--)
|
||||
{
|
||||
count++;
|
||||
total += showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
|
||||
total += showData[i].GetCurrData(1, dataAddDuration, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
|
||||
if (showData[i].IsDataChanged())
|
||||
dataChanging = true;
|
||||
}
|
||||
@@ -57,7 +57,7 @@ namespace XCharts.Runtime
|
||||
double max = double.MinValue;
|
||||
for (int i = index; i > index - rate; i--)
|
||||
{
|
||||
var value = showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
|
||||
var value = showData[i].GetCurrData(1, dataAddDuration, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
|
||||
if (value > max)
|
||||
max = value;
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace XCharts.Runtime
|
||||
double min = double.MaxValue;
|
||||
for (int i = index; i > index - rate; i--)
|
||||
{
|
||||
var value = showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
|
||||
var value = showData[i].GetCurrData(1, dataAddDuration, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
|
||||
if (value < min)
|
||||
min = value;
|
||||
|
||||
@@ -85,7 +85,7 @@ namespace XCharts.Runtime
|
||||
total = 0;
|
||||
for (int i = index; i > index - rate; i--)
|
||||
{
|
||||
var value = showData[i].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
|
||||
var value = showData[i].GetCurrData(1, dataAddDuration, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
|
||||
total += value;
|
||||
if (value < min)
|
||||
min = value;
|
||||
@@ -104,7 +104,7 @@ namespace XCharts.Runtime
|
||||
if (showData[index].IsDataChanged())
|
||||
dataChanging = true;
|
||||
|
||||
return showData[index].GetCurrData(1, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
|
||||
return showData[index].GetCurrData(1, dataAddDuration, dataChangeDuration, inverse, minValue, maxValue, unscaledTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,7 +184,8 @@ namespace XCharts.Runtime
|
||||
showData.Count;
|
||||
var isPercentStack = SeriesHelper.IsPercentStack<Bar>(chart.series, serie.stack);
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
float dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
double yMinValue = relativedAxis.context.minValue;
|
||||
double yMaxValue = relativedAxis.context.maxValue;
|
||||
|
||||
@@ -211,7 +212,7 @@ namespace XCharts.Runtime
|
||||
var state = SerieHelper.GetSerieState(serie, serieData);
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, state);
|
||||
var value = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse);
|
||||
var relativedValue = serieData.GetCurrData(1, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue, serie.animation.unscaledTime);
|
||||
var relativedValue = serieData.GetCurrData(1, dataAddDuration, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue, serie.animation.unscaledTime);
|
||||
var borderWidth = relativedValue == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
var borderGap = relativedValue == 0 ? 0 : itemStyle.borderGap;
|
||||
var borderGapAndWidth = borderWidth + borderGap;
|
||||
@@ -236,7 +237,6 @@ namespace XCharts.Runtime
|
||||
{
|
||||
barHig = AxisHelper.GetAxisValueLength(m_SerieGrid, relativedAxis, categoryWidth, relativedValue);
|
||||
}
|
||||
|
||||
float currHig = AnimationStyleHelper.CheckDataAnimation(chart, serie, i, barHig);
|
||||
Vector3 plb, plt, prt, prb, top;
|
||||
UpdateRectPosition(m_SerieGrid, isY, relativedValue, pX, pY, gap, borderWidth, barWidth, currHig,
|
||||
|
||||
@@ -134,7 +134,8 @@ namespace XCharts.Runtime
|
||||
showData.Count;
|
||||
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
float dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
double yMinValue = relativedAxis.context.minValue;
|
||||
double yMaxValue = relativedAxis.context.maxValue;
|
||||
|
||||
@@ -161,7 +162,7 @@ namespace XCharts.Runtime
|
||||
var highlight = serieData.context.highlight || serie.highlight;
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData);
|
||||
var value = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse);
|
||||
var relativedValue = serieData.GetCurrData(1, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue, serie.animation.unscaledTime);
|
||||
var relativedValue = serieData.GetCurrData(1, dataAddDuration, dataChangeDuration, relativedAxis.inverse, yMinValue, yMaxValue, serie.animation.unscaledTime);
|
||||
var borderWidth = relativedValue == 0 ? 0 : itemStyle.runtimeBorderWidth;
|
||||
|
||||
if (!serieData.interact.TryGetColor(ref areaColor, ref areaToColor, ref interacting))
|
||||
|
||||
@@ -99,7 +99,8 @@ namespace XCharts.Runtime
|
||||
showData.Count;
|
||||
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
float dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
double yMinValue = yAxis.context.minValue;
|
||||
double yMaxValue = yAxis.context.maxValue;
|
||||
@@ -119,10 +120,10 @@ namespace XCharts.Runtime
|
||||
var state = SerieHelper.GetSerieState(serie, serieData);
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData, state);
|
||||
var startDataIndex = serieData.data.Count > 4 ? 1 : 0;
|
||||
var open = serieData.GetCurrData(startDataIndex, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var close = serieData.GetCurrData(startDataIndex + 1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var lowest = serieData.GetCurrData(startDataIndex + 2, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var heighest = serieData.GetCurrData(startDataIndex + 3, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var open = serieData.GetCurrData(startDataIndex, dataAddDuration, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var close = serieData.GetCurrData(startDataIndex + 1, dataAddDuration, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var lowest = serieData.GetCurrData(startDataIndex + 2, dataAddDuration, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var heighest = serieData.GetCurrData(startDataIndex + 3, dataAddDuration, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var isRise = yAxis.inverse ? close<open : close> open;
|
||||
var borderWidth = open == 0 ? 0f :
|
||||
(itemStyle.runtimeBorderWidth == 0 ? theme.serie.candlestickBorderWidth :
|
||||
|
||||
@@ -99,7 +99,8 @@ namespace XCharts.Runtime
|
||||
showData.Count;
|
||||
|
||||
bool dataChanging = false;
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
float dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
double yMinValue = yAxis.context.minValue;
|
||||
double yMaxValue = yAxis.context.maxValue;
|
||||
@@ -118,10 +119,10 @@ namespace XCharts.Runtime
|
||||
continue;
|
||||
}
|
||||
var startDataIndex = serieData.data.Count > 4 ? 1 : 0;
|
||||
var open = serieData.GetCurrData(startDataIndex, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var close = serieData.GetCurrData(startDataIndex + 1, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var lowest = serieData.GetCurrData(startDataIndex + 2, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var heighest = serieData.GetCurrData(startDataIndex + 3, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var open = serieData.GetCurrData(startDataIndex, dataAddDuration, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var close = serieData.GetCurrData(startDataIndex + 1, dataAddDuration, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var lowest = serieData.GetCurrData(startDataIndex + 2, dataAddDuration, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var heighest = serieData.GetCurrData(startDataIndex + 3, dataAddDuration, dataChangeDuration, yAxis.inverse, yMinValue, yMaxValue, unscaledTime);
|
||||
var isRise = yAxis.inverse ? close<open : close> open;
|
||||
var borderWidth = open == 0 ? 0f :
|
||||
(itemStyle.runtimeBorderWidth == 0 ? theme.serie.candlestickBorderWidth :
|
||||
|
||||
@@ -209,7 +209,8 @@ namespace XCharts.Runtime
|
||||
|
||||
serie.animation.InitProgress(0, xCount);
|
||||
var animationIndex = serie.animation.GetCurrIndex();
|
||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
var dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
var dataChanging = false;
|
||||
serie.containerIndex = m_SerieGrid.index;
|
||||
@@ -246,7 +247,7 @@ namespace XCharts.Runtime
|
||||
var symbol = SerieHelper.GetSerieSymbol(serie, serieData, state);
|
||||
var isRectSymbol = symbol.type == SymbolType.Rect;
|
||||
SerieHelper.GetSymbolInfo(out borderColor, out symbolBorder, out cornerRadius, serie, serieData, chart.theme, state);
|
||||
var value = serieData.GetCurrData(dimension, dataChangeDuration, yAxis.inverse,
|
||||
var value = serieData.GetCurrData(dimension, dataAddDuration, dataChangeDuration, yAxis.inverse,
|
||||
yAxis.context.minValue, yAxis.context.maxValue, unscaledTime);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
var pos = new Vector3(zeroX + (i + 0.5f) * xWidth,
|
||||
|
||||
@@ -288,7 +288,8 @@ namespace XCharts.Runtime
|
||||
serie.sampleAverage :
|
||||
DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
||||
var dataChanging = false;
|
||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
var dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
|
||||
var interacting = false;
|
||||
@@ -325,7 +326,7 @@ namespace XCharts.Runtime
|
||||
var np = Vector3.zero;
|
||||
var xValue = axis.IsCategory() ? realIndex : serieData.GetData(0, axis.inverse);
|
||||
var relativedValue = DataHelper.SampleValue(ref showData, serie.sampleType, rate, serie.minShow,
|
||||
maxCount, totalAverage, i, dataChangeDuration, ref dataChanging, relativedAxis, unscaledTime);
|
||||
maxCount, totalAverage, i, 0, dataChangeDuration, ref dataChanging, relativedAxis, unscaledTime);
|
||||
|
||||
serieData.context.stackHeight = GetDataPoint(isY, axis, relativedAxis, m_SerieGrid, xValue, relativedValue,
|
||||
i, scaleWid, isStack, ref np);
|
||||
|
||||
@@ -172,7 +172,8 @@ namespace XCharts.Runtime
|
||||
serie.sampleAverage :
|
||||
DataHelper.DataAverage(ref showData, serie.sampleType, serie.minShow, maxCount, rate);
|
||||
var dataChanging = false;
|
||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
var dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
|
||||
var interacting = false;
|
||||
@@ -200,7 +201,7 @@ namespace XCharts.Runtime
|
||||
var np = Vector3.zero;
|
||||
var xValue = axis.IsCategory() ? i : serieData.GetData(0, axis.inverse);
|
||||
var relativedValue = DataHelper.SampleValue(ref showData, serie.sampleType, rate, serie.minShow,
|
||||
maxCount, totalAverage, i, dataChangeDuration, ref dataChanging, relativedAxis, unscaledTime);
|
||||
maxCount, totalAverage, i, dataAddDuration, dataChangeDuration, ref dataChanging, relativedAxis, unscaledTime);
|
||||
|
||||
serieData.context.stackHeight = GetDataPoint(isY, axis, relativedAxis, m_SerieGrid, xValue, relativedValue,
|
||||
i, scaleWid, false, ref np);
|
||||
|
||||
@@ -176,8 +176,6 @@ namespace XCharts.Runtime
|
||||
if (sd.show && serie.pieRoseType == RoseType.Area) showdataCount++;
|
||||
sd.context.canShowLabel = false;
|
||||
}
|
||||
float dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
bool isAllZeroValue = SerieHelper.IsAllZeroValue(serie, 1);
|
||||
var dataTotalFilterMinAngle = runtimePieDataTotal;
|
||||
if (isAllZeroValue)
|
||||
@@ -195,7 +193,7 @@ namespace XCharts.Runtime
|
||||
for (int n = 0; n < data.Count; n++)
|
||||
{
|
||||
var serieData = data[n];
|
||||
var value = isAllZeroValue ? zeroReplaceValue : serieData.GetCurrData(1, dataChangeDuration, unscaledTime);
|
||||
var value = isAllZeroValue ? zeroReplaceValue : serieData.GetCurrData(1, serie.animation);
|
||||
serieData.context.startAngle = startDegree;
|
||||
serieData.context.toAngle = startDegree;
|
||||
serieData.context.halfAngle = startDegree;
|
||||
|
||||
@@ -237,8 +237,6 @@ namespace XCharts.Runtime
|
||||
var rate = serie.animation.GetCurrRate();
|
||||
var dataChanging = false;
|
||||
var interacting = false;
|
||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
SerieHelper.GetAllMinMaxData(serie, m_RadarCoord.ceilRate);
|
||||
Color32 areaColor, areaToColor;
|
||||
var startAngle = m_RadarCoord.startAngle * Mathf.PI / 180;
|
||||
@@ -265,7 +263,7 @@ namespace XCharts.Runtime
|
||||
if (n >= serieData.data.Count) break;
|
||||
var min = m_RadarCoord.GetIndicatorMin(n);
|
||||
var max = m_RadarCoord.GetIndicatorMax(n);
|
||||
var value = serieData.GetCurrData(n, dataChangeDuration, unscaledTime);
|
||||
var value = serieData.GetCurrData(n, serie.animation);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
if (max == 0)
|
||||
{
|
||||
@@ -379,8 +377,6 @@ namespace XCharts.Runtime
|
||||
|
||||
var rate = serie.animation.GetCurrRate();
|
||||
var dataChanging = false;
|
||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
var startIndex = GetStartShowIndex(serie);
|
||||
var endIndex = GetEndShowIndex(serie);
|
||||
var startAngle = m_RadarCoord.startAngle * Mathf.PI / 180;
|
||||
@@ -404,7 +400,7 @@ namespace XCharts.Runtime
|
||||
var index = serieData.index;
|
||||
var p = m_RadarCoord.context.center;
|
||||
var max = m_RadarCoord.GetIndicatorMax(index);
|
||||
var value = serieData.GetCurrData(1, dataChangeDuration, unscaledTime);
|
||||
var value = serieData.GetCurrData(1, serie.animation);
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
if (max == 0)
|
||||
{
|
||||
|
||||
@@ -100,7 +100,7 @@ namespace XCharts.Runtime
|
||||
param.color = color;
|
||||
param.marker = SerieHelper.GetItemMarker(serie, serieData, marker);
|
||||
param.itemFormatter = SerieHelper.GetItemFormatter(serie, serieData, itemFormatter);
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter);;
|
||||
param.numericFormatter = SerieHelper.GetNumericFormatter(serie, serieData, numericFormatter); ;
|
||||
param.columns.Clear();
|
||||
|
||||
param.columns.Add(param.marker);
|
||||
@@ -180,8 +180,6 @@ namespace XCharts.Runtime
|
||||
var data = serie.data;
|
||||
serie.animation.InitProgress(serie.startAngle, serie.startAngle + 360);
|
||||
SerieHelper.UpdateCenter(serie, chart.chartPosition, chart.chartWidth, chart.chartHeight);
|
||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
var ringWidth = serie.context.outsideRadius - serie.context.insideRadius;
|
||||
var dataChanging = false;
|
||||
for (int j = 0; j < data.Count; j++)
|
||||
@@ -189,16 +187,18 @@ namespace XCharts.Runtime
|
||||
var serieData = data[j];
|
||||
if (!serieData.show) continue;
|
||||
if (serieData.IsDataChanged()) dataChanging = true;
|
||||
var value = serieData.GetFirstData(unscaledTime, dataChangeDuration);
|
||||
var outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.gap);
|
||||
if (outsideRadius < 0) continue;
|
||||
var value = serieData.GetCurrData(0, serie.animation, false, false);
|
||||
var max = serieData.GetLastData();
|
||||
var degree = (float) (360 * value / max);
|
||||
var degree = (float)(360 * value / max);
|
||||
var startDegree = GetStartAngle(serie);
|
||||
var toDegree = GetToAngle(serie, degree);
|
||||
var itemStyle = SerieHelper.GetItemStyle(serie, serieData);
|
||||
var colorIndex = chart.GetLegendRealShowNameIndex(serieData.legendName);
|
||||
Color32 itemColor, itemToColor;
|
||||
SerieHelper.GetItemColor(out itemColor, out itemToColor, serie, serieData, chart.theme, colorIndex);
|
||||
var outsideRadius = serie.context.outsideRadius - j * (ringWidth + serie.gap);
|
||||
|
||||
var insideRadius = outsideRadius - ringWidth;
|
||||
var borderWidth = itemStyle.borderWidth;
|
||||
var borderColor = itemStyle.borderColor;
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace XCharts.Runtime
|
||||
serie.dataCount;
|
||||
serie.animation.InitProgress(0, 1);
|
||||
var rate = serie.animation.GetCurrRate();
|
||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
var dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
var dataChanging = false;
|
||||
var interacting = false;
|
||||
@@ -157,8 +157,8 @@ namespace XCharts.Runtime
|
||||
|
||||
SerieHelper.GetItemColor(out color, out toColor, out emptyColor, serie, serieData, chart.theme, colorIndex, state);
|
||||
SerieHelper.GetSymbolInfo(out borderColor, out symbolBorder, out cornerRadius, serie, serieData, chart.theme, state);
|
||||
double xValue = serieData.GetCurrData(0, dataChangeDuration, unscaledTime, xAxis.inverse);
|
||||
double yValue = serieData.GetCurrData(1, dataChangeDuration, unscaledTime, yAxis.inverse);
|
||||
double xValue = serieData.GetCurrData(0, 0, dataChangeDuration, unscaledTime, xAxis.inverse);
|
||||
double yValue = serieData.GetCurrData(1, 0, dataChangeDuration, unscaledTime, yAxis.inverse);
|
||||
|
||||
if (serieData.IsDataChanged())
|
||||
dataChanging = true;
|
||||
@@ -237,7 +237,7 @@ namespace XCharts.Runtime
|
||||
serie.animation.InitProgress(0, 1);
|
||||
|
||||
var rate = serie.animation.GetCurrRate();
|
||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
var dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
var dataChanging = false;
|
||||
var dataList = serie.GetDataList(xDataZoom);
|
||||
@@ -264,7 +264,7 @@ namespace XCharts.Runtime
|
||||
dataChanging = true;
|
||||
|
||||
var pos = Vector3.zero;
|
||||
var xValue = serieData.GetCurrData(0, dataChangeDuration, unscaledTime, axis.inverse);
|
||||
var xValue = serieData.GetCurrData(0, 0, dataChangeDuration, unscaledTime, axis.inverse);
|
||||
|
||||
if (axis.orient == Orient.Horizonal)
|
||||
{
|
||||
|
||||
@@ -1176,12 +1176,13 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else
|
||||
{
|
||||
var duration = animation.GetUpdateAnimationDuration();
|
||||
var duration = animation.GetDataChangeDuration();
|
||||
var dataAddDuration = animation.GetDataAddDuration();
|
||||
var unscaledTime = animation.unscaledTime;
|
||||
foreach (var sdata in data)
|
||||
{
|
||||
if (sdata.show && !IsIgnoreValue(sdata, sdata.data[1]))
|
||||
total += sdata.GetCurrData(1, duration, unscaledTime);
|
||||
total += sdata.GetCurrData(1, dataAddDuration, duration, unscaledTime);
|
||||
}
|
||||
}
|
||||
return total;
|
||||
@@ -1301,6 +1302,7 @@ namespace XCharts.Runtime
|
||||
m_Data.Insert(0, serieData);
|
||||
else
|
||||
m_Data.Add(serieData);
|
||||
serieData.OnAdd(animation);
|
||||
SetVerticesDirty();
|
||||
dataDirty = true;
|
||||
m_NeedUpdateFilterData = true;
|
||||
@@ -1535,7 +1537,7 @@ namespace XCharts.Runtime
|
||||
var serieData = GetDataList(dataZoom);
|
||||
if (index < serieData.Count)
|
||||
{
|
||||
var value = serieData[index].GetCurrData(1, animation.GetUpdateAnimationDuration(), animation.unscaledTime);
|
||||
var value = serieData[index].GetCurrData(1, 0, animation.GetDataChangeDuration(), animation.unscaledTime);
|
||||
if (showAsPositiveNumber)
|
||||
value = Math.Abs(value);
|
||||
return value;
|
||||
@@ -1697,7 +1699,7 @@ namespace XCharts.Runtime
|
||||
if (index >= 0 && index < m_Data.Count)
|
||||
{
|
||||
var animationOpen = animation.enable;
|
||||
var animationDuration = animation.GetUpdateAnimationDuration();
|
||||
var animationDuration = animation.GetDataChangeDuration();
|
||||
var unscaledTime = animation.unscaledTime;
|
||||
var flag = m_Data[index].UpdateData(dimension, value, animationOpen, unscaledTime, animationDuration);
|
||||
if (flag)
|
||||
@@ -1724,7 +1726,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
var serieData = m_Data[index];
|
||||
var animationOpen = animation.enable;
|
||||
var animationDuration = animation.GetUpdateAnimationDuration();
|
||||
var animationDuration = animation.GetDataChangeDuration();
|
||||
var unscaledTime = animation.unscaledTime;
|
||||
for (int i = 0; i < values.Count; i++)
|
||||
serieData.UpdateData(i, values[i], animationOpen, unscaledTime, animationDuration);
|
||||
|
||||
@@ -152,6 +152,8 @@ namespace XCharts.Runtime
|
||||
private List<double> m_PreviousData = new List<double>();
|
||||
private List<float> m_DataUpdateTime = new List<float>();
|
||||
private List<bool> m_DataUpdateFlag = new List<bool>();
|
||||
private List<float> m_DataAddTime = new List<float>();
|
||||
private List<bool> m_DataAddFlag = new List<bool>();
|
||||
private List<Vector2> m_PolygonPoints = new List<Vector2>();
|
||||
|
||||
public override bool vertsDirty
|
||||
@@ -222,6 +224,8 @@ namespace XCharts.Runtime
|
||||
m_PreviousData.Clear();
|
||||
m_DataUpdateTime.Clear();
|
||||
m_DataUpdateFlag.Clear();
|
||||
m_DataAddTime.Clear();
|
||||
m_DataAddFlag.Clear();
|
||||
m_Labels.Clear();
|
||||
m_LabelLines.Clear();
|
||||
m_ItemStyles.Clear();
|
||||
@@ -234,6 +238,24 @@ namespace XCharts.Runtime
|
||||
m_SelectStyles.Clear();
|
||||
}
|
||||
|
||||
public void OnAdd(AnimationStyle animation, double startValue = 0)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
return;
|
||||
#endif
|
||||
m_DataAddTime.Clear();
|
||||
m_DataAddFlag.Clear();
|
||||
if (animation.GetDataAddDuration() > 0)
|
||||
{
|
||||
for (int i = 0; i < m_Data.Count; i++)
|
||||
{
|
||||
m_DataAddTime.Add(animation.unscaledTime ? Time.unscaledTime : Time.time);
|
||||
m_DataAddFlag.Add(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("GetOrAddComponent is obsolete. Use EnsureComponent instead.")]
|
||||
public T GetOrAddComponent<T>() where T : ChildComponent, ISerieDataComponent
|
||||
{
|
||||
@@ -469,7 +491,7 @@ namespace XCharts.Runtime
|
||||
|
||||
public double GetFirstData(bool unscaledTime, float animationDuration = 500f)
|
||||
{
|
||||
if (m_Data.Count > 0) return GetCurrData(0, animationDuration, unscaledTime);
|
||||
if (m_Data.Count > 0) return GetCurrData(0, 0, animationDuration, unscaledTime);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -479,62 +501,137 @@ namespace XCharts.Runtime
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double GetCurrData(int index, float animationDuration = 500f, bool unscaledTime = false, bool inverse = false)
|
||||
public double GetCurrData(int index, AnimationStyle animation, bool inverse = false, bool loop = false)
|
||||
{
|
||||
return GetCurrData(index, animationDuration, inverse, 0, 0, unscaledTime);
|
||||
if (animation == null || !animation.enable)
|
||||
return GetData(index, inverse);
|
||||
else
|
||||
return GetCurrData(index, animation.GetDataAddDuration(), animation.GetDataChangeDuration(),
|
||||
inverse, 0, 0, animation.unscaledTime, loop);
|
||||
}
|
||||
|
||||
public double GetCurrData(int index, float animationDuration, bool inverse, double min, double max, bool unscaledTime, bool loop = false)
|
||||
public double GetCurrData(int index, AnimationStyle animation, bool inverse, double min, double max, bool loop = false)
|
||||
{
|
||||
if (index < m_DataUpdateFlag.Count && m_DataUpdateFlag[index] && animationDuration > 0)
|
||||
if (animation == null || !animation.enable)
|
||||
return GetData(index, inverse);
|
||||
else
|
||||
return GetCurrData(index, animation.GetDataAddDuration(), animation.GetDataChangeDuration(),
|
||||
inverse, min, max, animation.unscaledTime, loop);
|
||||
}
|
||||
|
||||
public double GetCurrData(int index, float dataAddDuration = 500f, float animationDuration = 500f, bool unscaledTime = false, bool inverse = false)
|
||||
{
|
||||
return GetCurrData(index, dataAddDuration, animationDuration, inverse, 0, 0, unscaledTime);
|
||||
}
|
||||
|
||||
public double GetCurrData(int index, float dataAddDuration, float animationDuration, bool inverse, double min, double max, bool unscaledTime, bool loop = false)
|
||||
{
|
||||
if (dataAddDuration > 0)
|
||||
{
|
||||
var time = (unscaledTime ? Time.unscaledTime : Time.time) - m_DataUpdateTime[index];
|
||||
if (index < m_DataAddFlag.Count && m_DataAddFlag[index])
|
||||
{
|
||||
var time = (unscaledTime ? Time.unscaledTime : Time.time) - m_DataAddTime[index];
|
||||
var total = dataAddDuration / 1000;
|
||||
|
||||
var rate = time / total;
|
||||
if (rate > 1) rate = 1;
|
||||
if (rate < 1)
|
||||
{
|
||||
var prev = min > 0 ? min : 0;
|
||||
var next = GetData(index);
|
||||
var curr = MathUtil.Lerp(prev, next, rate);
|
||||
curr = inverse ? -curr : curr;
|
||||
return curr;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < m_DataAddFlag.Count; i++)
|
||||
m_DataAddFlag[i] = false;
|
||||
return GetData(index, inverse);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (animationDuration > 0)
|
||||
{
|
||||
if (index < m_DataUpdateFlag.Count && m_DataUpdateFlag[index])
|
||||
{
|
||||
var time = (unscaledTime ? Time.unscaledTime : Time.time) - m_DataUpdateTime[index];
|
||||
var total = animationDuration / 1000;
|
||||
|
||||
var rate = time / total;
|
||||
if (rate > 1) rate = 1;
|
||||
if (rate < 1)
|
||||
{
|
||||
CheckLastData(unscaledTime);
|
||||
var prev = GetPreviousData(index);
|
||||
var next = GetData(index);
|
||||
if (loop && next <= min && prev != 0)
|
||||
{
|
||||
next = max;
|
||||
}
|
||||
var curr = MathUtil.Lerp(prev, next, rate);
|
||||
if (min != 0 || max != 0)
|
||||
{
|
||||
if (inverse)
|
||||
{
|
||||
var temp = min;
|
||||
min = -max;
|
||||
max = -temp;
|
||||
}
|
||||
var pre = m_PreviousData[index];
|
||||
if (pre < min)
|
||||
{
|
||||
m_PreviousData[index] = min;
|
||||
curr = min;
|
||||
}
|
||||
else if (pre > max)
|
||||
{
|
||||
m_PreviousData[index] = max;
|
||||
curr = max;
|
||||
}
|
||||
}
|
||||
curr = inverse ? -curr : curr;
|
||||
return curr;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < m_DataUpdateFlag.Count; i++)
|
||||
m_DataUpdateFlag[i] = false;
|
||||
return GetData(index, inverse);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetData(index, inverse);
|
||||
}
|
||||
}
|
||||
return GetData(index, inverse);
|
||||
}
|
||||
|
||||
public double GetAddAnimationData(double min, double max, float animationDuration = 500f, bool unscaledTime = false)
|
||||
{
|
||||
if (animationDuration > 0 && m_DataAddFlag.Count > 0 && m_DataAddFlag[0])
|
||||
{
|
||||
var time = (unscaledTime ? Time.unscaledTime : Time.time) - m_DataAddTime[0];
|
||||
var total = animationDuration / 1000;
|
||||
|
||||
var rate = time / total;
|
||||
if (rate > 1) rate = 1;
|
||||
if (rate < 1)
|
||||
{
|
||||
CheckLastData(unscaledTime);
|
||||
var prev = GetPreviousData(index);
|
||||
var next = GetData(index);
|
||||
if (loop)
|
||||
{
|
||||
if (next <= min && prev != 0) next = max;
|
||||
}
|
||||
var curr = MathUtil.Lerp(prev, next, rate);
|
||||
if (min != 0 || max != 0)
|
||||
{
|
||||
if (inverse)
|
||||
{
|
||||
var temp = min;
|
||||
min = -max;
|
||||
max = -temp;
|
||||
}
|
||||
var pre = m_PreviousData[index];
|
||||
if (pre < min)
|
||||
{
|
||||
m_PreviousData[index] = min;
|
||||
curr = min;
|
||||
}
|
||||
else if (pre > max)
|
||||
{
|
||||
m_PreviousData[index] = max;
|
||||
curr = max;
|
||||
}
|
||||
}
|
||||
curr = inverse ? -curr : curr;
|
||||
var curr = MathUtil.Lerp(min, max, rate);
|
||||
return curr;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_DataUpdateFlag[index] = false;
|
||||
return GetData(index, inverse);
|
||||
for (int i = 0; i < m_DataAddFlag.Count; i++)
|
||||
m_DataAddFlag[i] = false;
|
||||
return max;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetData(index, inverse);
|
||||
return max;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -600,8 +697,7 @@ namespace XCharts.Runtime
|
||||
if (dimension >= 0 && dimension < data.Count)
|
||||
{
|
||||
CheckLastData(unscaledTime);
|
||||
m_PreviousData[dimension] = GetCurrData(dimension, animationDuration, unscaledTime);
|
||||
//m_PreviousData[dimension] = data[dimension];;
|
||||
m_PreviousData[dimension] = GetCurrData(dimension, 0, animationDuration, unscaledTime);
|
||||
m_DataUpdateTime[dimension] = (unscaledTime ? Time.unscaledTime : Time.time);
|
||||
m_DataUpdateFlag[dimension] = updateAnimation;
|
||||
data[dimension] = value;
|
||||
@@ -640,6 +736,8 @@ namespace XCharts.Runtime
|
||||
{
|
||||
for (int i = 0; i < m_DataUpdateFlag.Count; i++)
|
||||
if (m_DataUpdateFlag[i]) return true;
|
||||
for (int i = 0; i < m_DataAddFlag.Count; i++)
|
||||
if (m_DataAddFlag[i]) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -401,7 +401,8 @@ namespace XCharts.Runtime
|
||||
if (!m_InitedLabel)
|
||||
return;
|
||||
|
||||
var dataChangeDuration = serie.animation.GetUpdateAnimationDuration();
|
||||
var dataChangeDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
var needCheck = serie.context.dataIndexs.Count > 0;
|
||||
foreach (var serieData in serie.data)
|
||||
@@ -432,7 +433,7 @@ namespace XCharts.Runtime
|
||||
{
|
||||
if (i >= serieData.context.dataPoints.Count) continue;
|
||||
var labelObject = serieData.context.dataLabels[i];
|
||||
var value = serieData.GetCurrData(i, dataChangeDuration, unscaledTime);
|
||||
var value = serieData.GetCurrData(i, dataAddDuration, dataChangeDuration, unscaledTime);
|
||||
var content = string.IsNullOrEmpty(currLabel.formatter) ?
|
||||
ChartCached.NumberToStr(value, currLabel.numericFormatter) :
|
||||
SerieLabelHelper.GetFormatterContent(serie, serieData, value, total,
|
||||
@@ -452,7 +453,7 @@ namespace XCharts.Runtime
|
||||
}
|
||||
else
|
||||
{
|
||||
var value = serieData.GetCurrData(defaultDimension, dataChangeDuration, unscaledTime);
|
||||
var value = serieData.GetCurrData(defaultDimension, dataAddDuration, dataChangeDuration, unscaledTime);
|
||||
var total = serie.GetDataTotal(defaultDimension, serieData);
|
||||
var color = chart.GetItemColor(serie, serieData);
|
||||
var content = string.IsNullOrEmpty(currLabel.formatter) ?
|
||||
|
||||
@@ -698,6 +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());
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
@@ -346,7 +346,8 @@ namespace XCharts.Runtime
|
||||
if ((isPolar && serie.polarIndex != axisIndex) ||
|
||||
(!isPolar && serie.yAxisIndex != axisIndex) ||
|
||||
!serie.show) continue;
|
||||
var updateDuration = serie.animation.enable ? serie.animation.dataChangeDuration : 0;
|
||||
var updateDuration = serie.animation.GetDataChangeDuration();
|
||||
var dataAddDuration = serie.animation.GetDataAddDuration();
|
||||
var unscaledTime = serie.animation.unscaledTime;
|
||||
if (isPercentStack && SeriesHelper.IsPercentStack<Bar>(series, serie.serieName))
|
||||
{
|
||||
@@ -372,7 +373,7 @@ namespace XCharts.Runtime
|
||||
foreach (var data in showData)
|
||||
{
|
||||
var currData = performanceMode ? data.GetData(yValue ? 1 : 0, inverse) :
|
||||
data.GetCurrData(yValue ? 1 : 0, updateDuration, unscaledTime, inverse);
|
||||
data.GetCurrData(yValue ? 1 : 0, dataAddDuration, updateDuration, unscaledTime, inverse);
|
||||
if (!serie.IsIgnoreValue(data, currData))
|
||||
{
|
||||
if (currData > max) max = currData;
|
||||
|
||||
Reference in New Issue
Block a user