score:0

you should use context.parsed.x instead of context.parsed.y since it's a horizontal bar chart.

please take a look at your amended code and see how it works.

new chart('barchart', {
  type: 'bar',
  data: {
    labels: ["fruits"],
    datasets: [{
        label: "apple",
        data: [12],
        backgroundcolor: 'blue',
        barthickness: 80,
      },
      {
        label: "banana",
        data: [15],
        backgroundcolor: 'red',
        barthickness: 80,
      },
    ]
  },
  options: {
    maintainaspectratio: false,
    indexaxis: 'y',
    responsive: true,
    scales: {
      x: {
        stacked: true,
        display: false,
      },
      y: {
        stacked: true,
        display: false,
        mirror: true,
      }
    },
    plugins: {
      tooltip: {
        callbacks: {
          label: ctx => ctx.dataset.label + ': ' + new intl.numberformat('de-de', { style: 'currency', currency: 'eur' }).format(ctx.parsed.x)
        }
      },
      legend: {
        display: false
      },
      title: {
        display: false,
      },
    },
  },
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/3.7.1/chart.min.js"></script>
<canvas id="barchart" height="100"></canvas>


Related Query

More Query from same tag