0

I have a bar graph with chartjs 2.

I would like to hide tootlips when bar value is egal to a number ( in my exemple 8.23 )

I havn't found an option on chartjs to disable tooltips when hover a specific value

tooltips: {
        enabled: true,
        yPadding: -2,
        xPadding: 10,
        titleFontColor: 'rgba(0, 0, 255, 0.0)',
        displayColors: false,
        borderWidth: 1,
        bodyFontSize: 16,
        bodyFontFamily: 'Avenir',
        backgroundColor: '#0088ce',
        borderColor: '#d7d7d7',
        bodyFontColor: '#FFF',
        callbacks: {
            label: (tooltipItem: any, data: any) => {
                if (this.type === 'PRODUCTION') {
                    return 'condition result';
                } else {
                    return ' condition result2';
                }
            },
        }

Html

<canvas class="canvasHeight" #myChart  style ="height: 50px"></canvas>
Hamza Haddad
  • 1,516
  • 6
  • 28
  • 48

1 Answers1

0

I found the solution in another post.

I have used filter callback

tooltips: {
    filter: function (tooltipItem) {
        return tooltipItem.datasetIndex === 0  ||  8.23;
    }
}
Hamza Haddad
  • 1,516
  • 6
  • 28
  • 48