Configuration

    This concept was introduced in Chart.js 1.0 to keep configuration , 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 hover 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

    • per dataset: dataset.*
    • per chart: options.datasets[type].*
    • or globally: Chart.defaults.global.datasets[type].*

    where type corresponds to the dataset type.

    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.

    1. // Do not show lines for all datasets by default
    2. Chart.defaults.global.datasets.line.showLine = false;
    3. // This chart would show a line only for the third dataset
    4. var chart = new Chart(ctx, {
    5. data: {
    6. datasets: [{
    7. data: [0, 0],
    8. }, {
    9. }, {
    10. showLine: true // overrides the `line` dataset default
    11. }, {
    12. type: 'scatter', // 'line' dataset default does not affect this dataset since it's a 'scatter'
    13. data: [1, 1]
    14. }]