Skip to content Skip to sidebar Skip to footer

Recharts Won't Automatically Calculate Yaxis Ticks

I'm trying to add a chart using recharts with the latest exchange rates of some currencies. Data is shown correctly, but the chart always starts at 0 and goes to a bit above the ma

Solution 1:

Use the yAxis domain prop:

<YAxis type="number" domain={[0, 1000]}/> // set to whatever you want [yMix, yMax]

Solution 2:

For calculating automatically you can use something like these

<YAxis type="number" domain={['dataMin', 'dataMax']} />
<YAxis type="number" domain={[0, 'dataMax']} />
<YAxis type="number" domain={['auto', 'auto']} />

Please make sure to use integer numbers for the values, If you use a string as a value for YAxis it can not recognize the max value correctly.

Post a Comment for "Recharts Won't Automatically Calculate Yaxis Ticks"