我几乎没有浏览器方面的经验,我一直在调试这个问题,因为现在只是无法解决它。 每当我们将特定对象指向工具提示时,我都会显示一个动态文本框。这里的问题是它没有将下一行包装成多行,因为它被剪裁了。
这是我的代码
var html_comment= (this.getAttribute('comment')).toString();
html_comment = html_comment.replace(/(?:\\r\\n|\r|\\n| \\n)/g, '<br />');
if(activityCount > 1){
$('.highcharts-tooltip').hide();
html_comment = numberOfActivityHeader;
}
text = chart.renderer.text(this.getAttribute('SomeAttributeType') + ": <b>" + symbol + this.getAttribute('SomeAttributeValue') + suffix + "</b><br>" + html_comment , x + 10 + correctionX, y + 10 * 2)
.attr({
zIndex: 16
}).css({
fillColor: '#fff',
color: '#000'
}).add();
var box = text.getBBox();
debugger;
textBG = chart.renderer.rect(box.x - 5, box.y - 5, box.width + 10, box.height + 10, 5)
.attr({
fill: '#ffffff',
stroke: '#0072bc' || 'grey',
'stroke-width': 1,
zIndex: 15
}).add();
}).on('mouseout', function (event) {
text.destroy();
textBG.destroy();
$('.highcharts-tooltip').show();
到目前为止我尝试了什么: 我试着通过插入\ n说出每10个字符来手动包装它。但我看到\ n完全被忽视了。
我也试过更改一些css
text = chart.renderer.text(this.getAttribute(&#39; someAttributeType&#39;)+&#34;:&#34; + symbol + this.getAttribute(&#39; someAttributeValue&# 39;)+后缀+&#34;
&#34; + html_comment,x + 10 + correctionX,y + 10 * 2)
.attr({
zIndex:16
})。CSS({
fillColor:&#39; #ffff&#39;,
颜色:&#39;#000&#39;,
wordWrap:&#39; break-word&#39;
})添加();
textBG = chart.renderer.rect(box.x - 5,box.y - 5,box.width + 10,box.height + 10,5) .attr({ 填写:&#39; #fffff&#39;, 中风:&#39;#0072bc&#39; || &#39;灰&#39 ;, &#39; stroke-width&#39;:1, zIndex:15, wordWrap:&#39; break-word&#39; })添加();
正如您在上面所看到的,使用wordWrap来破坏renderer.text和rederer.rect中的单词。即使上面也没有用。
使用Highcharts或使用正确的css属性是否有解决此问题的方法?