Jens Törnell
Jens Törnell

Reputation: 24798

Limit data points with chart js

I've setup a line chart with chart js. In this picture my dots are too big but that is not my problem. There are too many points.

Is there a way to limit the number of points?

One point every 5 points would be a good solution.

enter image description here

Upvotes: 0

Views: 2162

Answers (1)

Pakpoom Tiwakornkit
Pakpoom Tiwakornkit

Reputation: 2939

To solve your problem you will need to select data points with 4 points skipped manually. Here is the code example to have you get the idea.

var reducedDataPoints = []
for(let [item, index] of xAxisDataPoints.entries()) {
  if(index % 5 === 0) {
    reducedDataPoints.push(item)
  }
}

You also need to do the same on the y axis to get it to work. Hope it helps

Upvotes: 1

Related Questions