'how to change event on legend click in amcharts 5?

the same problem solve is here https://www.amcharts.com/docs/v4/tutorials/activate-deactivate-a-pie-slice-on-legend-click-instead-of-toggling/ , I need to have the same effect but it doesnt work in version 5



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source