This website is for Vega-Lite v2. Go to the main Vega-Lite homepage for the latest release.

View Title

Edit this page

The title property of a view specification in Vega-lite adds a descriptive title to a chart. The title property can be either a string or an object defining the title parameters.

For example, the following bar chart is titled “A Simple Bar Chart”.

Title Parameter Object

A title parameter object can contain the following properties:

Property Type Description
text String

Required. The title text.

anchor String

The anchor position for placing the title. One of "start", "middle", or "end". For example, with an orientation of top these anchor positions map to a left-, center-, or right-aligned title.

Default value: "middle" for single and layered views. "start" for other composite views.

Note: For now, anchor is only customizable only for single and layered views. For other composite views, anchor is always "start".

offset Number

The orthogonal offset in pixels by which to displace the title from its position along the edge of the chart.

orient String

The orientation of the title relative to the chart. One of "top" (the default), "bottom", "left", or "right".

style String | String[]

A mark style property to apply to the title text mark.

Default value: "group-title".

For example, we can customize the anchor of the title of a bar chart.

Title Config

// Top-level View Specification
{
  ...
  "config": {
    "title": : {
      ...
    }
  }
}

To provide themes for all titles, the title config config: {title: {...}} can contain the following properties:

Property Type Description
anchor String

The anchor position for placing the title. One of "start", "middle", or "end". For example, with an orientation of top these anchor positions map to a left-, center-, or right-aligned title.

Default value: "middle" for single and layered views. "start" for other composite views.

Note: For now, anchor is only customizable only for single and layered views. For other composite views, anchor is always "start".

angle Number

Angle in degrees of title text.

baseline String

Vertical text baseline for title text.

color String

Text color for title text.

font String

Font name for title text.

fontSize Number

Font size in pixels for title text.

Default value: 10.

fontWeight String

Font weight for title text. This can be either a string (e.g "bold", "normal") or a number (100, 200, 300, …, 900 where "normal" = 400 and "bold" = 700).

limit Number

The maximum allowed length in pixels of legend labels.

offset Number

Offset in pixels of the title from the chart body and axes.

orient String

Default title orientation (“top”, “bottom”, “left”, or “right”)