Cartesian Axes

    All of the included cartesian axes support a number of common options.

    NameTypeDefaultDescription
    minnumberUser defined minimum value for the scale, overrides minimum value from data.
    maxnumberUser defined maximum value for the scale, overrides maximum value from data.
    sampleSizenumberticks.lengthThe number of ticks to examine when deciding how many labels will fit. Setting a smaller value will be faster, but may be less accurate when there is large variability in label length.
    autoSkipbooleantrueIf true, automatically calculates how many labels can be shown and hides labels accordingly. Labels will be rotated up to before skipping any. Turn autoSkip off to show all labels no matter what.
    autoSkipPaddingnumber0Padding between the ticks on the horizontal axis when autoSkip is enabled.
    labelOffsetnumber0Distance in pixels to offset the label from the centre point of the tick (in the x direction for the x axis, and the y direction for the y axis). Note: this can cause labels at the edges to be cropped by the edge of the canvas
    maxRotationnumber50Maximum rotation for tick labels when rotating to condense labels. Note: Rotation doesn’t occur until necessary. Note: Only applicable to horizontal scales.
    minRotationnumber0Minimum rotation for tick labels. Note: Only applicable to horizontal scales.
    mirrorbooleanfalseFlips tick labels around axis, displaying the labels inside the chart instead of outside. Note: Only applicable to vertical scales.
    paddingnumber0Padding between the tick label and the axis. When set on a vertical axis, this applies in the horizontal (X) direction. When set on a horizontal axis, this applies in the vertical (Y) direction.

    Axis ID

    The properties dataset.xAxisID or dataset.yAxisID have to match the scale properties scales.xAxes.id or scales.yAxes.id. This is especially needed if multi-axes charts are used.

    Creating Multiple Axes

    In the example below, we are creating two Y axes. We then use the yAxisID property to map the datasets to their correct axes.

    1. var myChart = new Chart(ctx, {
    2. type: 'line',
    3. datasets: [{
    4. label: 'Left dataset',
    5. // This binds the dataset to the left y axis
    6. yAxisID: 'left-y-axis'
    7. }, {
    8. data: [0.1, 0.5, 1.0, 2.0, 1.5, 0],
    9. label: 'Right dataset',
    10. // This binds the dataset to the right y axis
    11. yAxisID: 'right-y-axis'
    12. }],
    13. labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
    14. options: {
    15. scales: {
    16. yAxes: [{
    17. id: 'left-y-axis',
    18. type: 'linear',
    19. position: 'left'
    20. }, {
    21. id: 'right-y-axis',
    22. type: 'linear',
    23. position: 'right'
    24. }]
    25. }
    26. });