Hi Atish,
I'm going to try to help you by explaining why your sample(s) are not working. I hope this helps you in getting a better understanding of the code (instead of providing a version that does work).
Your samples (except for sample5.html) do not include any code to create labels. A label should be inside a <text> tag. The different samples do create <title> tags, but those are only shown (by some browsers) when hovering. The method .text(...) is used to set the textual value within a tag, so maybe that caused you to think text was added.
You should look for .append("text") in your code or in the original Sunburst code.
As said in sample5.html there is code to add text (line 55 and down). The value of the <text> tag is set using ".text(function(d){return
d.data.name})". This means it assumes your data contains a property "data" which in turn contains a property "name". But that is not the case with your data (see example of your data below and how to retrieve it live in your browser). Your data does contain a property "name" directly. So changing the function to ".text(function(d){return
d.name})" (line 65) will give it the correct textual value.
BUT, we are not there yet: the lines 63 and 64 contain styling attributes. The values are calculated in "labelVisible()" and "labelTransform()". Both functions contain references to properties "x0", "x1", "y0" and "y1". But again, your data does not have these properties. Your data has properties "x", "y", "dx" and "dy". You should use these values. Have a look at the lines 31 to 35 to see how these values are used to calculate the angle and radius. You'll need to use something similar in "labelTransform".
If you want to know what data is bound to an element. Just open the developer console in your browser. On the console you can (in most browsers) just type Javascript commands. If you type "d3.select("text").datum()" (without the outer quotes ;-) and hit Enter, you will see which data is bound to the first <text> tag in your html. It will show something like the values below. Here you see you have "name" (not "
data.name") and "x", "y", "dx" and "dy".
children: Array(10),
depth: 0,
dx: 1,
dy: 0.2,
name: "flare",
value: 956129,
x: 0,
y: 0
Hope I set you on the right track. Good luck.
Erik