增加数据更新动画

This commit is contained in:
monitor1394
2019-12-03 07:49:37 +08:00
parent ab057cb623
commit 74b304a72d
15 changed files with 263 additions and 50 deletions

View File

@@ -15,23 +15,33 @@ namespace XCharts
public class Demo_Test : MonoBehaviour
{
private float updateTime = 0;
CoordinateChart chart;
BaseChart chart;
void Awake()
{
chart = gameObject.GetComponent<CoordinateChart>();
if (chart == null)
{
chart = gameObject.AddComponent<CoordinateChart>();
}
chart = gameObject.GetComponent<BaseChart>();
}
void Update()
{
updateTime += Time.deltaTime;
if (updateTime > 2)
if (chart && updateTime > 2)
{
updateTime = 0;
chart.UpdateData(0, Random.Range(0, 5), Random.Range(10, 90));
var serie = chart.series.GetSerie(0);
serie.animation.updateAnimation = true;
var dataCount = serie.dataCount;
if (chart is HeatmapChart)
{
var dimension = serie.GetSerieData(0).data.Count - 1;
for (int i = 0; i < dataCount; i++)
{
chart.UpdateData(0, i, dimension, Random.Range(0, 10));
}
}
else
{
chart.UpdateData(0, Random.Range(0, dataCount), Random.Range(10, 90));
}
}
}
}