title: d3 mouse event, add circles on click
body: <p>I need to add in my code that when I click it, more circles and of different radius are added, I have been stuck up to this point</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function dragstarted(event, d) {
    d3.select(this).raise().attr("stroke", "black");
  }
  
  function dragged(event, d) {
    d3.select(this).attr("cx", d.x = event.x).attr("cy", d.y = event.y);
  }
  
  function dragended(event, d) {
    d3.select(this).attr("stroke", null);
  }
  
  const drag = d3.drag()
    .on("start", dragstarted)
    .on("drag", dragged)
    .on("end", dragended);
  
  const height = 300,
    width = 700
  radius = 20
  
  const svg = d3.select("svg")
    .attr("viewBox", [0, 0, width, height])
    .attr("stroke-width", 2);
  
  const circles = d3.range(10).map(i =&gt; ({
    x: Math.random() * (width - radius * 1) + radius,
    y: Math.random() * (height - radius * 1) + radius,
  }));
  
  svg.selectAll("circle")
    .data(circles)
    .join("circle")
    .attr("cx", d =&gt; d.x)
    .attr("cy", d =&gt; d.y)
    .attr("r", radius)
    .attr("fill", (d, i) =&gt; d3.schemePastel1[i % 100])
    .call(drag);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/d3/6.2.0/d3.min.js"&gt;&lt;/script&gt;
  &lt;svg&gt;&lt;/svg&gt;</code></pre>
  </div>
  </div>
  </p>
  <p>I need to create something like that, that can move the circles and add more circles by clicking</p>
  <p><a href="https://i.stack.imgur.com/jfcl2.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jfcl2.gif" alt="enter image description here" /></a></p>