score:0

Accepted answer

you will have to use a custom tooltip callback like this:

  options: {
    plugins: {
        tooltip: {
        callbacks: {
            label: (ttitem) => (`${ttitem.label}: rp. ${ttitem.parsed}`)
        }
      }
    }
  }

documentation: https://www.chartjs.org/docs/latest/configuration/tooltip.html#tooltip-callbacks

v2:

  options: {
    tooltips: {
        callbacks: {
        label: (ttitem, items) => (`${items.labels[ttitem.index]}: r. ${items.datasets[ttitem.datasetindex].data[ttitem.index]}`)
      }
    }
  }

example v3:

var options = {
  type: 'pie',
  data: {
    labels: ["red", "blue", "yellow", "green", "purple", "orange"],
    datasets: [{
      label: '# of votes',
      data: [12, 19, 3, 5, 2, 3],
      borderwidth: 1
    }]
  },
  options: {
    plugins: {
      tooltip: {
        callbacks: {
          label: (ttitem) => (`${ttitem.label}: rp. ${ttitem.parsed}`)
        }
      }
    }
  }
}

var ctx = document.getelementbyid('chartjscontainer').getcontext('2d');
new chart(ctx, options);
<body>
  <canvas id="chartjscontainer" width="600" height="400"></canvas>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/3.2.0/chart.js"></script>
</body>

example v2:

var options = {
  type: 'pie',
  data: {
    labels: ["red", "blue", "yellow", "green", "purple", "orange"],
    datasets: [{
      label: '# of votes',
      data: [12, 19, 3, 5, 2, 3],
      borderwidth: 1
    }]
  },
  options: {
    tooltips: {
      callbacks: {
        label: (ttitem, items) => (`${items.labels[ttitem.index]}: r. ${items.datasets[ttitem.datasetindex].data[ttitem.index]}`)
      }
    }
  }
}

var ctx = document.getelementbyid('chartjscontainer').getcontext('2d');
new chart(ctx, options);
<body>
  <canvas id="chartjscontainer" width="600" height="400"></canvas>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.8.0/chart.js"></script>
</body>


Related Query

More Query from same tag