Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple values/aggregator #16

Closed
Dams591 opened this issue Nov 14, 2016 · 25 comments
Closed

Multiple values/aggregator #16

Dams591 opened this issue Nov 14, 2016 · 25 comments

Comments

@Dams591
Copy link

Dams591 commented Nov 14, 2016

Hi there,

Thanks for the amazing work you've added on top of pivottable.
I really like the ability to expand/collapse this awesome.

One of the thing I'm trying to add to your extension is the ability to have multiple values/aggregator.
I was using the method described there:
nicolaskruchten/pivottable#30

Full like to fork:
https://github.com/unk1911/pivottable-multi-field-aggregator/tree/master

Here's also a fiddle that show multiple values in action
https://jsfiddle.net/dL86h8xr/

They added their own renderer which I changed a little bit to fit my needs.
But now I'm having a tough time to implement this in your renderer.

Have you ever thought of adding this features ? Any idea how I can implement it quickly ?

Thanks,
Damien

@nagarajanchinnasamy
Copy link
Owner

Hi, Thanks :)

I could not get the example of pivottable-multi-field-aggregator project or the fiddle. Could you please post some screenshots so that I understand your requirement well.

@Dams591
Copy link
Author

Dams591 commented Nov 17, 2016

Hey !

There you go.
The main goal is to have multiple values per column.
Like you can see here we have only one column 'Okres' and for each of them we have 4 values : "IleOper, MK_Saldo, MO_Saldo, MS_Saldo"
I've already started to modified your rendered but I have to say it's not easy and I'm still far away from the expected result.

image

Let me know if there is a quick way to implemement that.

@Dams591
Copy link
Author

Dams591 commented Nov 17, 2016

Here's another github link describing the use of MfSum And MfTableRenderer
nicolaskruchten/pivottable#30

@nagarajanchinnasamy
Copy link
Owner

Thanks :)

Got it. What if there are vals in both rows and columns?

Please give me some time to think through and respond as early as possible.

@nagarajanchinnasamy
Copy link
Owner

Sorry about the stupid question: "What if there are vals in ....." :)

@Dams591
Copy link
Author

Dams591 commented Nov 18, 2016

I have something working but I'm not too proud of my code :p Most likely on buildRowHeaderHeaders i'm looping on valueKeys which contains the name of all my values columns (Cost, Sales) In buildValues same thing, but instead of calling aggregator.val() I call aggregator.multivalue() which return one property per value. Same technic is used inside buildTotals and buildGrandTotal. I also changed some colspans/rowspans to fit the number of values.
Like I said the code is not the cleanest yet but if anyone is interested let me know I'll post it.

Here's a small preview. I did change a little the default style. I Aslo updated your code to be able to use font awesome icons for collapse/expand, enable or disable expand/collapse.

image

@nagarajanchinnasamy
Copy link
Owner

Feel free to fork/clone the repository and incorporate your changes in your forked repository.

That will help us to review the changes....

@nagarajanchinnasamy
Copy link
Owner

@Dams591 pls share your code changes...so that i get a better understanding...

@fullstack2
Copy link

@Dams591 - I'm looking for similar feature, Could you please share your code ?

@fullstack2
Copy link

@Dams591 - Could you please share your code ?

@Dams591
Copy link
Author

Dams591 commented Dec 28, 2016

At the moment I can't since its really tight to some other application, I'm doing my best to clean it and share it with you guys.

@fullstack2
Copy link

Thanks @Dams591 , Hoping to see your code soon.

@nagarajanchinnasamy - Any chances of you working on this feature ?

@nagarajanchinnasamy
Copy link
Owner

OK. Let me give it a try over this weekend if possible. Will keep you posted. Thanks for you interest :)

@fullstack2
Copy link

@nagarajanchinnasamy - That would be great ! Thanks in advance !

@nagarajanchinnasamy
Copy link
Owner

I haven't started coding. Still trying to understand the requirement better and arrive at a generic design. But definitely in my to-do list :)

@Dams591
Copy link
Author

Dams591 commented Jan 23, 2017

Hey Guys,

I was able to make a working version for you to study.
Here is my code. Like I mentioned earlier I'm not so prod about it and since I didn't have the time to clean it it is a little bit messy.
I'm currently looking for a way to display/hide subtotals (specially once on expand) and i would appreciate if you could help me towards that.

On the following codpen you will see that I have multiple value per Car Type ( Cost, Profit).

http://codepen.io/anon/pen/YNVbJm?editors=0010

Let me know if there's anything I can help you with.

@nagarajanchinnasamy
Copy link
Owner

@Dams591 Thanks for the code. Will go through it.

Regarding, the way to display/hide subtotals:
pvtColSubtotal and pvtRowSubtotal classes will help you locate the cells related to subtotals. expanded and collapsed classes will help you locate expanded or collapsed subtotal headers. You can find elements using these classes and apply necessary css.

See #20 styling collapsible labels.

@nagarajanchinnasamy
Copy link
Owner

@Dams591 you may also want to refer to #14 Give label for subtotal

@Dams591
Copy link
Author

Dams591 commented Jan 23, 2017

@nagarajanchinnasamy I think using the css class will be enough !! I didn't know you implemented this ! great news ! thanks and let's keep in touch.

@Dams591
Copy link
Author

Dams591 commented Jan 23, 2017

Humm sorry maybe I wasn't clear enough. I did implement the expanded/collapsed classes but it is not going to help me much.

I want to remove whats highlighted in yellow below once the collum is expanded. In fact I want to hide the subtotal value columns when I expand.

expanded/collapsed classes are on country here and theres not much I can do to select/customize what I want

image

And this is unfortunately not as easy as hidding a cell because of the colspans and stuff. Any idea ?
Another thing would be to display the rows subtotals at the end like you did for the columns.

Thanks
Damien

@nagarajanchinnasamy
Copy link
Owner

Understand your problem. Could you please raise a separate issue to resolve hiding subtotals upon expansion.

@Dams591
Copy link
Author

Dams591 commented Jan 24, 2017

Sure. let me close this one in the meantime. Thanks for your help.

@Dams591 Dams591 closed this as completed Jan 24, 2017
@Dams591
Copy link
Author

Dams591 commented Feb 3, 2017

For those who needs multiple values and hiding subtotals here's a way. Sorry I couldn't forked at the time due to other issues http://codepen.io/anon/pen/YNVbJm?editors=0010

@pranjal-goswami
Copy link

Hi!
I have attempted to write a plugin for adding multiple aggregations on different fields and have published them here: https://github.com/pranjal-goswami/multifact-pivottable

Multifact-pivottable

Using this plugin you can :

  • Add multiple aggregations to the same pivottable: AVG(Column A), SUM(Column B)

  • Add derived aggregations :
    -- a = AVG(Column A)
    -- b = SUM(Column B)
    -- [c = b/a] as 'Success Score'

  • Hide an aggregate (in case you want to use the value in derived aggregate but not show it)

  • Hide an aggregate from row-totals section

  • Enhance rendering of aggregations using heatmap or barchart

  • Custom heatmap colors for each aggregation

A demo is available here: http://pranjalgoswami.in/multifact-pivottable/examples/

Will add detailed documentation if people find the plugin useful.
Also, currently subtotals are not supported. But will extend @nagarajanchinnasamy 's work to support that too.

@stephypeter
Copy link

@pranjal-goswami @nagarajanchinnasamy
I have seen both the plugins, both are great for extending pivot table features.
It would be nice if both could be integrated into one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants