最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Where put "multiTooltipTemplate" in Chart.js v2.x - Stack Overflow

programmeradmin3浏览0评论

i want to change the "label" for the "datasetlabel" width "multiTooltipTemplate". But i find the solution only for the previous version of chart.js

Can you tell me how to convert this :

multiTooltipTemplate: "<%%=datasetLabel%> : <%%= value %>",

To the version 2 of Chart.js

For now i got this in option :

    options: {
tooltips: {
            enabled: true,
            mode: 'single',
            callbacks: {
                label: function(tooltipItems, data) { 
                    return tooltipItems.yLabel + ' €';
                }
            }
        },
}

Thanks for helping

i want to change the "label" for the "datasetlabel" width "multiTooltipTemplate". But i find the solution only for the previous version of chart.js

Can you tell me how to convert this :

multiTooltipTemplate: "<%%=datasetLabel%> : <%%= value %>",

To the version 2 of Chart.js

For now i got this in option :

    options: {
tooltips: {
            enabled: true,
            mode: 'single',
            callbacks: {
                label: function(tooltipItems, data) { 
                    return tooltipItems.yLabel + ' €';
                }
            }
        },
}

Thanks for helping

Share Improve this question edited Oct 28, 2017 at 18:20 Ender2050 6,99212 gold badges53 silver badges55 bronze badges asked May 11, 2016 at 9:31 AlexDemzzAlexDemzz 2432 silver badges18 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 11

Your options object should be

...
options: {
  tooltips: {
    callbacks: {
      label: function(tooltipItem, data) {
        var datasetLabel = data.datasets[tooltipItem.datasetIndex].label || '';
        return datasetLabel + ' : ' + tooltipItem.yLabel + ' €';
      }
    }
  }
}
...
发布评论

评论列表(0)

  1. 暂无评论