In this article you will learn how to handle click events on the chart. The resulting scene can be found in “Extras/Tutorials/Event Handling”
Adding an event interaction to the chart
Go to the interactions folder and drag the event interaction prefab into the interaction object of the chart
CReate a New Script and name it TUTorialEventHandler
public class TutorialEventHandler : MonoBehaviour
{
public CanvasEventInteraction Interaction; // this interaction is set from the inspector
void Start()
{
Interaction.ClickEvent.AddListener(OnClick); // hook the interaction click event
}
void OnClick(ChartClickEventArgs click)
{
Debug.Log(click.Category + "," + click.Index); // display the parameters of the click event
Debug.Log(click.FormattedString);
}
// Update is called once per frame
void Update()
{
}
}