我是HTML
,如下所示,我只能获得文字的height
和width
,而不是整个范围。
var bounds = d3.select(".nodeText").node().getBoundingClientRect();
console.log(bounds.width); // 300
console.log(bounds.height); // 111
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/2.1.3/d3.min.js"></script>
<div style="display: table; width: 300px; height: 111.717px;">
<span class="nodeText" style="display: table-cell; vertical-align: middle; text-overflow: ellipsis; font-family: Arial; font-size: 10px; font-style: normal; font-weight: normal; color: black; opacity: 1;">Exact 765 (55.23%)</span>
</div>
答案 0 :(得分:1)
您可以使用for (DateTime date = dateTimePicker.Value.Date;
date <= dateTimePicker.Value.AddYears(2);
date = date.AddMonths(1)) {
...
}
功能。
createRange
&#13;
var span = d3.select(".nodeText").node();
var textNode = span.childNodes[0];
var range = document.createRange();
range.selectNodeContents(textNode);
var rect = range.getBoundingClientRect();
var height = rect.bottom - rect.top;
var width = rect.right - rect.left;
console.log("height = "+height,"width = "+width);
&#13;