Tables
A table
provides a concise way to specify both a grouping and a layout.
Rather than first grouping data, and then applying a cartesian layout to these groups, a user directly specifies
a rowOrder
and colOrder
, which implicitly defines a grouping and a cartesian/grid layout.
This is useful for applications such as rendering an adjacency matrix, or for faceting a dataset into small multiples.
API Reference
Attribute | Type | Description |
---|---|---|
name | string | The name of the table (mandatory, for implementation reasons). |
rowOrder | OrderingCriterion | Ordering for the rows. |
colOrder | OrderingCriterion | Ordering for the columns. |
data | string | Name of the data array from which this table should be constructed. |
group? | string | Name of group. This is generally not needed, as the required grouping can be identified from the row and column orderings. However, this enables users to provide a group that has been subsequently modified by a transformation. |
rowLabels? | LabelSpec | Specification for row labels. |
colLabels? | LabelSpec | Specification for column labels. |
dragToReorder? | boolean | If true, dragging the row/column labels will update the underlying order. |
symmetric? | boolean | If true, then every value that appears as a row will also appear as a column (even if every cell in that column is empty), and vice-versa. This is useful for adjacency matrices of directed networks, as source/sink nodes may otherwise appear only as rows or columns. |
The OrderingCriterion
is either:
Attribute | Type | Description |
---|---|---|
order | string | The name of the order to apply. |
field | string | The name of the field containing the ids that the layout maps to positions. |
or
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" | The direction to sort in. |
A LabelSpec
is:
Attribute | Type | Description |
---|---|---|
field | string | The field to use as the source of label text, from the keys of the table group (most of the time the nodes) |
width? | number | Space (in pixels) to allow for labels. |
Other properties valid for a Vega text mark can also be assigned. |