nicolaskruchten / pivottable

Open-source Javascript Pivot Table (aka Pivot Grid, Pivot Chart, Cross-Tab) implementation with drag'n'drop.
https://pivottable.js.org/
MIT License
4.36k stars 1.08k forks source link

how to group date values #879

Open zpj61 opened 6 years ago

zpj61 commented 6 years ago

Hi, I have records with date field. How can I group dates by month or year and have the possibility to expand and collapse the groups during visualization? Is it possible? I need something like the image below. By the truth I need only a simple year / month grouping on the horizontal axis.

grid

nicolaskruchten commented 6 years ago

You can group dates by year and/or month with the dateFormat deriver (e.g. https://pivottable.js.org/examples/montreal_2014.html) and you can get expand/collapse behaviour using the Subtotal.js plugin: https://github.com/nagarajanchinnasamy/subtotal

zpj61 commented 6 years ago

Thank you! I have another question: must be columns or rows be declared in the code when derived data is used? I'm loading data as array of arrays, field names in first row, and I like the possibility to pass generic data and retrieve the fields in pivottable giving to the user the possibility to rearrange them. I have only a field with always the same name to be grouped with date values, the other field names are varying form time to time and I would made the things as generic as possible.

nicolaskruchten commented 6 years ago

This should all be possible in principle, but the only way to know is to try!