I'm trying to sort ordinal data on the x axis by a different field from the one I'm using as a label. Both fields (I'll call them 'sortable' and 'nonsortable') are one-to-one, meaning one is computed from the other and there will never be an instance when one 'sortable' value will correspond to two different 'nonsortable' values, and vice versa.
I tried two approaches:
- Changing the sort order to use a different field like this:
...
x: {
field: 'nonsortable',
sort: {
field: 'sortable',
op: 'count',
},
},
...
I wasn't sure which aggregate operation to use, but since the two fields are one-to-one, that shouldn't matter right?
This changed the order in a way that I don't understand, but it certainly didn't sort the axis by the 'sortable' field as intended.
- Changing the label to a different field like this:
...
x: {
field: 'sortable',
axis: {
labelExpr: 'datum.nonsortable',
},
}
...
This didn't work at all. I think maybe I misunderstood how the label expressions work.
Is there another way to do this, or maybe a way salvage one of these attempts?