2017-03-21 01:36:54 +01:00
# Title
The chart title defines text to draw at the top of the chart.
## Title Configuration
2020-01-03 20:07:38 +01:00
The title configuration is passed into the `options.title` namespace. The global options for the chart title is defined in `Chart.defaults.title` .
2017-03-21 01:36:54 +01:00
| Name | Type | Default | Description
2019-01-29 13:34:16 +01:00
| ---- | ---- | ------- | -----------
2020-01-05 20:59:57 +01:00
| `align` | `string` | `'center'` | Alignment of the title. [more... ](#align )
2019-01-29 13:34:16 +01:00
| `display` | `boolean` | `false` | Is the title shown?
| `position` | `string` | `'top'` | Position of title. [more... ](#position )
| `fontSize` | `number` | `12` | Font size.
| `fontFamily` | `string` | `"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif"` | Font family for the title text.
2018-11-02 08:46:06 +01:00
| `fontColor` | `Color` | `'#666'` | Font color.
2019-01-29 13:34:16 +01:00
| `fontStyle` | `string` | `'bold'` | Font style.
2019-12-20 14:21:20 +01:00
| `padding` | < code > number| {top: number, bottom: number}</ code > | `10` | Adds padding above and below the title text if a single number is specified. It is also possible to change top and bottom padding separately.
2019-01-29 13:34:16 +01:00
| `lineHeight` | < code > number| string</ code > | `1.2` | Height of an individual line of text. See [MDN ](https://developer.mozilla.org/en-US/docs/Web/CSS/line-height ).
| `text` | < code > string| string[]</ code > | `''` | Title text to display. If specified as an array, text is rendered on multiple lines.
2017-03-21 01:36:54 +01:00
### Position
Possible title position values are:
* `'top'`
* `'left'`
* `'bottom'`
* `'right'`
2020-01-05 20:59:57 +01:00
## Align
Alignment of the title. Options are:
* `'start'`
* `'center'`
* `'end'`
2017-03-21 01:36:54 +01:00
## Example Usage
The example below would enable a title of 'Custom Chart Title' on the chart that is created.
```javascript
var chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
title: {
display: true,
text: 'Custom Chart Title'
}
}
2019-01-29 13:34:16 +01:00
});
2017-03-21 01:36:54 +01:00
```
2019-12-20 14:21:20 +01:00
This example shows how to specify separate top and bottom title text padding:
```javascript
var chart = new Chart(ctx, {
type: 'line',
data: data,
options: {
title: {
display: true,
text: 'Custom Chart Title',
padding: {
top: 10,
bottom: 30
}
}
}
});
```