5

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

Ender2050
  • 6,912
  • 12
  • 51
  • 55
AlexDemzz
  • 243
  • 2
  • 18

1 Answers1

11

Your options object should be

...
options: {
  tooltips: {
    callbacks: {
      label: function(tooltipItem, data) {
        var datasetLabel = data.datasets[tooltipItem.datasetIndex].label || '';
        return datasetLabel + ' : ' + tooltipItem.yLabel + ' €';
      }
    }
  }
}
...
potatopeelings
  • 40,709
  • 7
  • 95
  • 119