Basic Configuration
The X-axis supports four axis types:value, category, time, and log. The type determines how data is scaled and displayed.
Axis Types
Value Axis
Numerical axis suitable for continuous data. Automatically calculates min, max, and interval values.Category Axis
Ordinal axis for discrete categorical data. Requires explicit data definition.Time Axis
Temporal axis optimized for time-series data with automatic time formatting.Log Axis
Logarithmic axis for exponential data patterns.Key Properties
Axis type determines the scale and data interpretation.Reference: src/coord/axisCommonTypes.ts:34
Position of the X-axis. Default is
'bottom'.Reference: src/coord/cartesian/AxisModel.ts:31-36Offset in pixels from the default position. Useful for multiple axes on the same position.Reference: src/coord/cartesian/AxisModel.ts:38
Index of the grid component that the axis belongs to.Reference: src/coord/cartesian/AxisModel.ts:34
Axis name displayed on the chart.Reference: src/coord/axisCommonTypes.ts:44
Location of the axis name:
'start': place name based on axis.extent[0]'end': place name based on axis.extent[1]'middle'or'center': place name at the center
Gap between axis name and axis line.Reference: src/coord/axisCommonTypes.ts:67
Rotation angle of the axis name in degrees.Reference: src/coord/axisCommonTypes.ts:53
Whether to inverse the axis direction.Reference: src/coord/axisCommonTypes.ts:42
Minimum value of the axis. Can be:
- A specific number
'dataMin': use the minimum value in data- A function that returns the min value
null/undefined: auto-calculated
Maximum value of the axis. Can be:
- A specific number
'dataMax': use the maximum value in data- A function that returns the max value
null/undefined: auto-calculated
For category axis: whether to add gap at both ends (default
true).
For value/time/log axis: gap value at both ends as [GAP, GAP] where GAP can be absolute pixel or percent.Reference: src/coord/axisCommonTypes.ts:140Number of segments the axis is split into. Only works for value, time, and log axes.Reference: src/coord/axisCommonTypes.ts:145
Mandatory interval for axis ticks. Overrides automatic calculation.Reference: src/coord/axisCommonTypes.ts:149
Only for value axis. If
false, axis always includes zero. If true, the axis may not contain zero.Reference: src/coord/axisCommonTypes.ts:216Axis Label Configuration
Configuration for axis labels.Reference: src/coord/axisCommonTypes.ts:89
Whether to show axis labels.
Whether labels are inside the grid or outside.Reference: src/coord/axisCommonTypes.ts:315
Rotation angle of labels in degrees. Positive values rotate clockwise.Reference: src/coord/axisCommonTypes.ts:316
Margin between label and axis line.Reference: src/coord/axisCommonTypes.ts:331
Label formatter. Can be a template string or callback function.Reference: src/coord/axisCommonTypes.ts:340
Whether to hide overlapping labels automatically.Reference: src/coord/axisCommonTypes.ts:335
Axis Line & Ticks
Configuration for the axis line.Reference: src/coord/axisCommonTypes.ts:92
Whether to show the axis line.Reference: src/coord/axisCommonTypes.ts:232
Whether the axis line aligns with the zero position of the other axis.Reference: src/coord/axisCommonTypes.ts:233
Configuration for axis ticks.Reference: src/coord/axisCommonTypes.ts:93
Whether to show axis ticks.Reference: src/coord/axisCommonTypes.ts:245
Whether ticks are inside the grid or outside.Reference: src/coord/axisCommonTypes.ts:247
Length of axis ticks in pixels.Reference: src/coord/axisCommonTypes.ts:249
For category axis with
boundaryGap: true, whether ticks align with labels.Reference: src/coord/axisCommonTypes.ts:203Split Lines & Areas
Configuration for split lines (grid lines).Reference: src/coord/axisCommonTypes.ts:95
Whether to show split lines.Reference: src/coord/axisCommonTypes.ts:354
Configuration for split areas (alternating background areas).Reference: src/coord/axisCommonTypes.ts:97
Whether to show split areas.Reference: src/coord/axisCommonTypes.ts:370
Advanced Examples
Multiple X-Axes
Time Axis with Custom Formatting
Value Axis with Custom Range
Related Components
- Y-Axis - Vertical axis configuration
- Grid - Cartesian coordinate system
- Angle Axis - Angular axis for polar charts
- Radius Axis - Radial axis for polar charts