Trying to generate Collapsible Tree Structure

HI team,
I am a BI Developer and i am new to Javascript.
I have a requirement to create Collapsible Tree Structure in BI tool called Yellowfin BI.
I am referencing to d3 charts.
I have a script which is working when i run using .html but i couldnt able to generate the script in the BI tool.
Can any one help me out this?
Here is the link i am referencing to.

looking forward for your reply.

Thanks
Chandana