Elements

While chart types provide settings to configure the styling of each dataset, you sometimes want to style all datasets the same way. A common example would be to stroke all of the bars in a bar chart with the same colour but change the fill per dataset. Options can be configured for four different types of elements: arc, lines, points, and rectangles. When set, these options apply to all objects of that type unless specifically overridden by the configuration attached to a dataset.

Global Configuration

The element options can be specified per chart or globally. The global options for elements are defined in Chart.defaults.global.elements. For example, to set the border width of all bar charts globally you would do:

  1. Chart.defaults.global.elements.rectangle.borderWidth = 2;

Point Configuration

Point elements are used to represent the points in a line chart or a bubble chart.

Global point options: Chart.defaults.global.elements.point

NameTypeDefaultDescription
radiusNumber3Point radius.
pointStyleStringcirclePoint style.
backgroundColorColor'rgba(0,0,0,0.1)'Point fill color.
borderWidthNumber1Point stroke width.
borderColorColor'rgba(0,0,0,0.1)'Point stroke color.
hitRadiusNumber1Extra radius added to point radius for hit detection.
hoverRadiusNumber4Point radius when hovered.
hoverBorderWidthNumber1Stroke width when hovered.

Point Styles

The following values are supported:

  • 'circle'
  • 'cross'
  • 'crossRot'
  • 'dash'
  • 'line'
  • 'rect'
  • 'rectRounded'
  • 'rectRot'
  • 'star'
  • 'triangle'
    If the value is an image, that image is drawn on the canvas using drawImage.

Line Configuration

Line elements are used to represent the line in a line chart.

Global line options: Chart.defaults.global.elements.line

NameTypeDefaultDescription
tensionNumber0.4Bézier curve tension (0 for no Bézier curves).
backgroundColorColor'rgba(0,0,0,0.1)'Line fill color.
borderWidthNumber3Line stroke width.
borderColorColor'rgba(0,0,0,0.1)'Line stroke color.
borderCapStyleString'butt'Line cap style (see MDN).
borderDashArray[]Line dash (see MDN).
borderDashOffsetNumber0Line dash offset (see MDN).
borderJoinStyleString'miterLine join style (see MDN).
capBezierPointsBooleantruetrue to keep Bézier control inside the chart, false for no restriction.
fillBoolean/StringtrueFill location: 'zero', 'top', 'bottom', true (eq. 'zero') or false (no fill).
steppedBooleanfalsetrue to show the line as a stepped line (tension will be ignored).

Rectangle Configuration

Rectangle elements are used to represent the bars in a bar chart.

Global rectangle options: Chart.defaults.global.elements.rectangle

NameTypeDefaultDescription
backgroundColorColor'rgba(0,0,0,0.1)'Bar fill color.
borderWidthNumber0Bar stroke width.
borderColorColor'rgba(0,0,0,0.1)'Bar stroke color.
borderSkippedString'bottom'Skipped (excluded) border: 'bottom', 'left', 'top' or 'right'.

Arc Configuration

Arcs are used in the polar area, doughnut and pie charts.

Global arc options: Chart.defaults.global.elements.arc.

NameTypeDefaultDescription
backgroundColorColor'rgba(0,0,0,0.1)'Arc fill color.
borderColorColor'#fff'Arc stroke color.
borderWidthNumber2Arc stroke width.