Axis ticks are markers placed at regular intervals along each axis, and are also used to determine where and how often to show the axis labels and grid lines.
Category axes show a tick for every category. Number and time axes will display around 5 ticks depending on the available space.
Tick placement can be customised by using one of the following strategies:
- Tick Interval - used to place a tick at regular intervals
- Tick Values - used to place a tick at specified values
- Min / Max Spacing - used to control the pixel gap between ticks
tick.interval defines the exact step value between ticks, expressed in the units of the respective axis.
For Number Axes, the interval property should be a number. Ticks will be displayed at every interval value within the axis range. For instance, with an interval of
5, the ticks will appear at
10, and so on.
The following example demonstrates how to specify the tick interval on a number axis:
For Log Axes the interval attribute should be assigned a numerical value. This number increments the exponent to which the base of the logarithm is elevated. For instance, an interval of
2 will display values like
10^4, and so on.
For Time Axes the interval property should represent a time interval, such as
time.month, which displays a tick every month. You can also utilise an interval based on predefined time intervals, like
time.month.every(3), to customise the frequency of the ticks.
time intervals are:
millisecond. There are also some UTC time intervals available:
interval property of a time axis is set to a
number, this will be interpreted as milliseconds.
If the configured
interval results in too many ticks given the data domain and chart size, it will be ignored and the default tick behaviour will be applied.
The example below demonstrates the usage of time intervals:
time.monthwill produce monthly ticks.
time.month.every(2)will generate ticks for every second month.
tick.values property allows you to specify the precise array of tick values to display. Depending on the axis type, this should be an array consisting of numbers, dates, or string values.
values: [50, 88, 100],
Note that these values might not be displayed when a
label.formatter is also used.
The following example demonstrates how to specify exact tick values:
tick.maxSpacing options alter the default behaviour by defining the approximate minimum and maximum pixel gaps that should exist between ticks. You can provide one or both options as needed. An appropriate number of ticks will be generated to meet the specified
tick.maxSpacing constraints taking the rendered size of the chart into account. A sample configuration is shown below:
Category axes do not support
maxSpacing, as ticks are derived from the domain of category values.
The following example demonstrates how to specify min / max tick spacing. Note the following:
- There is a button at the top of the chart to apply min / max spacing.
- There is a grab handle in the bottom right to allow resizing of the chart to see how the ticks change with available space.
maxSpacing are very close in value, the actual spacing between the ticks may be outside the requested range. This is because the specified constraints may result in ticks with non-standard intervals rather than round intervals such as 1x, 2x, 5x, and 10x. To avoid this, set
maxSpacing to be 2-3 times larger than
Continue to the next section to learn about Axis Domain.