Chartjs工具提示换行符 [英] Chartjs Tooltip Line Breaks
本文介绍了Chartjs工具提示换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
chartjs工具提示中是否可能出现换行符?
Is it possible to get line breaks in chartjs tooltips?
tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>"
我想用新行替换:。
我尝试使用&#013;
, \u000D
, \n
和< br />
无济于事。
I've tried with 
, \u000D
, \n
and <br />
to no avail.
更新:由于 chart.js
在版本2上。
Update: I have changed my accepted answer now that chart.js
is on version 2.
推荐答案
如果使用的是2.0。 0-beta2,您可以使用工具提示回调并在那里返回字符串数组。
If you are using 2.0.0-beta2, you can use tooltip callback and return array of strings there.
tooltips: {
mode: 'single',
callbacks: {
afterBody: function(data) {
var multistringText = ['first string'];
// do some stuff
multistringText.push('another string');
return multistringText;
}
}
}
这篇关于Chartjs工具提示换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文