Home > front end >  collapses the tree on the click of parent node - d3.js and Javascript
collapses the tree on the click of parent node - d3.js and Javascript

Time:09-12

I'm trying to use this Example for creating the organization chart. >> d3.js v3 (old version)

currently, it seems all are in a working state

the click on the circle " " button child nodes collapses, all good

but I want to make it happen like when the user tries to click on any place within the entire parent node, then also the child node group get collapses

EDIT: So either with " " button or on click at any place on a parent node

Any help would be great!

CodePudding user response:

There are two children for each node in your chart; the first one is contents (img, title and etc) and the second one is the collapse button. To accomplish your task, you can modify the <rect> tag inside the second <g data-id="x"> tag. Here's the code you need to replace with your own.

<rect  height="80" fill="transparent" x="0" y="0" width="210" style="
"></rect>
  • Related