Chartjs-ChartJS Horizontal Bar – Hide Stacked Bars But Still Show In Tooltip

0👍

Add the hidden tag to datasets of the series you want to hide like this:

type: 'horizontalBar',
label: 'aBar 1',
backgroundColor: '#20C5CB',
stack: 'Stack 1',
hidden: true,
data: [6],

and use a callback to the label tooltip like this:

tooltips: {
  mode: 'index',
  intersect: true,
  bodyFontSize:10,
  titleFontSize:0,
  titleMarginBottom:0,
  callbacks: {
    label: function(tooltipItem, data) {
      return data.datasets.map(ds => ds.label + ': ' + ds.data[tooltipItem.index])
    }
  }
},

Found solution here: Chartjs show hidden data on tooltip

Leave a comment