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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:34:29+00:00 2026-06-04T18:34:29+00:00

In trying to make multiple svg elements using D3.js, I am using the following

  • 0

In trying to make multiple svg elements using D3.js, I am using the following code which works given this data format:

// Data that works:
    var data= [
        {x:1, y:2, z:5}, 
        {x:3, y:5, z:10}, 
        {x:8, y:9, z:11}
    ]

// Make svg elements
    var svg = d3.select('body').selectAll('svg')
              .data(data)
              .enter().append('svg')
              .style('display', 'inline-block')
              .style('width', width)
              .style('height', height)
              .append('svg:svg')

However, when my data is nested, no svg elements appear on the DOM:

var data = {
    x: {
        val1: 10,
        val2: 20
       },
    y: {
        val1: 15,
        val2: 14
       },
   z: {
        val1: 10,
        val2: 20
       }
}

I would like to create svg elements which correspond to each child object of data (x, y, and z). It seems like they automatically get created for each object in first representation of the data. How I can achieve this given the second data structure?

  • 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-04T18:34:31+00:00Added an answer on June 4, 2026 at 6:34 pm

    The .data() function expects a normal array, so just an object/associative array won’t work. Have a look at the d3.entries function, which will convert it to a normal array.

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

Sidebar

Related Questions

I am trying to make this function that extracts text from html for multiple
Im trying to make multiple quizes that will keep track of each quiz on
I am trying to make a multiple page application using winforms. I decied to
I'm trying to make a Procedure that will duplicate multiple rows of a table
I'm trying to make a search feature that will search multiple columns to find
I'm trying to make a MATCH of columns using multiple criteria, as in the
With RavenDB, using Fiddler2, I'm trying to make a request to get multiple documents
i'm trying to make a small project that uses multiple forms (dialogs) for different
I'm trying to make an application in cocos2d that can be used on multiple
Trying to first .getJSON then using that data to become the source of my

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.