Chartjs-ChartJS Update Tooltip programmatically in V2

0๐Ÿ‘

I found an answer:

   var newTooltipConfig = {
       //mode: "dataset",
       intersect: false,
       callbacks: {
           title: function(tooltipItem, data) {
           //Return value for title
           return 'Second: ' + tooltipItem[0].xLabel;
       },
        label: function(tooltipItem, data) {
            var datasetLabel = data.datasets[tooltipItem.datasetIndex].label || 'Other';
            var label = values[tooltipItem.index];
            return datasetLabel + ': ' + label+'%';
    }
    }
    };
    linechart.options.tooltips = newTooltipConfig;
    linechart.update();

Leave a comment