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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:00:45+00:00 2026-06-17T13:00:45+00:00

I have been checking some tutorials about D3JS about joining and nesting, but I

  • 0

I have been checking some tutorials about D3JS about joining and nesting, but I can not solve the next problem, I was also checking example like http://bl.ocks.org/4061961 but I don’t find the solution between all the magic.

So, I have an array of elements, with this array I can create a “g” label for each element, and I can create a “text” label for each element, but I can not manage to put the “text” label inside the “g” label.

So what a I get in the DOM is this:
HTML -> BODY -> SVG -> G
HTML -> BODY -> SVG -> TEXT

And what I’ll like is this:
HTML -> BODY -> SVG -> G -> TEXT

My small testing code is this one:

data = ["1", "2", "3", "4", "5"];

// Grups de selecció
svg.selectAll("svg_group")
  .data(data)
  .enter()
  .append("g")
  .attr("class", 'svg_group');

// Text dels dies / anys
svg.selectAll("g .svg_group")
  .data(data)
  .enter()
  .append("text")
  .text( function(d) { return d; } );

I’ll appreciate any help. Thanks in advance.

Update 16:08

I need to add more than one element to the group and if possible in two steps. Now I have this in the DOM:

  <svg id="gantt" width="500" height="500">
    <g class="svg_group">
    <g class="svg_group">
    <g class="svg_group">
    <g class="svg_group">
    <g class="svg_group">
    <text>1</text>
    <text>2</text>
    <text>3</text>
    <text>4</text>
    <text>5</text>
    <line>1</line>
    <line>2</line>
    <line>3</line>
    <line>4</line>
    <line>5</line>  
  </svg>

And I like something like this:

  <svg id="gantt" width="500" height="500">
    <g class="svg_group">
      <text>1</text>
      <line>1</line>
    </g>
    <g class="svg_group">
      <text>2</text>
      <line>2</line>
    </g>
    <g class="svg_group">
      <text>3</text>
      <line>3</line>
    </g>
    <g class="svg_group">
      <text>4</text>
      <line>4</line>
    </g>
    <g class="svg_group">
      <text>5</text>
      <line>5</line>
    </g>
  </svg>

Example in:
http://jsfiddle.net/y394h/10/

  • 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-17T13:00:46+00:00Added an answer on June 17, 2026 at 1:00 pm

    How about this?

    svg.selectAll("svg_group")
      .data(data)
      .enter()
      .append("g")
      .attr("class", 'svg_group')
      .append("text")
      .text( function(d) { return d; } );
    

    or

    var group = svg.selectAll("svg_group")
      .data(data)
      .enter()
      .append("g")
      .attr("class", 'svg_group');
    
    group.append("text")
      .text( function(d) { return d; } );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have been looking on some tutorials for drawing canvas using SurfaceView, but the only
I have been checking out some info about 64-bit driver development; I found that
I have been querying google for some material about kd-trees and image comparison but
I have been checking out some posts on bounds vs frames but still a
I have been checking out some of the possible timers lately, and System.Threading.Timer and
I have been checking out some Rogue like games (Larn, Rogue, etc) that are
I have about 4 threads. One thread keeps checking some data that the other
I have been checking since some time to mount external drives to android phone
I have been doing some research on this but found no clear answer. The
We have been facing a small problem in MySQL procedure. We have placed some

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.