[Chartjs]-How can I skip data/labels in a period of time in Chartjs?

0👍

Well, Chart.JS will show whatever labels and data contain. Therefore you can create a function to remove a certain range.

Here is a sample with a line chart: https://codepen.io/adelriosantiago/pen/xxRGVPW?editors=0010

The function rangeWithSkips will basically filter the input array between startSkip and endSkip. Later in the code you select the new range with:

data: {
  labels: rangeWithSkips(3, 10).labels, // Pick the starting and end range here
  datasets: [
    {
      label: "Volume",
      data: rangeWithSkips(3, 10).data // Pick the starting and end range here too
    }
  ]
}

Here is an updated version with that does exactly the same with a 2 inputs: https://codepen.io/adelriosantiago/pen/yLVNOGX?editors=1011

enter image description here

Leave a comment