Chartjs-Chart JS: All Values Displayed on x-axis After Callback Conversion

1๐Ÿ‘

I fixed this by disabling the autoSkip feature. Something I had tried previously but could not get to work. Presumably, because I put it in the wrong location.

      xAxes: 
        [{
            ticks: 
            {
                callback: function(dataLabel, index) {
                    //Hide the label of the datasets except the beginning of the week. Display the week, not the day. Return null to hide the grid line, or '' to keep it.
                    console.log("dataLabel = " + dataLabel + " (dataLabel - 1) % 7 " + (dataLabel - 1) % 7)
                    return (dataLabel - 1) % 7 === 0 ? (Math.floor((dataLabel - 1) / 7)).toString() : null;
                },
                fontSize: 16,
                autoSkip: false,
            },
            scaleLabel: {
                display: true,
                labelString: 'Week'
            }
        }]

Leave a comment