recharts:使用a< brush />使用自定义X轴tick ticks;

发布于 2025-02-12 00:48:29 字数 546 浏览 0 评论 0原文

我一直在尝试使用rechartsreact中创建图表,并且在使用&lt;时,我一直在使用自定义的X轴tick渲染呈现相同的问题。刷 /&gt; < /code>组件。

我有大部分数据要显示1天:[{date:'9:30',value:1},{date:'9:35',value:2},...]

每小时也会分别生成X轴壁虱:['9:00','10:00',...]

如果我不使用刷子使用Zoom看起来像 this ,但是当我试图缩放以查看特定时间范围时,所有tick tick都消失了但是一个

I've been trying to create a chart with recharts in react and I keep on getting the same issue with custom x-axis ticks rendering when using the <Brush /> component.

I have a chunk of data to display for 1 day: [{ date: '9:30', value: 1 }, { date: '9:35', value: 2 }, ...]

There are also x-axis ticks for every hour generated separately: ['9:00', '10:00', ...]

If I don't use zoom with the brush it looks like
this but when I'm trying to zoom-in to see a specific time range all ticks disappear but one ????.

I can get the brush to work without custom ticks but I really need to show only hours without any intermediate values like 9:45 on the x-axis. Would be very glad to hear any feedback.

React v17.0.2
Recharts v2.1.9
Chrome Version 103.0.5060.53 (Official Build) (x86_64)

This example in a sandbox: https://codesandbox.io/s/simple-area-chart-forked-4kojl9?file=/src/App.tsx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文