如何将饼图高图中的标题文本居中?
我正在尝试将饼图 Highchart 的标题文本居中对齐。能够实现这一点,但是当鼠标悬停和鼠标移出时,标题数据不会更新。任何人都可以帮助我。 在 MouseHOver 上尝试执行下面提到的代码
point: {
events: {
mouseOver: function() {
let span = '<span style="color:${this.color}" class="dealer-title">${this.y}<br/> <span style="color:#33383e;}" class="text-truncate" title="${this.name}"><b> </b></span></span>';
$('.customTitle')[0].innerHTML = span
}
}
}
}
},
I am trying to do center align the title text of the pie chart Highchart. Was able to achieve that but on mouse hover, and mouse out the title data doesn't get updated. Anyone can help me with the same.
On MouseHOver trying to do the below mentioned code
point: {
events: {
mouseOver: function() {
let span = '<span style="color:${this.color}" class="dealer-title">${this.y}<br/> <span style="color:#33383e;}" class="text-truncate" title="${this.name}"><b> </b></span></span>';
$('.customTitle')[0].innerHTML = span
}
}
}
}
},
fiddle attached:
https://jsfiddle.net/5sutmqv3/1/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在
text
中启用usehtml
参数方法调用:live demo: https://jsfiddle.net/blacklabel/w5a2jpk7/
You need to enable
useHTML
argument in thetext
method call:Live demo: https://jsfiddle.net/BlackLabel/w5a2jpk7/
API Reference: https://api.highcharts.com/class-reference/Highcharts.SVGRenderer#text
看来您不能在标题中包含 html 标签。如果删除 SPAN,它将显示这些值。
It looks like you can't include html tags in the title. If you remove the SPANs it'll display the values.