小编stv*_*534的帖子

省略文本的省略号

我已经找到了一些例子,但很难找到任何工作,如果有人有更清楚或一些见解将非常感激.

var wrap = function() {
var self = d3.select(this),
textLength = self.node().getComputedTextLength(),
text = self.text();
while (textLength > (50) && text.length > 0) {
text = text.slice(0, -1);
self.text(text + '...');
textLength = self.node().getComputedTextLength();
}
};



const y = d3.scaleBand()
.range([height, 0], .1)
.domain(data.map(function (d) {
return d.name; <----- wrap need to somehow attach to this
})
);
Run Code Online (Sandbox Code Playgroud)

javascript svg d3.js

2
推荐指数
1
解决办法
201
查看次数

标签 统计

d3.js ×1

javascript ×1

svg ×1