Graphical elements are the primitives used to render visualizations of datasets in different types of charts. You can define defaults for them configuring the four objects in the Chart.defaults.global.elements context, listed as follows. Some of these properties are overridden in the defaults for certain charts, so changing them at this level may not cause any effect:
Object |
Description |
Default properties |
arc
|
The default properties for Canvas arcs, which are used in pie, doughnut, and polar area charts. |
backgroundColor:"rgba(0,0,0,0.1)" |
line |
The default properties for Canvas lines, which are used in line and radar charts. See Chapter 2, Technology Fundamentals, for Canvas properties used in borderCapStyle and borderJoinStyle. See Chapter 4, Creating Charts, for fill strategies. |
backgroundColor:"rgba(0,0,0,0.1)" |
Point |
Value points are actually circles drawn with Canvas arcs. This object contains default properties for points in line, radar, scatter, or bubble charts. See Chapter 4, Creating Charts, for more point styles. |
backgroundColor:"rgba(0,0,0,0.1)" |
Rectangle |
The default properties for Canvas rectangles used in bar and horizontalBar charts. One of the borders is not drawn (skipped). |
backgroundColor:"rgba(0,0,0,0.1)" |
The following code will make all line and radar charts use red dashed 5-pixel lines as the default, unless they are overridden in their default configuration or options object. See Config/defaults-2-global-elements.html, as follows:
const line = Chart.defaults.global.elements.line;
line.borderDash = [5,5];
line.borderWidth = 5;
line.borderColor = 'red';