Configuring the axes

Time scales support all properties for Cartesian scales and add two additional properties, listed in the following table. These properties are configured in each axis (for example, scales.xAxes[0].bounds):

Property

Value

Description

bounds

data (default), ticks

Sets the scale boundary strategy. The default data will re-dimension the axes to fit the data. Using ticks, the chart will be truncated to fit the scales.

distribution

linear (default) or series

How the data is distributed on the axis. If series, the data values will be equally spaced. If linear, the instants will be equally spaced.

Additional axis configuration properties for time scales

In the last example, the bars were unevenly positioned because the default distribution preserved the time instants. In this example, the bars will be evenly spaced, but the periods between them will not be uniform. The data is bounded by the ticks, instead of the data points, and the date format for the days displays the abbreviated month, day, and year:

xAxes: [{
type: 'time',
offset: true,
gridLines: { offsetGridLines: true },
distribution: 'series',
bounds: 'ticks',
time: {
unit: 'day',
displayFormats: {
day: 'MMM D Y',
}
}
}]

The result is shown as follows. See the full code in Time/time-2.html:

A bar chart with a time scale with equally-distributed bars, and tick bounds. Code: Time/time-2.html.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset