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 8890469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:30:33+00:00 2026-06-14T22:30:33+00:00

In this code, http://enjalot.com/inlet/4124664/ of which the main part is: function render(data) { var

  • 0

In this code, http://enjalot.com/inlet/4124664/

of which the main part is:

    function render(data) {

        var nodz = svg.selectAll(".node")
            .data(data);

        nodz.enter().append("g")
            .attr("class", "node")
            .attr("id", function(d) { return "id"+d[0]+d[1]; })
            .attr("x",0)
            .attr("y", 0)
            .attr("transform", function(d) {
                return "translate(" + x(d[0]) + "," + y(d[1]) + ")";
            })
            .append("text")
            .attr("x", 0)
            .attr("y", 0)
            .attr("stroke", "black")
            .text(function(d) {return d[2]; });


        // update
        nodz.selectAll("text")
            .text(function(d) {
                return d[2]; });

        // another go
        d3.selectAll("text")
            .text(function(d) {
                return d[2]; });


     }


    // data in form [x pos, y pos, value to display]

    var nodes = [[0,0,0],[1,1,0],[1, -1,0],[2,0,0], [2,2,0]];
    render(nodes);

    nodes2 = [[0,0,1],[1,1,1],[1, -1,1],[2,0,1], [2,2,1], [2, -2,1]];
    render(nodes2);

I call the code to draw some nodes twice.

I expect it to draw five nodes with a value of zero in the first pass,

Then I add another item to the list and update all the values to 1 so expect to see all the values change to 1 and a new node appear. Instead, I’m only seeing the last one being set to 1. I’ve tried adding a unique id to bind the node to the data but this isn’t working. Also tried reselecting to see if the data is now bound. In all the tutorials I’ve been through, just calling the selectAll().data() part updates the data, what am I missing?

  • 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-14T22:30:34+00:00Added an answer on June 14, 2026 at 10:30 pm

    The second optional argument to .data() is a function that tells d3 how to match elements. That’s where you need to compare your IDs, see the documentation. That said, it should work without IDs in your case as it matches by index by default.

    The problem with updating the text is that after calling .selectAll() you need to call .data() again to let d3 know what you want to match to that selection (i.e. that the new data should be bound to the old data).

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

Sidebar

Related Questions

I'm trying to modify this code ( http://code.google.com/p/pypng/source/browse/trunk/code/texttopng ) so that it can render
I have simple front controller plugin which contains this code: http://pastebin.com/m155c59b0 When session expire
I came across this code http://support.microsoft.com/kb/320348 which made me wonder what would be the
I use this code: http://blogswizards.com/plugin-development/sliding-boxes-and-captions-with-jquery On a simple gallery site I am building. Specifically
I had tested this code: http://support.microsoft.com/kb/316383 It works, but a Word application is opened
I have this code: http://pastebin.com/Sd9WKZFr When i call something like rate(60, -6000, 120000) it
I've been using MassTransit for handling e-mail messages. Using this code: http://meandaspnet.blogspot.com/2009/10/how-to-binary-serialize-mailmessage-for.html I'm able
This code comes from: http://code.activestate.com/recipes/577090-file-encryption-using-stream-cipher/ import sys import random if len(sys.argv) != 4: print
I have used this code (kind of tutorial) at http://code.google.com/p/gwt-examples/wiki/gwt_hmtl5 ... In this code,
I'm working on a picture select/crop program and using this code below: http://www.androidworks.com/crop_large_photos_with_android/comment-page-1#comment-969 As

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.