Hello, I need to capture the selected bar at the moment a user clicks on it. Is there a way to handle this event?
The bar chart already triggers a click event when a user selects a bar, which is typically used to apply a filter.
If you have the Interaction Manager enabled, you can capture this action by listening to the filter:before-add or filter:added events. These events allow you to intercept or react to the filter generated when the user clicks on a bar, like this:
yourInteractionManager.on('filter:before-add', (e) => {
console.log(e) // <--- e has the filter data
})
1 Like
That looks good, but the problem is that i don’t have the Interaction manager in my app, only the chart
Got it, then you ca just use the click event for the Bars, like this:
myChart.on('click', event => {
console.log(event)
})
where event.data will have the clicked bar data