Chartjs-Chart.js: Strikethrough tick labels

0👍

I don’t know if that is possible because you are dealing with a canvas element, but you can customize the text in the labels by using the ticks callback as in this example:

       new Chart(document.getElementById("bar-chart"), {
        type: 'bar',
        data: {
            labels: ["One", "Two", "Three", "Four", "Five"],
            datasets: [
                {
                    label: "A chart",
                    backgroundColor: ["#3e95cd", "#8e5ea2", "#3cba9f", "#e8c3b9", "#c45850"],
                    data: [2478, 5267, 734, 784, 433]
                }
            ]
        },
        options: {
            legend: { display: false },
            title: {
                display: true,
                text: 'A chart with columns and custom vertical labels'
            },
            scales: {
                yAxes: [{
                    ticks: {
                        callback: function (value, index, values) {
                            return index % 2 == 0 ? value : '**' + value + '**';
                        }
                    }
                }]
            }
        }
    });

Note the callback funcion there, maybe you can use this to give some labels a distinctive text.

The chart of this example looks like this:
enter image description here

Leave a comment