Home Forums Chart Support It does not allow me to hide weekend dates in a line graph. Reply To: It does not allow me to hide weekend dates in a line graph.

#60301

@riron2421,

To remove the weekend gap from the chart, you can use customBreaks as shown in this code snippet.


function removeWeekendGap(chart) {
  var scaleBreaks = [],
      dps = chart.data[0].dataPoints;
  for (var i = 1; i < dps.length; i++) {
    if (dps[i].x.getDate() - 1 != dps[i - 1].x.getDate())
      scaleBreaks.push({
        startValue: new Date(
          dps[i - 1].x.getTime() + 12 * 60 * 60 * 1000
        ),
        endValue: new Date(dps[i].x.getTime() - 12 * 60 * 60 * 1000),
      });
  }

  chart.axisX[0].scaleBreaks.customBreaks = scaleBreaks;
  chart.render();
}

Please check out this Stackblitz for complete working code.

Removing weekend gap using Scalebreaks

—-
Manoj Mohan
Team CanvasJS