Chartjs-Chart.js – Line Chart Tooltip Labels

1πŸ‘

I did something like this to add some padding. Not ideal but I don’t know another way.

  tooltips: {
    callbacks: {
      title: function(tooltipItem, data) {
        return tooltipItem[0].xLabel;
      },
      label: function(tooltipItem, data) {
        return ' ' + data.datasets[tooltipItem.datasetIndex].label + ' ' + tooltipItem.yLabel;
      }

Basically adding the padding manually

return ' ' + ... + tooltipItem.yLabel;

Probably more helpfully, see Edit tooltips in ChartJS

Leave a comment