Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where put "multiTooltipTemplate" in Chart.js v2.x

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

like image 439
AlexDemzz Avatar asked May 11 '16 09:05

AlexDemzz


1 Answers

Your options object should be

...
options: {
  tooltips: {
    callbacks: {
      label: function(tooltipItem, data) {
        var datasetLabel = data.datasets[tooltipItem.datasetIndex].label || '';
        return datasetLabel + ' : ' + tooltipItem.yLabel + ' €';
      }
    }
  }
}
...
like image 116
potatopeelings Avatar answered Nov 01 '22 17:11

potatopeelings