score:1

Accepted answer

you can use custom tooltips to do this (basically you use an html element instead of using the canvas to render the tooltip alone). see https://github.com/nnnick/chart.js/blob/v1.0.2/samples/line-customtooltips.html for an example for line charts.

in your case, you can adjust the loop at https://github.com/nnnick/chart.js/blob/v1.0.2/samples/line-customtooltips.html#l68 to exclude / include the datasets as you see fit.

score:1

i make use of the custom tooltip configuration to achieve this(here it hides datasets that doesn't have "income" label):

this.mychart = new chart(this.ctx, {
        type: 'bar',
        data: {
            labels: labels,
            datasets: [{
                    label: "income",
                    data: data3
                },
                {
                    label: "tax",
                    data: data1,
                    backgroundcolor: "#3eafd5"
                },
                {
                    label: "expenses",
                    data: data2,
                    backgroundcolor: "#d24b47"
                }
            ]
        },
        options: {
            responsive: true,
            tooltips: {
                custom: function(tooltipmodel) {
                    if (tooltipmodel.body && tooltipmodel.body[0].lines && tooltipmodel.body[0].lines[0].indexof("income") == -1) {
                        tooltipmodel.opacity = 0;
                    }
                }
            }
        }
    }

Related Query