in this tutorial you will learn how to quickly setup a chart and add data to it.
The scene created in this tutorial can be found in “Extras/ExampleScenes/QuickStart”.
1. Go To Tools/Graph and Chart menu and click on “Add Data Series Chart”
Apply a margin to the newly created object:
2. Create a new Script and name it “DataLoader”
Copy the following code into the script file
using DataVisualizer;
using UnityEngine;
public class DataLoader : MonoBehaviour
{
public DataSeriesChart chart; // the chart object
// Start is called before the first frame update
void Start()
{
var category = chart.DataSource.GetCategory("dataseries-1").Data; // obtain category data
category.Append(0.0, 0.0); // call append to add a new point to the graph
category.Append(100.0, 2.0);
category.Append(200.0, 1.0);
category.Append(300.0, 5.0);
category.Append(500.0, 2.0);
}
}
3. Create a new game object and name it “DataLoaderObject”
Add a data loader component to the newly created object
drag “DataSeriesChart” into the chart field of the data loader component