Giter Site home page Giter Site logo

Row Grouping & Aggregation about table HOT 9 CLOSED

tannerlinsley avatar tannerlinsley commented on September 28, 2024
Row Grouping & Aggregation

from table.

Comments (9)

lukaswelinder avatar lukaswelinder commented on September 28, 2024

I'm vetting table components for work and this is one of our key requirements. I like what you have going, so let me review the source over the weekend to assess the scope.

If you could recommend where to look first, that would help a lot. Thanks.

from table.

tannerlinsley avatar tannerlinsley commented on September 28, 2024

from table.

tannerlinsley avatar tannerlinsley commented on September 28, 2024

Adding row grouping and aggregation will likely need several additions and edits throughout the entire core. These are some of the requirements/ideas I have in mind out of the gate:

  • Row Groups should be infinitely nestable?
  • Grouping needs to run pre-sort
  • Grouping is achieved using same column mechanics eg. using a string fieldName, or callback d => d.fieldName
  • When the bottom level of a grouping is reached, sorting needs to run inside that grouping level (this way sub-items are sorted when exanded), then sorting can work its way up to the parent level of the data using any aggregated data from the group to sort
  • Aggregation happens after grouping
  • Default and type-aware aggregations
  • Utilize built-in aggregations via string or imported const eg. RowAggregation.avg
  • Aggregation callbacks on columns to customize any column
  • Pagination should respect sub-rows
  • State will need to be manageable both internally and externally (I think the best way to do this is by using reserved keys on the actual rows of data as opposed to mapped metadata). This will probably make it much easier to handle infinitely grouped rows.
  • If a row is expanded, its child rows will be inserted after it, at the same dom depth, but with a className to denote its nesting level
  • That className should be configurable just like everything else
  • When there are any row groups in a table whatsoever, a column will need to be generated at the beginning of each row to control expansion (probably an html arrow out of the box). This column should be completely optional, and should use an internal api that would be available to use in any normal table cell (dogfood that shiz). This way, if someone wants to build their own grouping controls, they can do whatever the heck they want, however they want to do it.
  • The grouping model should be transmitted with onChange events. This way: sorting, pagination, and now grouping can all be controlled easily serverside.
  • Groupings callbacks will work by returning any unique primitive value (uniqueness will only be detected using a single level equality check, so don't return arrays or objects)
  • The grouping model will need to be an array of objects, so it can support names and id's for the groupings. Similarly to sorting, if a grouping uses a custom callback, it will need an ID that it can be sent serverside (since functions cannot).

Thoughts?

from table.

lukaswelinder avatar lukaswelinder commented on September 28, 2024

@tannerlinsley Sorry for the delay, been quite busy.

Awesome list, thanks for taking the time to put that together. I think the infinite nesting makes it much more challenging to implement, but its usefulness outweighs that.

The operation order (grouping then sorting) is a good idea, especially for performance on massive lists. Do you imagine the sorting controls on the group or globally on the table head?

Pagination should respect sub-rows.

Not sure I follow what you mean by this. Do you mean that pagination of collapsed groups counts rows and not groups? ie: 3 groups w/ 30 items, 10/page would show a single group per page? I do see the challenge here thought...

State will need to be manageable both internally and externally (I think the best way to do this is by using reserved keys on the actual rows of data as opposed to mapped metadata).

By actual rows do you mean key or ref on the components, or are you talking about references to the original objects?

The grouping model should be transmitted with onChange events.

I think this is a great idea. Also, regarding this and the above snippet, should there be a way to disabled or prevent internal state (make it a fully controlled component)?

This and next week I will be diving into working with the library; our initial implementation doesn't require anything fancy, so it'll give me a chance to get a feel for when you already have in place.

I'll circle back early January with more detailed thoughts and feedback.

from table.

tannerlinsley avatar tannerlinsley commented on September 28, 2024

This is going to become a higher priority for me very soon. I plan on hopefully having support for this out by the end of February.

I think the best option for now is to assume a like-schema for sub-rows and implement what we have discussed in previous comments to achieve this.

I'll comment again when I begin to work on this if anyone is interested in collaborating on the effort.

:)

from table.

tannerlinsley avatar tannerlinsley commented on September 28, 2024

Just released 4.0.0 which was a big overhaul of the display logic and styling. Everything is flexbox now, which should lay a lot of the groundwork for what we're talking about here.

Along with those styling upgrades, a new subComponent prop allows you to utilize each rows data and return any custom react component of your choosing. You can see it in action here

This is merely a simple proof of concept of how we could implement pivoting and row-grouping in a serious manner. But we also get another win here. Let me explain:

If you're data already contains aggregated rows and drill through data, you can easily pass nested Tables without having to do any aggregation at all. You could even utilize subComponents for charting, large-format meta-data or other types of drill-through.

I'll be working on the actual pivoting and grouping logic in the weeks to come.

from table.

tannerlinsley avatar tannerlinsley commented on September 28, 2024

Implemented with 8fa7975! Huzzah!

from table.

lukaswelinder avatar lukaswelinder commented on September 28, 2024

Congrats on the release @tannerlinsley, great job on the implementation.

Wish I could have lended a hand; things have just been a little too busy lately 😬

from table.

tannerlinsley avatar tannerlinsley commented on September 28, 2024

from table.

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.