How to cut line graph in ChartJS

Jonjie

I'm trying to cut the line graph to its specific data but still want to show the labels below. Please see the screenshot.

enter image description here

How can I remove or cut the line with the red indicator without removing the 09 Aug?

I've added this line, lineTension: .10, but I think this is only to specify how the line curves. Any idea for this? I've already searched over the internet but unfortunately didn't find an answer.

timclutton

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>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related