Giter Site home page Giter Site logo

Comments (4)

FoolHen avatar FoolHen commented on July 26, 2024 1

Seems like there was an issue with the flatten library that addChildNodes is using. It was fixed in version 0.11.1 but infinite-tree is still using the previous version. I was having this issue and updating the dependency increased the performance noticeably. Updated in a PR @cheton

from infinite-tree.

cheton avatar cheton commented on July 26, 2024

The "flatten" and "rowRenderer" functions, especially the "rowRenderer", would use the most CPU time while trying to load a large tree:

https://github.com/cheton/infinite-tree/blob/master/src/infinite-tree.js#L686
https://github.com/cheton/infinite-tree/blob/master/src/infinite-tree.js#L712

// Flatten nodes
this.nodes = flatten(data, { openAllNodes: this.options.autoOpen });

// Update rows
this.rows = this.nodes.map(node => this.options.rowRenderer(node, this.options));

One solution is to render only visible rows, it should be able to significantly reduce the rendering time from 10s to <0.1s.

Another workaround is to use lazy loading, you can load first batch of top-level nodes (e.g. 1000 top-level nodes in one batch) at the first time, when you scroll to the bottom, then call tree.addChildNodes(nodes) to load another batch of top-level nodes.

from infinite-tree.

bharatpatil avatar bharatpatil commented on July 26, 2024

I guess if already flattened list is provided to loadData() then it would solve problem for 1st line.

from infinite-tree.

kinow avatar kinow commented on July 26, 2024

I guess if already flattened list is provided to loadData() then it would solve problem for 1st line.

+1 We are working a similar idea. At the moment we are adding InfiniteTree to a Vue component. We had a component implemented with recursion, and some Vue components that would create their children components on the fly. Which would cause style reflows, event bubbling, and be hard to render when you had ~thousands of nodes.

With the InfiniteTree, the performance is already better. But our GraphQL data is flatten already. We thought we would be able to use it, but in the end had to keep the hierarchical data, and pass if to the new component.

We now want to investigate if it would be possible to skip the step where the flatten data is created. I already know it is possible to create an empty InfiniteTree by not giving it any data in the constructor. If there is a nice way to tell it to load the flatten data, I think this issue will be solved, and the component will be even faster.

from infinite-tree.

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.