Chartjs Tooltip Line Breaks(Chartjs 工具提示换行符)
问题描述
是否可以在 chartjs 工具提示中获得换行符?
Is it possible to get line breaks in chartjs tooltips?
tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>"
我想用新的一行替换:".
I want to replace ": " with a new line.
我试过 
、u000D
、
和 <br/>
无济于事.
I've tried with 
, u000D
,
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,您可以使用 tooltip 回调并在此处返回字符串数组.
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 工具提示换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Chartjs 工具提示换行符


基础教程推荐
- 在 contenteditable 中精确拖放 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01