r/d3js • u/arjUnaRe • Jul 27 '19
axisBottam() for xaxis
Onresize by changing width I'm implementing responsive charts
But axisBottam crating multiple DOM / same lines printing again and again.
I need only one occurrence of xaxis
How to remove DOM
Please help
0
Upvotes
1
u/christinaAquafina Jul 27 '19
To remove the axis select the group you appended it to and call the remove method for all the group's nodes:
d3.select(/group class/).selectAll('*').remove();
Then you can append a new axis to the empty group.
If you have altered the X scale's range then you can just called the X axis function again and it'll use the newly updated scale.