In version 1.13.0 we have added two scripts StackGraphManager.cs and StackedGraphExample.cs. They can be found in Tutorials/StackedGraph along with an example scene showing how to use them.
StackGraphManager.cs allows you to create stacked graphs and stream data to them. Also allowing to show /hide categories (changing their stacking).
You can use StackGraphManager by doing the following:
- Set up your categories (either by script or by inspector)
- Call the InitialData method , if there is some initial data to add. You can also call it with an empty array if you wish to clear the data
- Call AddPointRealtime to add new stacked points to the stacked chart
- Call SetCategoryEnabled/ToggleCategoryEnabled to show/hide categories
//setting up initial data
for(int i=0; i< yArr.GetLength(0); i++)
for(int j=0; j<yArr.GetLength(1); j++)
{
yArr[i,j] = Random.value * 3;
}
manager.InitialData(xArr, yArr);
//adding realtime point
for (int i = 0; i < newPointYArr.Length; i++)
newPointYArr[i] = Random.value * 3;
manager.AddPointRealtime(x, newPointYArr, 1f);
//show/hide category
manager.ToggleCategoryEnabled(categoryName);
\manager.SetCategoryEnabled(“Player 1”, isEnabled);