mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.38k stars 1.3k forks source link

[DataGrid] Transpose columns into rows #3285

Open jasonsturges opened 2 years ago

jasonsturges commented 2 years ago

Duplicates

Latest version

Summary 💡

Feature request to transpose the grid - reverse columns and rows.

Similar to pivot tables in #214, but just a matrix transform operation.

Changing from this:

Header 1 Header 2
A 1 B 1
A 2 B 2

...into this:

Header 1 A 1 A 2
Header 2 B 1 B 2

Examples 🌈

Spreadsheets such as Microsoft Excel have a similar notion of transposing columns into rows, such as here or here

image

image

Motivation 🔦

Stems from a discussion in #3282 where I hoped to use editable data grids for property panels, such as in Unity:

image

Order ID 💳 (optional)

No response

m4theushw commented 2 years ago

Looking at the example you gave from Unity, couldn't your consider the param name as a column and the value as another column? It's basically reshaping the data to be rendered in a grid. The only thing missing is the ability to hide the headers.

jasonsturges commented 2 years ago

@m4theushw Yes, I originally convoluted this together in #3282, but cleaned that issue up to isolate hiding headers.

Here, I was thinking either:

But you're right, this could be a two-column key / value pair grid - logic for that might be a bit more obtuse to handle, as there seemed to be an elegance if the data model was expressed via Data Grid columns.

If this feature request of transposing columns to rows, or introducing row headers doesn't resonate with the roadmap of Material UI Data Grids, I'll understand - this might simply be outside the intended usage here.

m4theushw commented 2 years ago

It's not in our roadmap, at least for now. I added the "waiting for 👍" label so other users with the same pain can upvote and we know if we should allocate time for it. The possibility of hiding the column headers is something we need to address.

aimad-majdou commented 1 year ago

Hello, any updates on this ?

davidnir1 commented 10 months ago

Hello, Was there any progress made on this? Our users are driving us crazy asking for this :)

cherniavskii commented 9 months ago

Hey @aimad-majdou @davidnir1, Could you please provide more details on your use case? What is your data format and why would you want to transpose it? Also, you might want to take a look at the pivoting issue https://github.com/mui/mui-x/issues/214 - maybe this is what you're looking for? Thanks!

shahamran commented 6 months ago

Hi @cherniavskii, I can share my use case if it helps.

I have data with much more "columns" (headers) than "rows" (data points). Also, the header text can be quite long. Since text is arbitrarily wide, but only as high as the font size, it's more efficient (in terms of information density) to stack the headers vertically.

Consider this table:

my very long column 1 my very long column 2 my very long column 3 ... my very long column N
0 1 2 ... N

this takes a lot of horizontal space, and will quickly need a scrollbar. But in this table:

my very long column 1 1
my very long column 2 2
... ...
my very long column N N

the same information is displayed in a much more compact form. This remains true as long as there aren't many data points (in which case horizontal scrolling feels unnatural).

Hope this is clear :)

Also, I'm open for alternative ideas.

jasonsturges commented 6 months ago

Still interested in this - most simple example: pivot a column into a row in database query:

pivot

stevstrong commented 6 months ago

https://github.com/mui/mui-x/issues/3285#issuecomment-984855059

Looking at the example you gave from Unity, couldn't your consider the param name as a column and the value as another column? It's basically reshaping the data to be rendered in a grid.

@m4theushw or anyone else I would really appreciate if you could give an example how to implement that. Thanks in advance.

MaximeDauphinot commented 2 months ago

Hello, any news on it ? it would be awesome to possibly do this