title: Accessing data from the callback function of a bar chart using chart js
body: <p>I am currently trying to show a text stocked in the data in the tooltip, I can#t figure how to make it work, I have tried many things.</p>
  <p>You can find below an example of what I#m trying to do, I want that the &quot;text&quot; value is displayed when hovering one of the bar.</p>
  <p>I tried this</p>
  <pre><code>let data = [{
        label: 'Available',
        backgroundColor: '#3366ff',
        data: [500],
        text : &quot;test1&quot;
      }, {
        label: 'Budget',
        backgroundColor: '#009999',
        data: [5000, 6500],
        text : &quot;test2&quot;
      }, {
        label: 'Actual',
        backgroundColor: '#92d400',
        data: [5200, 7245],
        text : &quot;test3&quot;
      }];
  
      new Chart(document.getElementById(&quot;bar-chart-horizontal&quot;), {
          type: 'horizontalBar',
          data: {
              labels: [&quot;Rooms&quot;, &quot;Guests&quot;],
              datasets: data,
          },
          options: {
              scales: {
                  xAxes: [{
                      ticks: {
                          beginAtZero: true
                      }
                  }]
              },
              tooltips: {
                  callbacks: {
                      label: function(tooltipItem, data) {
                          var item = data.datasets[tooltipItem.datasetIndex].data[tooltipItem.index];
                          return item.text;
                      }
                  }
              }
          }
      });
  </code></pre>
  <p>But this is not working, it is not even displaying anything logical, only &quot;Room&quot; and &quot;Guests&quot;.</p>
  <p>What should I do to retrieve the correct informations ? I tried doing it like this : <a href="https://jsfiddle.net/8ks5hwLo/" rel="nofollow noreferrer">Fiddle</a></p>
  <p>But it doesn't work when applied to my code... I'm probably missing something pretty stupid but I can't figure what.</p>
  <p>Thanks to all the people that will read this and try to help me.</p>