finos / perspective

A data visualization and analytics component, especially well-suited for large and/or streaming datasets.
https://perspective.finos.org/
Apache License 2.0
7.72k stars 1.04k forks source link

Show non-aggregate rows under aggregate group rows #2636

Closed brettsaunders21 closed 2 weeks ago

brettsaunders21 commented 2 weeks ago

Feature Request

Description of Problem:

All of our use cases involve us showing data visually grouped by x columns, but under each group with have all the rows for that group under them. Instead of it just being aggregates.

Similar to this:

image

Which can be achieved with the following config: But obviously not completely what we want as the aggregate rows.. have no aggregate values. Just a workaround to get close

Perspective JSON Example Config Using the "editable" example on the docs ```json { "version": "2.10.0", "plugin": "Datagrid", "plugin_config": { "columns": {}, "editable": true, "scroll_lock": false }, "columns_config": {}, "settings": true, "theme": "Pro Light", "title": null, "group_by": [ "State", "City", "Row ID" ], "split_by": [], "columns": [ "Row ID", "Order ID", "Order Date", "Ship Date", "Ship Mode", "Customer ID", "Customer Name", "Segment", "Country", "City", "State", "Postal Code", "Region", "Product ID", "Category", "Sub-Category", "Product Name", "Sales", "Quantity", "Discount", "Profit" ], "filter": [], "sort": [], "expressions": {}, "aggregates": { "Row ID": "unique", "Order ID": "unique", "Customer ID": "unique", "Country": "unique", "Sales": "unique", "Profit": "unique", "Sub-Category": "unique", "Ship Mode": "unique", "Category": "unique", "Product Name": "unique", "Postal Code": "unique", "Quantity": "unique", "Order Date": "unique", "Segment": "unique", "Customer Name": "unique", "Discount": "unique", "State": "unique", "Product ID": "unique", "City": "unique", "Region": "unique", "Ship Date": "unique" } } ```

Although we plan to only using the backend perspective package and do the rendering ourself:

image

Currently the only way to get the others rows to appear is group by a column like "Row ID" last which is a unique field for every row and set the aggregate to "unique" (or first, or any... but we found unique to calculate the fastest). This as you can guess leads to slow processing times as it's trying to calculate every row like it's a group with an aggregate on.

It would be nice to have the current group behaviour, but an option to show "non-agragate rows" under the aggregate rows. Speeding this up and also allowing us to have the aggregate rows actually show values like "sum" or anything else instead of being blank

Potential Solutions:

An option to render normal rows under aggregate rows.

This is a feature we really need to make this viable to use, as we use group by like this in all our use cases. Our users like to see the values that made up the aggregates, but unfortunately I don't know your code base well enough to contribute it or what an appropriate format for the configuration of this to be in.

texodus commented 2 weeks ago

All of our use cases involve us showing data visually grouped by x columns, but under each group with have all the rows for that group under them. Instead of it just being aggregates.

Although we plan to only using the backend perspective package and do the rendering ourself:

If you don't want aggregates, the datagrid, etc, Perspective is the wrong tool for the job. Maybe try Object.groupBy()?

[edit] Closed this a little early, some more context. The best way to get the underlying rows in a pivot is with a master/detail view like so:

https://github.com/finos/perspective/assets/60666/dc2f8973-754e-478a-af19-06371a99184c

While Perspective may add underlying rows to the Datagrid in the future, it's not going to involve engine changes to do so, we'll use the existing API (as the master detail view above already does) to extract the rows as you scroll. E.g., this feature will be of no use for writing your own frontend, the engine API will not change.