Javascript 图表JS:回调转换后x轴上显示的所有值

Javascript 图表JS:回调转换后x轴上显示的所有值,javascript,chart.js,chart.js2,Javascript,Chart.js,Chart.js2,我想使用Chart.Js根据天数绘制一些数据。这些天将从第169天(第24周第1天)到第295天(第42周第1天) 我希望显示所有天数的所有数据,但仅显示x轴上天数的子集,如下所示。我希望x轴上的日期显示为一周,并且仅显示每周的第一天。例如,第169天将显示为第24周,然后在第176天(即第25周)之前,x轴上没有任何值。我希望每周以这种方式在x轴上显示 我使用此回调函数成功地将x轴上的天转换为周: ticks: { //stepSize: 10, //This does nothing cal

我想使用Chart.Js根据天数绘制一些数据。这些天将从第169天(第24周第1天)到第295天(第42周第1天)

我希望显示所有天数的所有数据,但仅显示x轴上天数的子集,如下所示。我希望x轴上的日期显示为一周,并且仅显示每周的第一天。例如,第169天将显示为第24周,然后在第176天(即第25周)之前,x轴上没有任何值。我希望每周以这种方式在x轴上显示

我使用此回调函数成功地将x轴上的天转换为周:

ticks: {
//stepSize: 10, //This does nothing
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.
return (dataLabel - 1) % 7 === 0 ? (Math.floor((dataLabel - 1) / 7)).toString() : null;
},
这个确实有效,因为我想转换为周的所有天都转换为周,其余的都返回为null(在x轴上没有显示值,也没有显示行)。我可以通过手动调整图表大小和使用的控制台日志来判断这一点。然而,图表Js似乎选择了要显示的转换周数。我尝试使用步长值,但没有效果。有没有办法强制Chart.JS在x轴上添加所有转换的周数

请参阅此JSFIDLE进行演示:
第215行是回调函数。

我通过禁用autoSkip功能修复了这个问题。我以前试过的东西,但没法开始工作。大概是因为我放错地方了

      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'
            }
        }]