Scales
Axes are an integral part of a chart. They are used to determine how data maps to a pixel value on the chart. In a cartesian chart, there is 1 or more X-axis and 1 or more Y-axis to map points onto the 2-dimensional canvas. These axes are known as 'cartesian 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'.
Namespace: options.scales[scaleId]
ScaleId("id")
method. x
, y
, r
or a custom id can be assigned.
Common Axis Options:¶
These are only the common options supported by all axes. Please see specific axis documentation for all the available options for that axis.
Type¶
Type of scale being employed. Custom scales can be created and registered with a string key. This allows changing the type of an axis for a chart.
AlignToPixels¶
Align pixel values to device pixels. Default false
BackgroundColor¶
Background color of the scale area.
Display¶
Controls the axis global visibility (visible when true
, hidden when false
).
Default true
'auto'
, the axis is visible only if at least one associated dataset is visible.
Min¶
User defined minimum number for the scale, overrides minimum value from data.
Max¶
User defined maximum number for the scale, overrides maximum value from data.
Reverse¶
Reverse the scale. Default false
Stacked¶
Should the data be stacked. Default false
'single'
SuggestedMax¶
Adjustment used when calculating the maximum data value.
SuggestedMin¶
Adjustment used when calculating the minimum data value.
Weight¶
The weight used to sort the axis. Higher weights are further away from the chart area.
Default 0
Linear Axis Options:¶
The linear scale is used to chart numerical data. It can be placed on either the x or y-axis. The scatter chart type automatically configures a line chart to use one of these scales for the x-axis. As the name suggests, linear interpolation is used to determine where a value lies on the axis.
BeginAtZero¶
if true
, scale will include 0
if it is not already included.
Grace¶
Percentage (string ending with %) for added room in the scale range above and below data.
Amount (number) for added room in the scale range above and below data.Cartesian Axis Options:¶
Axes that follow a cartesian grid are known as 'Cartesian Axes'. Cartesian axes are used for line, bar, and bubble charts. Four cartesian axes are included in Chart.js by default.
Bounds¶
Determines the scale bounds. Default 'ticks'
Clip¶
If true, clip the dataset drawing against the size of the scale instead of chart area.
Default true
Position¶
Stack¶
Stack group. Axes at the same position
with same stack
are stacked.
StackWeight¶
Weight of the scale in stack group. Used to determine the amount of allocated space for the scale within the group.
Default 1
Axis¶
Which type of axis this is. Possible values are: 'x'
, 'y'
.
If not set, this is inferred from the first character of the ID which should be 'x'
or 'y'
.
Offset¶
If true
, extra space is added to the both edges and the axis is scaled to fit into the chart area.
This is set to true
for a bar chart by default, for others false
.