1
我开始与D3玩计算位置和元件的旋转,我想实现这一结果:D3 - 由弧边
我做这个事情弧,但我不”不知道如何计算三角形的位置和旋转?这是我当前的代码:(http://jsfiddle.net/spbGh/1/)
var width = 220,
height = 120;
var convertValue = function (value) {
return value * .75 * 2 * Math.PI;
}
var arc = d3.svg.arc()
.innerRadius(45)
.outerRadius(60)
.startAngle(0);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width/2 + "," + height/2 + ")")
var big_background = svg.append("path")
.datum({ endAngle: convertValue(1)})
.style("fill", "#f3f4f5")
.attr("d", arc);
var big_gain = svg.append("path")
.datum({ endAngle: convertValue(.75) })
.style("fill", "orange")
.attr("d", arc);
// HELP with this thing!!!
var triangle = svg.append('path')
.style("fill", "orange")
.attr('d', 'M 0 0 l 4 4 l -8 0 z')
'如果用另一种方式绘制三角形,它会变得更容易< - 你是什么意思?你能给我另一个例子吗? –
在您的代码中,提示朝上。在我修改后的jsfiddle中,它没有任何旋转就指向下方。 –
你能帮助我转型吗?我如何在电弧路径上实现运动?现在我的箭头正在从一个地方跳到另一个地方:http://jsfiddle.net/spbGh/4/ –