Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8410971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:19:08+00:00 2026-06-10T00:19:08+00:00

I’m wanting to do something in D3 that’s very similar to what this guy

  • 0

I’m wanting to do something in D3 that’s very similar to what this guy is trying to do:

Can enter() selection be reused after append/insert?

I have multiple (rows and) columns of data, and for every piece of data I need to bind it to several elements. The answer to the question I linked to above explains how this works with enter selections, but what about with update selections?

Basically, I need to know how that’s supposed to work with setting the attributes in the update selection and knowing which piece of data is currently having its attributes set, etc. I can’t find examples or documentation for this anywhere.

EDIT: Alright, I generally got it working. However, there’s still one fundamental problem left: even though the data array that I’m passing in to the "data" function call is correct, the values passed to the "update" selection are incorrect.

I debugged it a little bit, and I think I know what’s going on: the wrong data is getting removed in the exit selection. How do I fix this – in other words, how do I make sure that the old data is removed and the data that’s repeated in my new "data" function call remains intact?

Just to clarify, let’s say this is the data that I pass in (to the "data" function call):

1, 2, 3
4, 5, 6

then let’s say I pass in this the next time around:

4, 5, 6

for some reason, this is the resulting data:

1, 2, 3

etc. How can I fix this, or is this not supposed to happen and is it only happening because I’m doing something wrong?

Also, in case it helps, if I select all "g" elements and remove them before I call the "data" function:

svg.selectAll("g").remove();

svg.selectAll("g").data(data);

then I don’t experience this problem. Obviously, this is not an elegant solution though.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:19:09+00:00Added an answer on June 10, 2026 at 12:19 am

    Continuing the example code from question you linked, you need to re-select the added lines:

    var g = svg.selectAll(".foo")
        .data([123, 456]);
    
    var gEnter = g.enter().append("g")
        .attr("class", "foo");
    
    gEnter.append("line"); // line1
    gEnter.append("line"); // line2
    
    var line = g.selectAll("line"); // line1 and line2
    

    (If you want to modify line1 or line2 separately, assign them separate classes or identifying attributes.)

    Conceptually, the parent G elements have an enter, update and exit selection as a result of the data-join. If you append child elements to the entering G’s, you’ll need to reselect them to create the merged enter+update selection of the children.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
For some reason, after submitting a string like this Jack’s Spindle from a text
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.