#define Graph_And_Chart_PRO using UnityEngine; using ChartAndGraph; using System.Collections; using System.Collections.Generic; public class RowerGraphChartFeed : MonoBehaviour { GraphChartBase graph { get; set; } void Start () { graph = GetComponent(); //GraphChartBase graph = GetComponent(); //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 list,List list2 = null) { 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.ClearCategory("Player 2"); for (int i = 0; i < list.Count; i++) { var item = list[i]; graph.DataSource.AddPointToCategoryRealtime("Player 2", item.x, item.y); //if (i == 0) // graph.DataSource.SetCurveInitialPoint("Player 1", item.x, item.y); //else // graph.DataSource.AddLinearCurveToCategory("Player 1", new DoubleVector2(item.x, item.y)); } if (list2 != null) { for (int i = 0; i < list2.Count; i++) { var item = list2[i]; graph.DataSource.AddPointToCategoryRealtime("Player 1", item.x, item.y); } } //graph.DataSource.MakeCurveCategorySmooth("Player 1"); //graph.DataSource.EndBatch(); } } IEnumerator ClearAll() { yield return new WaitForSeconds(5f); GraphChartBase graph = GetComponent(); graph.DataSource.Clear(); } }