flekschas/piling.js

GroupBy spliting between groupings

Opened this issue · 4 comments

Hello,
I am trying to change the groupings of Scatterplots, but it is always necessary to use spiltAll() in between the groupings to get the result I would expect. Is this intended or a bug?

Observed behavior

Similarly also in the Global Surface Temperature Ridge Plots (SVG)
the following use case can be found:

Steps to reproduce

  1. In the Arrangement section we choose index and Update arrangement on grouping
  2. In the Group By section We click Group while having decade selected.
  3. We select month instead of decade and press Group again
    (if we keep repeating steps 2 and 3 no changes occur anymore)

This leads to a different outcome than if we do the following.

  1. In the Arrangement section we choose index and Update arrangement on grouping
  2. In the Group By section We click Group while having decade selected.
  3. We click on the Split All Button
  4. We select month instead of decade and press Group

A video of the behaviour in the mentioned example:

2021-06-02.11-27-48.mp4

Similar problem in our Project where we change the cluster numbers but only the correct clusters are shown after pressing a button to perform a SplitAll()

2021-06-02.11-23-44.mp4

Thank you for any help or comments :)

Apologies for me belated reply. I am currently out of the office but will get back to you next Tuesday. If I forget please add a comment or ping me.

What you describe is the expected behavior. The groupBy call acts on the current rather than the initial pile state. In your scenario this is what happens:

  1. First, you group all scatter plots by decade. This results in 14 piles (1880s to 2010s).
  2. Next, when you click on group by month, then what you're telling piling.js that it should try to group these 14 piles by their month. Now what happens in this case is that piling.js tries to find piles that have the same month and group them. The way it's doing that is is by going through every pile and aggregating the items' month property into a single value. By default in the case of categorical grouping, is that the month values are simply concatenated into a string. Finally, piling.js is grouping all piles with the same string value. In this example, all 14 piles contain items with the very same months so all 14 piles are being grouped.

What you want to achieve is essentially what you're doing. Instead of grouping the 14 piles you want to group the original piles (that consisted of only one item per pile). So in that case you first need to split all the tiles and then have to repile them.

I assume you're building your own kind of visual piling interface. In that case I would create a new UI element which combines the splitAll() and groupBy() calls. Unfortunately, I never got around adding an option to groupBy to internally split piles before grouping them.

Does this help?

Thank you for your answer!
Yes, this explains our observed behaviour. We will look into a workaround to achieve our desired use case :)
Thank you again!

I am reopening the issue because I think your requested behavior should be available.

For now, you could create another callback function that looks as follows

async function groupByCategory(category) {
  await piling.splitAll();
  piling.groupBy('category', category);
}

In the future, I imagine the groupBy() to accept an option property splitBeforeGrouping to avoid showing the unnecessary split animation. E.g.:

piling.groupBy('category', 'month', { splitBeforeGrouping: true });

Internally, when splitBeforeGrouping is true, piling should first execute the split operation and immediately after that trigger the grouping call.