Add export button of frappe chart in erpnext script report

I have a script report with frappe chart,


Now, I would like to add an export button to enable downloading the chart.
I found how to do it in this page Exporting to images
but I can not add this code “chart.export();” in the js

I want the same any update on this ?