NVD3, Clear svg before loading new chart

前端 未结 6 985
無奈伤痛
無奈伤痛 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:39

    If you are developing a dashboard having multiple widget showing different d3 charts then use the following

    d3.selectAll("#d3-donutChart > *").remove(); 
    

    this will only clear the specific chart, not all the svg's in the webpage.

    Add this line just after subscribing to data in angular 2.

提交回复
热议问题