score:1

better approach is to customize tooltip template to show no data :

tooltiptemplate: "<%if (label && value){%><%=label%>: <%= value %><%} else {%> no data <%}%>"

score:2

i wanted to disable the tooltip all times. the version i'm using is 2.1.6, and i did it like this:

var options = {
    tooltips : {
        enabled: false      
    }
};

note: this will not display tool-tip at all, use it only when you want to disable the tool-tip appearing.

score:3

if you don't mind a few console messages you can throw an error to exit out of the tooltip method for null values, like so

var mylinechart = new chart(ctx).line(data, {
    tooltiptemplate: function (d) {
        if (d.value === null)
            throw '';
        else
            // else return the normal tooltip text
            return d.label + ': ' + d.value;
    }
});

the alternative would be to extend the chart or write a custom tooltips function


fiddle - http://jsfiddle.net/y4zunrx6/

score:3

using chart.js 2.3.0 and angular-chart.js 1.1.1, i solved the problem globally by resolving the chartjsprovider provider in my angular.module('shared').config(...) function and specifying a custom label callback for the tooltips option:

        chartjsprovider.setoptions({
            tooltips: {
                enabled: true,
                //mode: 'single',
                callbacks: {
                    label: function (tooltipitem, data) {
                        const tooltip = data.datasets[tooltipitem.datasetindex];
                        const value = tooltip.data[tooltipitem.index];
                        return value === 0 ? null : tooltip.label + ': ' + value;
                    }
                }
            }
        });

by returning null the tooltip is not shown for that specific tooltipitem.

reference: chart.js tooltip configuration


Related Query

More Query from same tag