テキストタグを1つのsvgに追加するにはどうすればよいですか? "id = 50"のsvgタグ?テキストタグを1つのsvgに追加するにはどうすればいいですか? "id = 50"のsvgタグ?
このコードは、以下のプロパティを持つbodyにsvgタグを追加し、各svg(selectAll
)にテキストタグを追加します。私は、例えば一つだけのSVGにテキストタグを追加するにはどうすればよい
//appends text to the first svg
d3.select("body").select("svg").append("text")
.attr("id",202)
:FIDDLE here
var arr =[10,20,30,40,50]
//appends an svg tag to body with the following properties
d3.select("body").selectAll("svg")
.data(arr)
.enter()
.append("svg")
.attr("width",201)
.attr("height",202)
.attr("id",function(d){ return d;})
//appends text tag to each svg
d3.select("body").selectAll("svg").append("text")
.attr("id",202)
このコードは、単にFIDDLE here、最初のSVG(select
)にテキストを追加します"id = 50"のsvgタグ?
は、これが私の試みです:
d3.select("body").select("#50").append("text")
.attr("id",202)
私もselect("svg #50")
が、無喜びを試してみました。誰も助言することはできますか?
そのためのおかげで、ここであなたがhttps([でき]私[フィドル](https://jsfiddle.net/HattrickNZ/dhhw04b8/6/) – HattrickNZ
は確かです:// html.spec.whatwg.org/multipage/dom.html#the-id-attribute)数字で始まるID –
@RobertLongson「id'属性の場合、SVG仕様はXML 1.0勧告を参照します。属性「id」は[* Name * production](https://www.w3.org/TR/2008/REC-xml-20081126/#NT-NameStartChar)と一致する必要があります。そのルールに従えば、値は数字で始まらなければならない。 – altocumulus