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

It does not allow me to hide weekend dates in a line graph.

Viewing 2 posts - 1 through 2 (of 2 total)
  • #60298

    Hello, I am using a line graph.

    I am displaying data by day, according to established date parameters, but I have a problem. The data I am trying to graph does not include data for weekend days. I do not want these days to be graphed. Is there a solution so that the graph does not show points on the X axis with weekend day dates (Saturday / Sunday).

    #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

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.