YAxis scale=log not working when any value is 0
See original GitHub issue- [ x] I have searched the issues of this repository and believe that this is not a duplicate.
Reproduction link
Steps to reproduce
Create a graph that has values at zero in some field:
const data2 = [
{
name: "Page A",
uv: { value: 200, errors: [100, 200] },
pv: { value: 2400, errors: [200, 100] }
},
{
name: "Page B",
uv: { value: 0, errors: [0, 0] }, // change value to something to render
pv: { value: 4200, errors: [50, 200] }
},
{
name: "Page C",
uv: { value: 1600, errors: [50, 100] },
pv: { value: 3200, errors: [100, 100] }
}
];
And try to render with scale=log:
<LineChart
width={600}
height={300}
data={props.data}
margin={{ top: 5, right: 30, left: 20, bottom: 5 }}
>
<XAxis dataKey="name" />
<YAxis domain={["auto", "auto"]} scale="log" />
<CartesianGrid strokeDasharray="3 3" />
<Tooltip />
<Legend />
<Line
type="monotone"
dataKey="pv.value"
stroke="#8884d8"
activeDot={{ r: 8 }}
connectNulls={false}
>
<ErrorBar dataKey={`pv.errors`} width={4} strokeWidth={1.5} />
</Line>
<Line
type="monotone"
dataKey="uv.value"
stroke="#82ca9d"
connectNulls={false}
>
<ErrorBar dataKey={`uv.errors`} width={4} strokeWidth={1.5} />
</Line>{" "}
</LineChart>
What is expected?
To render the line chart.
What is actually happening?
The line chart is not rendered when scale log and some values at 0.
Error in console Warning: Received NaN for the
y1 attribute. If this is expected, cast the value to a string.
is being printed.
Environment | Info |
---|---|
Recharts | v2.1.6 |
React | react 16 |
System | any |
Browser | any |
In the example attached you can find one grpah and one not working. The difference: a 0 value in PageB ‘u’ field.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top Results From Across the Web
D3.js - Log scale starting at zero - Stack Overflow
I am plotting a y axis which should be defined in log scale. The range is from 0 to 1000. If I try,...
Read more >d3.scale.log(), 0 in domain · Issue #1420 - GitHub
This concerns d3.scale.log() with a value of zero in the domain. When the input domain contain 0 the javascipt-engine will crash, due to...
Read more >how to set y-axis as log scale? - MATLAB Answers
I used loglog function but it scales both axis but I want only Y. 0 Comments.
Read more >pandas.DataFrame.plot — pandas 0.22.0 documentation
In case subplots=True, share x axis and set some x axis labels to invisible; defaults to True if ax is None otherwise False...
Read more >Logarithmic scale - Wikipedia
A logarithmic scale (or log scale) is a way of displaying numerical data over a very wide range of values in a compact...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
log(0) being infinity is not a valid argument, as displaying a data in log scale is not logging the values, but the scale itself. I.e. such that the points of your graph are spaced out differently and especially differences in the smaller values are more pronounced. Forgive the drawing
That probably might be helpful as ‘pseudo-log’ solution