ASP
ASP

Reputation: 131

Clear single svg before loading new graph

I have added multiple graphs on a single JSP page hence this JSP page contains multiple svg elements.

Here is code structure:

<div class="col-md-12 col-sm-9 col-xs-12">
  <div id="placeholder33" style="height: 160px; display: none" class="demo-placeholder">
    <div style="width: 100%;">
        <div id="canvas_dahs3" class="demo-placeholder" style="width: 100%; height:270px;">
           <svg></svg>
        </div>
    </div>
  </div>
</div>

When I am trying to clear only one svg element to load new graph using.

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

It removes all svg elements. How can I clear only one svg so that other graphs remains same.

Upvotes: 0

Views: 64

Answers (1)

fafl
fafl

Reputation: 7387

Can you not use an ID?

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

Upvotes: 1

Related Questions