This article is about adding , removing,and changing the visual features of categories from script. If you want to lean how to fill categories with data , see Filling the candle chart with data
Like any feature of graph and chart, The candle categories are completely configurable from script as well. You may want to take a look at Obtaining a chart object for scripting before proceeding with this article.
Also , you may want to look at Category Settings for a quick overview of the visual properties of graph categories
How to load material and Prefabs into your script
in order to configure a category you may need to pass materials and prefabs as parameters in your script. You can obtain these parameters in the very same way you would with any unity resources. Check out these two links for more information :
Candle chart settings object
Some of the methods in the following sections require that you pass a CandleSettings parameter. This is a type that holds all the settings you can find in Category Settings .
The candle settings object can be set public in a monobehavior and edited in the inspector. It can also be populated with values in code. For example:
CandleChartData.CandleSettings candle = new CandleChartData.CandleSettings();
candle.CandleHoverPrefab = prefab;
candle.Fill = fillMaterial;
candle.LineThickness = 1.0;
ADDING AND REMOVING CATEGORIES
You can add a category in the following way:
CandleChartData.CandleSettings upCandle, downCandle;
candle.DataSource.AddCategory("newCategory", upCandle, downCandle, 0.0);
You can remove a category in the following way:
candle.DataSource.RemoveCategory("oldCategory");
SETTING CATEGORY STYLES FROM SCRIPT
You can set the styles of categories from script in the following way:
CandleChartData.CandleSettings upCandle, downCandle;
candle.DataSource.SetUpCandle("category",upCandle);
candle.DataSource.SetDownCandle("category",downCandle);
RENAMING A CATEGORY
You can rename a category in the following way , make sure the new name does not exist in the chart
candle.DataSource.RenameCategory("prevName", "newName");
REMOVING ALL THE CATEGORIES FROM THE Candle CHART
candle.DataSource.Clear();
CHECKING IF A CATEGORY EXISTS IN A Candle CHART
if(candle.DataSource.HasCategory("categoryName"))
{
}