1
var svgcanvas = d3.select("body").append("svg:svg")
.attr("width", 725)
.attr("height", 500);
我的數據集的樣本將來自DB我有一組字符串數據,我想情節需要的分區與字符串整齊地繪製圓
var jsoncirclehigh =[
{
"blah":"Javascript",
"blah":"",
"blah":"",
},
{
"Technology": "D3",
"TechField":"",
"Devphase":"",
},
];
形狀被拉到附近我忘了加
svgcanvas.append("svg:path")
.attr("d","M -200,0 A200,200 0 0,0 500,0 L -200,0")
.attr("transform", "translate(220,400) scale(1, -1)")
.style("stroke-width", 2)
.style("stroke", "steelblue")
.style("fill", "yellow");
圈,我創建了我想與數據相匹配
svgcanvas.append("circle")
.attr("r", 2.5)
.attr("cx", 200)
.attr("cy", 250)
.style("stroke", "steelblue")
.style("fill", "blue")
.on("mouseover", function(){d3.select(this).style("fill", "aliceblue");})
.on("mouseout", function() {d3.select(this).style("fill", "blue");})
.text(function(d) {return d;});
試圖與圓的文本匹配,但沒有奏效
svgcanvas.selectAll("text")
.data(jsoncirclehigh)
.enter()
.append("text")
.attr("font-family", "sans-serif")
.attr("font-size", "11px")
.attr("fill", "red");
非常感謝你 – user1701622
你可能知道如何將一個形狀內限制這些圈子嗎? – user1701622
@ user1701622不客氣! Re:後續Q - 再來?就像他們的中心座標在某個多邊形內時只繪製它們一樣? – ZachB