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

is there a way to update the svg width without calling render()? #427

Closed kanth609 closed 3 months ago

kanth609 commented 3 months ago

Hello :), so basically, i'm trying to update the svg width dynamically using svgWidth(<value>) but i have to call the render() function to update width in the DOM, as i'm loosing the added classes when the render() is called. So checking here if is there a way to update the svg width without calling render()?

bumbeishvili commented 3 months ago

svg is exposed through the state, so in theory, you could do

chart.svgWidth(300);
chart.getState().svg.attr('width,300)

But something feels wrong with this approach

kanth609 commented 3 months ago

thanks @bumbeishvili , can you pls let me know why do you feel it is wrong, so that i can find the different approach to update the width of svg. thanks!

bumbeishvili commented 3 months ago

thanks @bumbeishvili , can you pls let me know why do you feel it is wrong, so that i can find the different approach to update the width of svg. thanks!

Because render should be working normally and you should not be losing anything?

kanth609 commented 3 months ago

yeah you're ryt, as i'm applying some styles to the selected node and if i call the render(), it is getting removed also if nodes are huge, i don't wanna re-render the chart. so thinking to go ahead with the approach which you suggested above. :)