增加数据更新动画

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

View File

@@ -0,0 +1,52 @@
/******************************************/
/* */
/* Copyright (c) 2018 monitor1394 */
/* https://github.com/monitor1394 */
/* */
/******************************************/
using UnityEngine;
namespace XCharts
{
[DisallowMultipleComponent]
[ExecuteInEditMode]
public class Demo01_UpdateData : MonoBehaviour
{
private float updateTime = 0;
BaseChart chart;
void Awake()
{
chart = gameObject.GetComponent<BaseChart>();
}
void Update()
{
updateTime += Time.deltaTime;
if (chart && updateTime > 2)
{
updateTime = 0;
var serie = chart.series.GetSerie(0);
//serie.animation.updateAnimation = true;
var dataCount = serie.dataCount;
if (chart is RadarChart)
{
var dimension = serie.GetSerieData(0).data.Count - 1;
chart.UpdateData(0, 0, Random.Range(0, dimension + 1), Random.Range(0, 100));
}
else 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));
}
}
}
}
}

View File

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

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));
}
}
}
}