powerfun-unity/Assets/Scripts/UI/Prefab/Rower/RowerGraphChartFeed.cs
2021-09-28 11:27:24 +08:00

64 lines
2.4 KiB
C#

#define Graph_And_Chart_PRO
using UnityEngine;
using ChartAndGraph;
using System.Collections;
using System.Collections.Generic;
public class RowerGraphChartFeed : MonoBehaviour
{
void Start ()
{
//GraphChartBase graph = GetComponent<GraphChartBase>();
//if (graph != null)
//{
// graph.Scrollable = false;
// graph.HorizontalValueToStringMap[0.0] = "Zero"; // example of how to set custom axis strings
// graph.DataSource.StartBatch();
// graph.DataSource.ClearCategory("Player 1");
// graph.DataSource.ClearAndMakeBezierCurve("Player 2");
// for (int i = 0; i <10000; i++)
// {
// graph.DataSource.AddPointToCategory("Player 1",i*5,Random.value*10f + 20f);
// if (i == 0)
// graph.DataSource.SetCurveInitialPoint("Player 2",i*5, Random.value * 10f + 10f);
// else
// graph.DataSource.AddLinearCurveToCategory("Player 2",
// new DoubleVector2(i*5 , Random.value * 10f + 10f));
// }
// graph.DataSource.MakeCurveCategorySmooth("Player 2");
// graph.DataSource.EndBatch();
//}
// StartCoroutine(ClearAll());
}
public void SetData(List<DoubleVector2> list)
{
GraphChartBase graph = GetComponent<GraphChartBase>();
if (graph != null)
{
graph.Scrollable = false;
//graph.HorizontalValueToStringMap[0.0] = "Zero"; // example of how to set custom axis strings
graph.DataSource.StartBatch();
graph.DataSource.ClearAndMakeBezierCurve("Player 1");
for (int i = 0; i < list.Count; i++)
{
var item = list[i];
if (i == 0)
graph.DataSource.SetCurveInitialPoint("Player 1", item.x, item.y);
else
graph.DataSource.AddLinearCurveToCategory("Player 1", new DoubleVector2(item.x, item.y));
}
graph.DataSource.MakeCurveCategorySmooth("Player 1");
graph.DataSource.EndBatch();
}
}
IEnumerator ClearAll()
{
yield return new WaitForSeconds(5f);
GraphChartBase graph = GetComponent<GraphChartBase>();
graph.DataSource.Clear();
}
}