Time Cartesian Axis

    The time scale requires both a date library and a corresponding adapter to be present. Please choose from the available adapters (opens new window).

    See .

    When providing data for the time scale, Chart.js uses timestamps defined as milliseconds since the epoch (midnight January 1, 1970, UTC) internally. However, Chart.js also supports all of the formats that your chosen date adapter accepts. You should use timestamps if you’d like to set for better performance.

    Namespace: options.scales[scaleId]

    Namespace: options.scales[scaleId]

    Time Units

    The following time measurements are supported. The names can be passed as strings to the time.unit config option to force a certain unit.

    • 'millisecond'
    • 'second'
    • 'minute'
    • 'day'
    • 'week'
    • 'month'
    • 'quarter'
    • 'year'

    For example, to create a chart with a time scale that always displayed units per month, the following config could be used.

    Display Formats

    You may specify a map of display formats with a key for each unit:

    • millisecond
    • second
    • minute
    • hour
    • day
    • week
    • month
    • quarter
    • year

    For example, to set the display format for the quarter unit to show the month and year, the following config might be passed to the chart constructor.

    1. const chart = new Chart(ctx, {
    2. type: 'line',
    3. options: {
    4. scales: {
    5. x: {
    6. type: 'time',
    7. time: {
    8. displayFormats: {
    9. quarter: 'MMM YYYY'
    10. }
    11. }
    12. }
    13. }
    14. }
    15. });

    Ticks Source

    The ticks.source property controls the ticks generation.

    • 'auto': generates “optimal” ticks based on scale size and time options
    • 'data': generates ticks from data (including labels from data {x|y} objects)
    • 'labels': generates ticks from user given ONLY

    Parser

    If this property is defined as a string, it is interpreted as a custom format to be used by the date adapter to parse the date.

    If this is a function, it must return a type that can be handled by your date adapter’s parse method.