Skip to main content

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

AttributeTypeDescription
namestringThe name of the table (mandatory, for implementation reasons).
rowOrderOrderingCriterionOrdering for the rows.
colOrderOrderingCriterionOrdering for the columns.
datastringName of the data array from which this table should be constructed.
group?stringName 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?LabelSpecSpecification for row labels.
colLabels?LabelSpecSpecification for column labels.
dragToReorder?booleanIf true, dragging the row/column labels will update the underlying order.
symmetric?booleanIf 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:

AttributeTypeDescription
orderstringThe name of the order to apply.
fieldstringThe name of the field containing the ids that the layout maps to positions.

or

AttributeTypeDescription
fieldstring 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:

AttributeTypeDescription
fieldstringThe field to use as the source of label text, from the keys of the table group (most of the time the nodes)
width?numberSpace (in pixels) to allow for labels.
Other properties valid for a Vega text mark can also be assigned.