【发布时间】:2023-04-03 18:15:01
【问题描述】:
当我的鼠标指针悬停在图表上时,是否可以有标签和单位?目前只有数字。
对于下面的示例,我想展示:
- 58% 标签1
- 0% 标签2
- 0% 标签3
- 0% 标签4
- 0% 标签5
我的选项如下所示:
var options = {
//Boolean - Show a backdrop to the scale label
scaleShowLabelBackdrop : true,
//Boolean - Whether to show labels on the scale
scaleShowLabels : true,
// Boolean - Whether the scale should begin at zero
scaleBeginAtZero : true,
scaleLabel : "<%%= Number(value) + ' %'%>",
legendTemplate: "<ul class=\"<%%=name.toLowerCase()%>-legend\"><%% for (var i=0; i<datasets.length; i++){%><li><span style=\"background-color:<%%=datasets[i].strokeColor%>\"></span><%%if(datasets[i].label){%><%%=datasets[i].label%> <strong><%%=datasets[i].value%></strong><%%}%></li><%%}%></ul>",
tooltipTemplate: "<%%= value %> Label"
}
使用 scaleLabel 选项,我在 Y 轴上显示 %,但在悬停弹出窗口上没有...
【问题讨论】:
-
一切皆有可能。你试过的代码在哪里?
-
@tellez 我试过的选项在帖子上,这应该是正确的吗?我在文档上没有找到更改 popup 显示的选项,我发现的只是比例
-
@tellez 我发现可能有用的选项是 tooltipTemplate,但是当我更改它时,我的图表上什么也没有发生...
标签: javascript jquery ruby-on-rails label chart.js