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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:31:35+00:00 2026-06-18T05:31:35+00:00

On certain occasions I have been able to bind my data to a parent

  • 0

On certain occasions I have been able to bind my data to a parent element (say, the <svg> container), then append child <path> elements, and then update their d attributes with the data. Other times, it seems I can’t do this.

For example, in my code I have

var svg = d3.select(this).selectAll("svg").data([allSeries]);

where allSeries is a 3-element array of my three time series data. I then add a path for each element.

var gEnter = svg.enter().append("svg").append("g");
for (var i = allSeries.length - 1; i >= 0; i--) {
  gEnter.append("path").attr("class", "line").style("opacity", 0);
};

Later, when it’s time to add/update the data, I tried this

g.selectAll(".line")
   .attr("d", function(d) { return line(d.values); })

but it didn’t work. This, however, does work

g.selectAll(".line")
   .data(allSeries)
   .attr("d", function(d) { return line(d.values); })

So how can I get my .line elements to read the data from svg?

  • 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-18T05:31:37+00:00Added an answer on June 18, 2026 at 5:31 am

    The nested group needs to declare it’s data source as the identity function in order to have access to the child elements of the parent group:

    g.selectAll(".line")
       .data(function(d) {return d;})
       .attr("d", function(d) { return line(d.values); })
    

    This is better explained in the documentation of the selection.data() function here: https://github.com/mbostock/d3/wiki/Selections#wiki-data

    For example, you may bind a two-dimensional array to an initial selection, and then bind the contained inner arrays to each subselection. The values function in this case is the identity function: it is invoked for each group of child elements, being passed the data bound to the parent element, and returns this array of data.

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

Sidebar

Related Questions

I’m fairly new at C# and MVC and have used lambdas on certain occasions,
If this is in the apple doc then I've not been able to find
I'm using PHP to data scrape another website. However, on certain occasions I need
I have a div, it will be a certain fixed height. Say 500px. Generally
I have a sub that updates a form on certain occasions. Sometimes I need
I am using MVC3 and unobstrusive validation. On certain occasions I want to submit
I have been reading through this similar question and find myself less than satisfied
I've been using StackOverflow since the beginning, and have on occasion been tempted to
On certain occasions, when several back-end process happen to run at the same time
I am looping through a set of values $id and on certain occasions I

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.