Orderings
An ordering is a mapping from elements of a data aray to natural numbers.
Orderings are important because they can control how data is positioned by attribute-based layouts.
There are two main types of orderings:
- attribute-based orderings are defined by the attributes of data elements directly
- seriation-based orderings are obtained by trying to trying to permuate the rows or columns of a matrix in such a way that reveals structure which would otherwise be hidden
Seriation-based orderings are obtained using the Reorder.js library (GitHub, npm)
An ordering specification has the following parameters:
| Attribute | Type | Description |
|---|---|---|
| name | string | The name that will be given to the ordering when it is created. |
| data | string | The name that will be given to the ordering when it is created |
| allowTies? | boolean | If allowTies is true, then two items for which the ordering criterion are equal will be assigned the same rank.If allowTies is false, then every item will be assigned a distinct rank. |
| orderBy | OrderingCriterion[] or OrderingCriterion | The criterion that will be used when ordering items. |
An OrderingCriterion is either an OrderingCriterionAttribute or an OrderingCriterionSeriation.
Attribute-based orderings
An OrderingCriterionAttribute is either a string specifying the name of the attribute to be used, an OrderingCriterionExpression or an OrderingCriterionField.
OrderingCriterionExpression:
| Attribute | Type | Description |
|---|---|---|
| expression | string | This expression will be evaluated for each item, and the items will be sorted based on these calculated values. The expression can access an item as datum. |
| direction? | "ascending" or "descending" | Which direction to sort in. |
| fn | any | This expression will be evaluated for each item, and the items will be sorted based on these calculated values.Whether to sort in ascending or descending order. |
OrderingCriterionField:
| Attribute | Type | Description |
|---|---|---|
| field | string or string[] | The name of a field (or list of names of fields) to sort on. |
| direction? | "ascending" or "descending" | Which direction to sort in. |
| fn | any | This expression will be evaluated for each item, and the items will be sorted based on these calculated values.Whether to sort in ascending or descending order. |
Seriation-based orderings
OrderingCriterionSeriation:
| Attribute | Type | Description |
|---|---|---|
| method | SeriationAlgorithmName | The name of the seriation method. |
| weightField? | string | The name of a field containing edge weights. |
| distance? | Distances | The name of the distance function to use. |
The method can be one of optimal-leaf-order, barycentre, bandwidth-reduction, or pca.
The distance can be one of euclidean, manhattan, minkowski, chebyshev, hamming, jaccard, braycurtis.