Axes

    In a radial chart, such as a radar chart or a polar area chart, there is a single axis that maps points in the angular and radial directions. These are known as ‘radial axes’.

    Scales in Chart.js >v2.0 are significantly more powerful, but also different than those of v1.0.

    • Multiple X & Y axes are supported.
    • Scale titles are supported.
    • New scale types can be extended without writing an entirely new chart type.

    The default ‘s for carterian charts are 'x' and 'y'. For radial charts: 'r'. Each dataset is mapped to a scale for each axis (x, y or r) it requires. The scaleId’s that a dataset is mapped to, is determined by the xAxisID, yAxisID or rAxisID. If the ID for an axis is not specified, first scale for that axis is used. If no scale for an axis is found, a new scale is created.

    Some examples:

    The following chart will have 'x' and 'y' scales:

    The following chart will have scales 'x' and 'myScale':

    1. let chart = new Chart(ctx, {
    2. type: 'bar',
    3. data: {
    4. datasets: [{
    5. data: [1, 2, 3]
    6. }]
    7. },
    8. options: {
    9. scales: {
    10. type: 'logarithmic',
    11. position: 'right', // `axis` is determined by the position as `'y'`
    12. }
    13. }
    14. }
    15. });

    The following chart will have 'r' scale:

    1. let chart = new Chart(ctx, {
    2. type: 'radar'
    3. });

    The following chart will have 'myScale' scale:

    Common Configuration

    Namespace: options.scales[scaleId]

    Namespace: options.scales[scaleId].ticks

    Axis Range Settings

    Given the number of axis range settings, it is important to understand how they all interact with each other.

    The suggestedMax and suggestedMin settings only change the data values that are used to scale the axis. These are useful for extending the range of the axis while maintaining the auto fit behaviour.

    1. let minDataValue = Math.min(mostNegativeValue, options.suggestedMin);
    2. let maxDataValue = Math.max(mostPositiveValue, options.suggestedMax);

    In contrast to the suggested* settings, the min and max settings set explicit ends to the axes. When these are set, some data points may not be visible.

    By default data is not stacked. If the stacked option of the value scale (y-axis on horizontal chart) is true, positive and negative values are stacked separately. Additionally a stack option can be defined per dataset to further divide into stack groups . For some charts, you might want to stack positive and negative values together. That can be achieved by specifying stacked: 'single'.

    Callbacks

    There are a number of config callbacks that can be used to change parameters in the scale at different points in the update process. The options are supplied at the top level of the axis options.

    Namespace: options.scales[scaleId]

    The default configuration for a scale can be easily changed. All you need to do is set the new options to Chart.defaults.scales[type].

    For example, to set the minimum value of 0 for all linear scales, you would do the following. Any linear scales created after this time would now have a minimum of 0.