使用图表js限制数据点

问题描述 投票:0回答:1

我已经用chart js设置了折线图。在这张照片中,我的点太大了,但这不是我的问题。点太多了。

有没有办法限制点数?

每5分1分是一个很好的解决方案。

enter image description here

javascript chart.js points
1个回答
1
投票

要解决您的问题,您将需要选择手动跳过4个点的数据点。这是使您有想法的代码示例。

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

您还需要在y轴上执行相同的操作才能使其正常工作。希望对您有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.