Getting the click event in d3 v6.1.1

how to get click event for the d3 v6.0
For the Bar chart I am getting error to correct the function

I had the issue like this too.

It can be solve either to change it to d3 v5 or do the migration to v6. You can check my post here

I hope it can help you.