Chartjs-Chartjs – display nth string X-axis label?

0👍

See https://www.chartjs.org/docs/latest/axes/labelling.html

basically, you set the ticks value. You use a ternary to decide when to show, e.g.

    options: {
        scales: {
            y: {
                ticks: {
                    // Only show if n'th
                    callback: function(value, index, ticks) {
                        return index%3 ? value : '';
                    }
                }
            }
        }
    }

Leave a comment