2021-09-23 18:14:53 +08:00
|
|
|
#define Graph_And_Chart_PRO
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using ChartAndGraph;
|
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
|
|
public class RowerGraphChartFeed : MonoBehaviour
|
|
|
|
|
{
|
2022-05-31 14:43:05 +08:00
|
|
|
GraphChartBase graph { get; set; }
|
|
|
|
|
|
|
|
|
|
void Start ()
|
2021-09-23 18:14:53 +08:00
|
|
|
{
|
2022-05-31 14:43:05 +08:00
|
|
|
graph = GetComponent<GraphChartBase>();
|
2021-09-23 18:14:53 +08:00
|
|
|
//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");
|
2022-05-31 14:43:05 +08:00
|
|
|
|
2021-09-23 18:14:53 +08:00
|
|
|
// 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();
|
|
|
|
|
//}
|
2022-05-31 14:43:05 +08:00
|
|
|
// StartCoroutine(ClearAll());
|
2021-09-23 18:14:53 +08:00
|
|
|
}
|
|
|
|
|
|
2022-04-27 20:03:56 +08:00
|
|
|
public void SetData(List<DoubleVector2> list,List<DoubleVector2> list2 = null)
|
2021-09-23 18:14:53 +08:00
|
|
|
{
|
|
|
|
|
if (graph != null)
|
|
|
|
|
{
|
|
|
|
|
graph.Scrollable = false;
|
|
|
|
|
//graph.HorizontalValueToStringMap[0.0] = "Zero"; // example of how to set custom axis strings
|
2022-05-31 14:43:05 +08:00
|
|
|
//graph.DataSource.StartBatch();
|
2021-09-29 11:06:05 +08:00
|
|
|
graph.DataSource.ClearCategory("Player 1");
|
2022-04-27 20:03:56 +08:00
|
|
|
graph.DataSource.ClearCategory("Player 2");
|
2021-09-23 18:14:53 +08:00
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var item = list[i];
|
2022-05-31 14:43:05 +08:00
|
|
|
graph.DataSource.AddPointToCategoryRealtime("Player 2", item.x, item.y);
|
2021-09-29 11:06:05 +08:00
|
|
|
//if (i == 0)
|
|
|
|
|
// graph.DataSource.SetCurveInitialPoint("Player 1", item.x, item.y);
|
|
|
|
|
//else
|
|
|
|
|
// graph.DataSource.AddLinearCurveToCategory("Player 1", new DoubleVector2(item.x, item.y));
|
2021-09-23 18:14:53 +08:00
|
|
|
}
|
2022-04-27 20:03:56 +08:00
|
|
|
if (list2 != null)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < list2.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
var item = list2[i];
|
2022-05-31 14:43:05 +08:00
|
|
|
graph.DataSource.AddPointToCategoryRealtime("Player 1", item.x, item.y);
|
2022-04-27 20:03:56 +08:00
|
|
|
}
|
|
|
|
|
}
|
2021-09-29 11:06:05 +08:00
|
|
|
//graph.DataSource.MakeCurveCategorySmooth("Player 1");
|
2022-05-31 14:43:05 +08:00
|
|
|
//graph.DataSource.EndBatch();
|
2021-09-23 18:14:53 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
IEnumerator ClearAll()
|
|
|
|
|
{
|
|
|
|
|
yield return new WaitForSeconds(5f);
|
|
|
|
|
GraphChartBase graph = GetComponent<GraphChartBase>();
|
|
|
|
|
|
|
|
|
|
graph.DataSource.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|