Handling the click event
One important thing about charts is that they allow interaction. CCC provides a way to handle some events in the chart and click is one of those events. To have it working, we need to change two properties: clickable
, which needs to be set to true, and clickAction
where we need to write a function with the code to be executed when a click happens. The function receives one argument that usually is referred to as a scene. The scene is an object that has a lot of information about the context where the event happened. From the object you will have access to vars
, another object where we can find the series
and the categories
where the click happened.
We can use the function to get the series/categories being clicked and perform a fireChange
that can trigger updates on other components:
function(scene) { var series = "Series:"+scene.atoms.series.label; var category = "Category:"+scene.vars.category.label; var value = "Value:"+scene.vars.value.label; ...