简体   繁体   English

如果同一页面上有多个条形图,则重新绘制条形图 y 轴范围

[英]Recharts bar chart y-axis range not rendered in case of multiple bar charts on same page

I am using 4 re-charts barchart control in react to display bar charts in the same page.我正在使用 4 个重新图表条形图控件来响应在同一页面中显示条形图。 To set the y-axis range, I am using datamax.要设置 y 轴范围,我使用的是 datamax。 It is working for 2 of the barcharts but for the remaining 2, it does not work.它适用于 2 个条形图,但对于其余 2 个,它不起作用。 Below is the Y-Axis configuration:-以下是 Y 轴配置:-

<YAxis type="number" domain={[0, (dataMax) => Number(dataMax) + 50]} />

Below is the screenshot of the way the charts are currently rendered.下面是图表当前呈现方式的屏幕截图。 The ones highlighted in yellow are not correctly rendered.以黄色突出显示的未正确渲染。

在此处输入图像描述

Probably your json file has string values instead of numeric values.可能您的 json 文件具有字符串值而不是数值。 You can use parseInt(cost) or parseFloat(cost)您可以使用 parseInt(cost) 或 parseFloat(cost)

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

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