简体   繁体   English

通过在 Xasis 中显示 1 小时间隔的数据,Recharts 折线图显示奇怪

[英]Recharts Line Chart displays strange by showing data for 1 hour interval in Xasis

I'm trying to make it similar to this chart but it shows strange.我试图让它与这张图表相似,但它显示得很奇怪。

I need a result like this image我需要像这张图片这样的结果

Here's the demo project running on Stackbiltz这是在 Stackbiltz 上运行的演示项目

The x-axis shows from 9 am-3 pm (1-hour interval) and the time-value data interval is 1 minute but after doing this the line is strange (maybe too narrow). x 轴显示从上午 9 点到下午 3 点(1 小时间隔),时间值数据间隔为 1 分钟,但在这样做之后,这条线很奇怪(可能太窄了)。 Do you have any ideas?你有什么想法?

Thanks for your help.谢谢你的帮助。

there are too many data changes, it looks good only if you make the graph width at least 900px.数据变化太多,图形宽度至少900px才好看。

you can try to change the data once in 10 seconds then the graph look ok also with 250 px width您可以尝试在 10 秒内更改一次数据,然后图表看起来也不错,宽度为 250 像素

let j = 0
  let value = parseFloat(getRandomNumber(980, 1050).toFixed(2))
  for (let i = 0; i < totalRange / (60 * 1000) - 1; i++) {

    if (j % 10 === 0) {
      value = parseFloat(getRandomNumber(980, 1050).toFixed(2))
    }
    const next = start.add(1, 'minutes').valueOf();

    arr.push({
      time: next,
      value,
    });
    j++
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM