0
我想了解一个由mbostock包装长文本标签的d3代码块。包装文本,使用通话功能传递数据
完整的示例和代码:http://bl.ocks.org/mbostock/7555321
这个例子上被引用此之前,但我无法理解“.tick”级怎么还可以选择并传递到一个文本元素“包装“功能。
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.selectAll(".tick text") //text selected here
.call(wrap, x.rangeBand()); //wrap function called here
function wrap(text, width) {
text.each(function() {
var text = d3.select(this),
words = text.text().split(/\s+/).reverse(), //text manipulated here
我认为,当“x轴()”被调用,那么秤(x)时数据被附加了“名”,但我不明白这些数据如何被传递和访问的“wrap()”函数。