[Chartjs]-How to cut line graph in ChartJS

1đź‘Ť

âś…

If by “cut” you mean “remove” (don’t draw) then you simply need to pass null as the value, e.g.:

data: [10159, 10152, 43149, 43149, null]

As you haven’t provided your code I can’t correct it, so here’s a rough working example:

new Chart(document.getElementById("chart"), {
  type: "line",
  data: {
    labels: ["05 Aug", "06 Aug", "07 Aug", "08 Aug", "09 Aug"],
    datasets: [{
      data: [10159, 10152, 43149, 43149, null],
      fill: false,
      lineTension: .1
    }]
  },
  options: {
    legend: {
      display: false
    },
    maintainAspectRatio: false,
    scales: {
      yAxes: [{
        ticks: {
          beginAtZero: true
        }
      }]
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js"></script>
<canvas id="chart"></canvas>

Leave a comment