Click2Buy / vue-pivot-table

A vue component for pivot table
MIT License
225 stars 71 forks source link

aggregate by row possible? #9

Open navjeetc opened 5 years ago

navjeetc commented 5 years ago

Is it possible to show aggregated numbers when you have two values in rows. e.g. if the rows have occupation (Doctor, Engineer) and Person Name, can I get total number of people in each occupation. Right now with reducer impl of reducer: (sum, item) => sum + 1, it displays like

blank header blank header blank header
John Doe 1
Engineer John Smith 1
Mike Smith 1
Doctor John Paul 1
Mike Paul 1

But I want to also display total number for Engineer - 3 and and Doctor - 2

antoinematyja commented 5 years ago

In your example, totals by Occupation can be displayed by removing the Person Name column, but it implies changing the columns settings, and you want to have the 2 numbers at the same time.

We could imagine adding a boolean to the Occupation column settings, something like displayTotal which would add a row for each Occupation with its total.

In the case of the demo of this app (country/gender/year), with displayTotal on "country" this would give this : image

Quite a headache to build colspans/rowspans but it seems possible. But it's a lot of work, and this is not my top priority.

rczupa commented 4 years ago

Hi Antoinematyja how are you ? Can I fork your project to increase new features ? I need the possibility to use more than one different algoritm of aggregators and this totalizer discussed in here.

After that, if you want, we can merge the solution.

Thanks.

antoinematyja commented 4 years ago

Hi 🙂 Sure.

I'm currently working on new features to add more customization to the headers. The API for the PivotTable component will change a bit (especially the fields definition), but it should not be incompatible with the features you want to work on.

Thanks for your interest