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

  • Home
  • SEARCH
  • 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 8052671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:36:22+00:00 2026-06-05T07:36:22+00:00

I am learning Javascript, and bit confused the below usage. These question may be

  • 0

I am learning Javascript, and bit confused the below usage. These question may be more javaScript than d3 specific.

http://mbostock.github.com/d3/ex/sunburst.html

var arc = d3.svg.arc()
.startAngle(function(d) { return d.x; })
.endAngle(function(d) { return d.x + d.dx; })
.innerRadius(function(d) { return Math.sqrt(d.y); })
.outerRadius(function(d) { return Math.sqrt(d.y + d.dy); });

so,

  1. startAngle, endAngle etc takes a function as argument. What is the rationale being the argument a function rather than just a number?
  2. In the full code, no where “d” is defined.I see it in almost all of d3 programs. What is “d” for? How is it set or where is it passed?

thanks.

  • 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-05T07:36:23+00:00Added an answer on June 5, 2026 at 7:36 am

    To your first question:

    The d3.svg.arc object is used to create slices inside a pie diagram. Each of these slices needs a different start- and end-angle to be displayed properly.

    In d3.js you do not pass in both angles for each slice, but provide a function, that takes one argument d, which is the corresponding data element for that slice and returns the angles. The same holds for the other parameters set here.

    Another advantage is, that a datum can consist of multiple properties and you can decide which property takes which part with respect to the visualization.

    Your second question

    When using a function as a parameter to another function, it is common to use a function expression of the given form. In d3.js most functions, that serve as parameters, get passed in one or two parameters themselves (most of the time the part of the data, that needs to be transformed). In your function expression you need (or at least should) name those parameters in order to address them. Most of the time in the example d is used as the parametername for the parameter holding the specific data item.

    It doesn’t need to be defined elsewhere as it is just a normal function parameter. If you wish, you could rewrite it in the following way:

    function startAngleParam( d ) {
     return d.x;
    }
    
    var arc = d3.svg.arc()
    .startAngle( startAngleParam )
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bit of javascript/jQuery which creates a simple slideshow. I'm learning jquery
I am learning JavaScript and was asked this question, can anyone help? What do
As a c# coder learning JavaScript I find this alot more readable: $(this) .first()
I've been broadening my horizons learning javascript and I have a quick question about
I'm still learning JavaScript,reading books,utilizing FireBug,experimenting. I'm amazed and stuck on thing below. Have
I'm learning javascript, and in the way I'm trying to learn more about jQuery.
Learning Javascript and have a question about global variables. From my reading, most recommend
I'm learning JavaScript using W3C and I didn't find an answer to this question.
I'm still learning Jquery and a bit confused with the task I have on
Im learning javascript right now, so this might be a really newb question! 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.