80
rated 0 times
[
83]
[
3]
/ answers: 1 / hits: 19376
/ 11 Years ago, fri, february 14, 2014, 12:00:00
I'm working on a pie chart mock. That I need to try and match the designs to have the label extruding out with a horizontal line attached to the slice ticks. Is this possible? It would be a bonus to have the black dots form on the segments.
Here is the code for the tick marks. Would it be a case of creating another set of lines that intersect?
//draw tick marks
var label_group = d3.select('#'+pieId+' .label_group');
lines = label_group.selectAll(line).data(filteredData);
lines.enter().append(svg:line)
.attr(x1, 0)
.attr(x2, 0)
.attr(y1, function(d){
if(d.value > threshold){
return -that.r-3;
}else{
return -that.r;
}
})
.attr(y2, function(d){
if(d.value > threshold){
return -that.r-8;
}
else{
return -that.r;
}
})
.attr(stroke, gray)
.attr(transform, function(d) {
return rotate( + (d.startAngle+d.endAngle)/2 * (180/Math.PI) + );
});
lines.transition()
.duration(this.tweenDuration)
.attr(transform, function(d) {
return rotate( + (d.startAngle+d.endAngle)/2 * (180/Math.PI) + );
});
lines.exit().remove();
More From » d3.js