[Chartjs]-ChartJS: Limit label's length on an axis and show a tooltip on hover?

5👍

Use Chart.scaleService.updateScaleDefaults.

Chart.scaleService.updateScaleDefaults('category', {
    ticks: {
        callback: function (tick) {
            return tick.substring(0, 3);
        }
    }
});

And add this code in your xAxes options.

tooltips: {
    callbacks: {
        title: function (tooltipItems, data) {
            return data.labels[tooltipItems[0].index]
        }
    }
}

Leave a comment