NVD3, Clear svg before loading new chart

前端 未结 6 987
無奈伤痛
無奈伤痛 2020-12-15 14:55

I have several different NVD3 charts that I call upon in the same svg. I use buttons to call functions, each containing a new chart that uses its own data.

6条回答
  •  执笔经年
    2020-12-15 15:22

    You can select all the elements below the SVG with the "svg > *" selector, i.e. to remove all of those, do

    d3.selectAll("svg > *").remove();
    

提交回复
热议问题