d3 / d3-selection

Transform the DOM by selecting elements and joining to data.

Home Page:https://d3js.org/d3-selection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

selection merge error: is not a function

amandaXCY opened this issue · comments

D3 version is : "d3": "^5.9.1"
this my code,run error: u.enter(...).append(...).merge is not a function

var myData = ["A", "B", "C", "D", "E"];

var u = d3
  .select("body")
  .selectAll("div")
  .data(myData);

u.exit().remove(); // EXIT
u.enter()
  .append("div")
  .merge(u)
  .text(function(d) {
    return d;
  });

I’m unable to reproduce this issue. Here is a working version:

https://observablehq.com/d/8c213b6894b3b087

Also, I highly recommend the new selection.join. I’ve adapted your code to use selection.join in the linked notebook.