Header
Edit this pageHeaders provide a title and labels for faceted plots. A header’s title describes the field that is used to facet the plot, while a header’s labels describe that field’s value for each subplot.
By default, Vega-Lite automatically creates headers with default properties for row
and column
channels of a faceted view. User can set the header
property of row- or column-field definition to an object to customize header properties.
In addition to the header
property of a row- or column-field definition, users can also set default header properties for all headers with the configuration object’s (config
) header configuration (config: {header: {...}}
).
Documentation Overview
Header Properties
// A Single View or a Layer Specification
{
...,
"mark/layer": ...,
"encoding": {
"row": {
"field": ...,
"type": ...,
"header": {...}, // Header
...
},
"x": ...,
"y": ...,
...
}
}
// A Facet Specification
{
...,
"facet": {
"row/column": {
"field": ...,
"type": ...,
"header": {...}, // Header
...
},
...
},
"spec": ...
}
To customize header, a header
definiton in row- or column-field definitions can contain the following groups of properties:
General
Property | Type | Description |
---|---|---|
title | String | Null |
A title for the field. If Default value: derived from the field’s name and transformation function ( Notes: 1) You can customize the default field title format by providing the 2) If both field definition’s |
See also: You may also use guide-title
and guide-label
style configs to customize common styles for axis, legend, and header labels and titles.
Labels
Property | Type | Description |
---|---|---|
format | String |
The text formatting pattern for labels of guides (axes, legends, headers) and text marks.
See the format documentation for more examples. Default value: Derived from numberFormat config for number format and from timeFormat config for time format. |
formatType | String |
The format type for labels ( Default value:
|
labelAlign | String |
Horizontal text alignment of header labels. |
labelAnchor | TitleAnchor |
The anchor position for placing the labels. One of |
labelAngle | Number |
The rotation angle of the header labels. Default value: |
labelColor | Color |
The color of the header label, can be in hex color code or regular color name. |
labelFont | String |
The font of the header label. |
labelFontSize | Number |
The font size of the header label, in pixels. |
labelFontStyle | FontStyle |
The font style of the header label. |
labelLimit | Number |
The maximum length of the header label in pixels. The text value will be automatically truncated if the rendered size exceeds the limit. Default value: |
labelOrient | String |
The orientation of the header label. One of |
labelPadding | Number |
The padding, in pixel, between facet header’s label and the plot. Default value: |
Title
Property | Type | Description |
---|---|---|
titleAlign | String |
Horizontal text alignment (to the anchor) of header titles. |
titleAnchor | TitleAnchor |
The anchor position for placing the title. One of |
titleAngle | Number |
The rotation angle of the header title. Default value: |
titleBaseline | String |
Vertical text baseline for the header title. One of Default value: |
titleColor | Color |
Color of the header title, can be in hex color code or regular color name. |
titleFont | String |
Font of the header title. (e.g., |
titleFontWeight | String | Number |
Font weight of the header title.
This can be either a string (e.g |
titleFontSize | Number |
Font size of the header title. |
titleFontStyle | FontStyle |
The font style of the header title. |
titleLimit | Number |
The maximum length of the header title in pixels. The text value will be automatically truncated if the rendered size exceeds the limit. Default value: |
titleOrient | String |
The orientation of the header title. One of |
titlePadding | Number |
The padding, in pixel, between facet header’s title and the label. Default value: |
Example
This example uses header properties to change the font size of this faceted plot’s title and labels.
Header Config
// Top-level View Specification
{
...
"config": {
"header": {...}, // Header
"headerRow": {...},
"headerColumn": {...},
"headerFacet": {...},
...
}
}
The header
property of the top-level config
object sets the default properties for all headers. If header properties are set in row-, column-, or facet-field definitions, these configuration values will be overridden. Additional property blocks can target more specific header types based on types of facet channels ("headerRow"
, "headerColumn"
, "headerFacet"
).
The header configuration can contain any header properties.