Forum Discussion

az2451's avatar
az2451
Icon for Resolver I rankResolver I
8 years ago
Solved

How to replace/remove SVG-Elements by using EventListener

  Hi there,   im trying to figure out how to replace/remove svg-elements instead of creating new ones while using an eventListener.   when i move the slider handle to the right, it also moves th...
  • v-viig's avatar
    8 years ago

    At first , "this.absline.parent" is not correct. It seems you should use something like this:

     

    d3.select(this.absline.parent).selectAll("*").remove();

     

    We would also recommend not to remove/create an element for each event as adding/removing elements from DOM is a very expensive operation.

    It'd be better to keep a single element and change its position for each event.

     

    Ignat Vilesov,

    Software Engineer

     

    Microsoft Power BI Custom Visuals

    [email protected]