"sort fy by x" bug
This branch is trying to fix the following issue:
When we have "sort fy by x" and a transform, the series are not indexed properly. The channel to sort (XV, in this case fy) is indexed by the original data, and the channel by which to sort (YV, in this case x) is indexed by the transformed (grouped) data.
It can be solved, in the case of this unit test, by grouping data by series:
const XV = x === "fy" || x === "fx" ? [...new Set(X[1].value)] : X[1].value;
However this is not a proper fix, since it should apply only when data is indeed grouped this way. We have to understand how the data is reindexed, or alternatively we have to make the facet information follow along with the grouping.
Note: the broken test is the expected chart, but we can't achieve it yet without breaking a few others:
cc: @enjalot
Forgot to mention that a solution is to avoid doing the transform, and use e.g.:
Plot.dotX(agediff, {
x: "age_difference",
stroke: null, // don't display any mark
sort: {fy: "x", reduce: "median"}
}),
(so maybe the bug can be solved by warning that there is a mismatch?)
I’m having difficulty following this issue. 🤯
I think this is only a bug with the facet channels, right? Normal channels should be transformed consistently; it’s just the facet channels that don’t respect the transforms. I made the same mistake at first in #1304 and fixed it in 41aad8056ebb737f0fade5e028e025ce5b4a4b48. There’s probably some similar special logic we need here to handle the facet channels when there is a transform (reconstructing them from index.fx and index.fy).