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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:21:14+00:00 2026-06-15T21:21:14+00:00

After fiddling around for several hours now, I still cannot make labels work in

  • 0

After fiddling around for several hours now, I still cannot make labels work in my D3 Sunburst layout. Here’s how it looks like:

http://codepen.io/anon/pen/BcqFu

enter image description here

I tried several approaches I could find online, here’s a list of examples I tried with, unfortunately all failed for me:

[cannot post link list because of new users restriction]

and of course the coffee flavour wheel: http://www.jasondavies.com/coffee-wheel/

At the moment i fill the slices with a title tag, only to have it displayed when hovering over the element. For that I’m using this code:

 vis.selectAll("path")
   .append("title")
   .text(function(d) { return d.Batch; });

Is there something similar I could use to show the Batch number in the slice?

—

More info: Jason Davies uses this code to select and add text nodes:

var text = vis.selectAll("text").data(nodes);
var textEnter = text.enter().append("text")
  .style(...)
  ...

While the selection for his wheel gives back 97 results (equaling the amount of path tags) I only get one and therefore am only able to display one label (the one in the middle)

  • 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-15T21:21:15+00:00Added an answer on June 15, 2026 at 9:21 pm

    Needs some finessing but the essential piece to get you started is:

      var labels = vis.selectAll("text.label")
          .data(partition.nodes)
        .enter().append("text")
          .attr("class", "label")
          .style("fill", "black")
          .attr("transform", function(d) { return "translate(" + arc.centroid(d) + ")"; })
          .text(function(d, i) { return d.Batch;} );
    

    You can see it here

    The trick is that in addition to making sure you are attaching text nodes to the appropriate data you also have to tell them where to go (the transform attribute with the handy centroid function of the arc computer).

    Note that I do not need vis.data([json]) because the svg element already has the data attached (when you append the paths), but I still have to associate the text selection with the nodes from each partition.

    Also I class the text elements so that they will not get confused with any other text elements you may want to add in the future.

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

Sidebar

Related Questions

After inheriting some Zend Framework code it didn't work, after lots of fiddling I've
After some time researching and trying different things I still cannot get my @ExceptionHandler
Good Sunday morning! After fiddling around with some JavaScript this weekend, I finally wrote
I was getting ready to post this as a question, but after fiddling around
I am learning JS and after fiddling around with adding elements etc I tried
I am new to Ruby on Rails. After fiddling around with it for a
I'm fiddling around with knockout js and trying to make a grid with a
After fiddling around with an issue I am having I have come to this
After much fiddling, I've managed to install the right ODBC driver and have successfully
After a long search I'm still confused about it although I found some related

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.