question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

YAxis domain throws exception "[DecimalError] Invalid argument: NaN"

See original GitHub issue

Setting YAxisdomain property throws the following exception: Uncaught Error: [DecimalError] Invalid argument: NaN at new Decimal (decimal.js:1876) at getTickValuesFixedDomainFn (getNiceTickValues.js:303) at utils.js:146 at getTicksOfScale (ChartUtils.js:880) at CartesianUtils.js:69 at Array.reduce (<anonymous>) at formatAxisMap (CartesianUtils.js:40) at generateCategoricalChart.js:1429 at Array.forEach (<anonymous>) at CategoricalChartWrapper.updateStateOfAxisMapsOffsetAndStackGroups (generateCategoricalChart.js:1428)

The exception isn’t thrown when setting YAxisdomain to [0, ‘auto’]. The exception isn’t thrown when using XAxis. Every other domain fails ([0, 100], [0, ‘dataMax’], [0, ‘dataMax - 100’]).

Here’s the code: <AreaChart width={1780} height={433} data={data}> <CartesianGrid strokeWidth={0.2} vertical={false}/> <YAxis tick={{fill: '#474a57'}} axisLine={false} interval="preserveStartEnd" tickCount={11} domain={[0, 100]} tickSize={0} /> <Area strokeWidth={1.5} type="linear" dataKey="key1" stroke={"url(#stroke1)"} fill={"url(#fill1)"} /> <Area strokeWidth={1.5} type="linear" dataKey="key2" stroke={"url(#stroke2)"} fill={"url(#fill2)"} /> </AreaChart>

I’ve encountered the same exception on recharts versions 1.4.1 and 1.6.0 on Google Chrome.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
Haschtlcommented, Jul 18, 2021

I figured out that this is still an issue, if the data-object is an empty list. Then the YAxis domain callbacks return -infinite, which results in the DecimalError. I fixed it like this:

  <YAxis
    type="number"
    yAxisId={1}
    tickFormatter={(value: number) => {
      return value.toPrecision(4);
    }}
    domain={[
      (min: number) => {
        if (isFinite(min)) {
          return min - Math.abs(0.1 * min);
        } else {
          return 0;
        }
      },
      (max: number) => {
        if (isFinite(max)) {
          return max + Math.abs(0.1 * max);
        } else {
          return 1;
        }
      },
    ]}
  />
2reactions
imjustdcommented, May 16, 2019

Finally downgraded to v1.4.4 to make it work like before, so null/undefined values are not drawn, while other lines on the charts are displayed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the meaning of "Invalid Argument" and what causes ...
In IE8, if you set a bad value on a style property, you get an "Invalid argument" error. I'm guessing xPos contains either...
Read more >
recharts - UNPKG
src/cartesian/YAxis.js","webpack://Recharts/./src/util/Events.js","webpack://Recharts/./src/chart/generateCategoricalChart.js","webpack://Recharts/.
Read more >
Time Series Forecasting In Python | R - Analytics Vidhya
Complete guide to Time series forecasting in python and R. Learn Time series forecasting by checking stationarity, dickey-fuller test and ...
Read more >
Posit Arithmetic - Posithub.org
continue computing, what float arithmetic calls "Quiet NaN. ... to be processed to completion and the cases that throw an exception can.
Read more >
Incident Response - Hybrid Analysis
AV Detection: Marked as clean Link Twitter E-Mail. https://ciencecom.salesloftlinks.com/t/311/c/90e20579-4136-45bf-973a-40585b7beeec/ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found