關(guān)于屬性設(shè)置不清楚。
有關(guān)于屬性值的說明文檔嗎?官網(wǎng)API里也搜不到,
比如.attr(這里有transform,left,right,)還有其他的屬性可以設(shè)置嗎?
再比如
var svg=d3.select("#container")?//?
.append("svg")?//為什么是svg,為什么不是svgOtherName ??,看完第一節(jié),還是一頭霧水啊,只會(huì)照著做。
還有?text-anchor、cardinal、這些在在官網(wǎng)API里也搜不到。老師能把可用屬性枚舉出來不?
2014-11-27
有關(guān)于屬性值的說明文檔嗎?
https://github.com/mbostock/d3/wiki/Selections#attr
attr是這樣定義的:selection.attr(name[,?value]),比如給svg這個(gè)selection設(shè)置attr,svg.attr("width", 500)
那最后就會(huì)在html中生成這樣的形式?<svg width="500">. attr只是提供了一種方法,讓你給某種name賦予一個(gè)指,具體attr有什么,那要看你的attr所對(duì)應(yīng)的元素/selection支持什么樣的attr,比如這里的svg,你就要看和svg相關(guān)的attr都有哪些。
我說清楚了么?如果不清楚的話,咱們?cè)倮^續(xù)討論
transform的api:
https://github.com/mbostock/d3/wiki/Math#d3_transform
var svg=d3.select("#container").append("svg")
append什么元素都可以的,因?yàn)槲疫@里后面要操作的元素都是svg元素,所以要用svg作為一個(gè)root 元素,就像html中的html元素一樣。
text-anchor是svg中的元素:
http://tutorials.jenkov.com/svg/text-element.html#text-anchor
cardinal在這里:
https://github.com/mbostock/d3/wiki/SVG-Shapes#line_interpolate
2014-11-27
恩,第一句話就豁然開朗了~感謝。