Configuration
This concept was introduced in Chart.js 1.0 to keep configuration DRY (opens new window), and allow for changing options globally across chart types, avoiding the need to specify options for each instance, or the default for a particular chart type.
The following example would set the interaction mode to ‘nearest’ for all charts where this was not overridden by the chart type defaults or the options passed to the constructor on creation.
Dataset Configuration
The following example would set the showLine
option to ‘false’ for all line datasets except for those overridden by options passed to the dataset on creation.
// Do not show lines for all datasets by default
Chart.defaults.datasets.line.showLine = false;
// This chart would show a line only for the third dataset
data: {
datasets: [{
data: [0, 0],
}, {
data: [0, 1]
showLine: true // overrides the `line` dataset default
}, {
type: 'scatter', // 'line' dataset default does not affect this dataset since it's a 'scatter'
data: [1, 1]
}]