Giter Club home page Giter Club logo

Comments (7)

SiddharthMantri avatar SiddharthMantri commented on May 21, 2024

I've noticed this error happening especially when the window is resized or similar changes to the container element take place. Working on a PR.

from react-charts.

tcosentino avatar tcosentino commented on May 21, 2024

I am running into this now when putting my chart inside of a @reach/tabs component. @SiddharthMantri did you have any luck on resolving? I am going to be diving into this today and figured I'd check

from react-charts.

bspai avatar bspai commented on May 21, 2024

Hi All, Any updates on this? I am facing this error on codesandbox. For the first render it plots properly. But any updates on any files, which result in re render on codesandbox, will result in this error.
https://codesandbox.io/s/react-charts-line-cvpt2

from react-charts.

gagregrog avatar gagregrog commented on May 21, 2024

I'm using a bar chart inside of a resizable box as is shown in the demos.

I've noticed that this error occurs when resizing the element, but particularly when the angle of the horizontal axis labels changes. When the chart is sized so that the labels are initially skewed, you can resize the element without problems as long as the labels remain skewed. As soon as the component becomes wide enough to display the labels horizontally, the maximum call depth error appears.

What has me stumped is that this same label behavior as shown in the chart demo does not cause the error.

Has anyone had any luck sorting out the source of this?

from react-charts.

Chris7 avatar Chris7 commented on May 21, 2024

From my testing, this appears to be related to the number of elements being shown. If I show a limited number of elements, the chart works properly, but then if I update it with a longer list of items, the recursion error appears.

Here's my component:

function StateOverTimeChart({ data, timeInterval }) {
  const grouping = 1000 * timeInterval;

  const series = React.useMemo(
    () => ({
      type: "bar"
    }),
    []
  );

  const chartData = React.useMemo(
    () =>
      _.map(
        _.groupBy(data, item => `${item.JobDefinition}-${item.State}`),
        (jobData, definition) => ({
          label: definition,
          // Due to a bug with react-charts https://github.com/tannerlinsley/react-charts/issues/61 we need to limit
          // the data we are displaying.
          data: _.takeRight(
            _.sortBy(
              _.map(
                _.groupBy(
                  jobData,
                  item => Math.floor(item.CreatedOn / grouping) * grouping
                ),

                (data, grouping) => ({
                  primary: new Date(_.toInteger(grouping)).toLocaleString(),
                  secondary: data.length
                })
              ),
              "primary"
            ),
            40
          )
        })
      ),
    [data, grouping]
  );

  const axes = React.useMemo(
    () => [
      { primary: true, type: "ordinal", position: "bottom" },
      { type: "linear", position: "left", stacked: true }
    ],
    []
  );

  return (
    <div
      style={{
        width: "100%",
        height: "300px"
      }}
    >
      <Chart data={chartData} series={series} axes={axes} tooltip />
    </div>
  );
}

Curiously, changing primary: new Date(_.toInteger(grouping)).toLocaleString(), to primary: _.toInteger(grouping), causes the recursion error to stop as well

from react-charts.

florpor avatar florpor commented on May 21, 2024

seems like this has to do with label rotation on ordinal axes.
setting maxLabelRotation to 0 mitigates this issue for me (at the expense of overlapping labels if showing many categories without enough space to expand):

	{ primary: true, type: 'ordinal', position: 'bottom', maxLabelRotation: 0 },
	{ position: 'left', type: 'linear', stacked: true }

from react-charts.

tannerlinsley avatar tannerlinsley commented on May 21, 2024

Due to a massive overhaul and rewrite of React Charts to TypeScript and a massively upgraded public API, this issue is being bulk closed for triage. The latest version can be tested via the react-charts@beta tag. Documentation is in the process of being upgraded, but thankfully, everything is fully typed now, so you can explore the API that way for now.

If, after testing or playing with the v3 beta, you believe your issue is still not addressed or relevant, feel free to open a new issue.

from react-charts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.