bumbeishvili / org-chart

Highly customizable org chart. Integrations available for Angular, React, Vue
https://stackblitz.com/edit/web-platform-o5t1ha
MIT License
928 stars 330 forks source link

Linked line color/styles with React #297

Closed scottrepreneur closed 1 year ago

scottrepreneur commented 1 year ago

I'm having trouble setting a non-default color for the linked lines. Trying to follow the README instructions:

.linkUpdate((d, i, arr) => {
  d3.select(this).attr('stroke', 'red');
  // d3.select(this).attr('stroke-width', 2);
})

Here's a forked js sandbox. https://stackblitz.com/edit/d3-org-chart-react-integration-hooks-shjp76?file=OrgChart.js

Getting an error on run/build:

this.setAttribute is not a function

Is there another way to accomplish this with the react instantiation?

bumbeishvili commented 1 year ago

You are using the arrow function and this does not refer to the correct object. Pass a function callback instead