5

After joning data with my group I would like the elements in the enter selection to be added to a group (g-element) on top/highest up. Default is to append to the bottom.

The reason for this is that I want the object to visually appear below the all ready visible objects.

I know I can order and sort but I thought there might be an easier/better way to do this. I have done several manual things only to later find out "Oooh, they included a smart way to do that, EASILY."

GusOst
  • 4,105
  • 3
  • 19
  • 28

2 Answers2

14

D3 does have an insert method: https://github.com/mbostock/d3/wiki/Selections#wiki-insert

Nick Briggs
  • 166
  • 1
  • 3
13

Excerpt from Reference

For instance, insert("div", ":first-child") will prepend child div nodes to the current selection.

https://github.com/mbostock/d3/wiki/Selections#wiki-insert

Community
  • 1
  • 1
n1nj4
  • 511
  • 5
  • 13