| Name | Type | Default | Description
| ---- | ---- | ------- | -----------
-| `alignment` | `string` | | `'center'` | The tick alignment along the axis. Can be `'start'`, `'center'`, or `'end'`.
-| `crossAlignment` | `string` | | `'near'` | The tick alignment perpendicular to the axis. Can be `'near'`, `'center'`, or `'far'`. See [Tick Alignment](#tick-alignment)
+| `align` | `string` | | `'center'` | The tick alignment along the axis. Can be `'start'`, `'center'`, or `'end'`.
+| `crossAlign` | `string` | | `'near'` | The tick alignment perpendicular to the axis. Can be `'near'`, `'center'`, or `'far'`. See [Tick Alignment](#tick-alignment)
| `sampleSize` | `number` | `ticks.length` | The number of ticks to examine when deciding how many labels will fit. Setting a smaller value will be faster, but may be less accurate when there is large variability in label length.
| `autoSkip` | `boolean` | `true` | If true, automatically calculates how many labels can be shown and hides labels accordingly. Labels will be rotated up to `maxRotation` before skipping any. Turn `autoSkip` off to show all labels no matter what.
| `autoSkipPadding` | `number` | `0` | Padding between the ticks on the horizontal axis when `autoSkip` is enabled.
### Tick Alignment
-The alignment of ticks is primarily controlled using two settings on the tick configuration object: `alignment` and `crossAlignment`. The `alignment` setting configures how labels align with the tick mark along the axis direction (i.e. horizontal for a horizontal axis and vertical for a vertical axis). The `crossAlignment` setting configures how labels align with the tick mark in the perpendicular direction (i.e. vertical for a horizontal axis and horizontal for a vertical axis). In the example below, the `crossAlignment` setting is used to left align the labels on the Y axis.
+The alignment of ticks is primarily controlled using two settings on the tick configuration object: `align` and `crossAlign`. The `align` setting configures how labels align with the tick mark along the axis direction (i.e. horizontal for a horizontal axis and vertical for a vertical axis). The `crossAlign` setting configures how labels align with the tick mark in the perpendicular direction (i.e. vertical for a horizontal axis and horizontal for a vertical axis). In the example below, the `crossAlign` setting is used to left align the labels on the Y axis.
```jsx live
function exampleAlignment() {
},
y: {
ticks: {
- crossAlignment: 'far',
+ crossAlign: 'far',
}
}
}
}
```
-**Note:** the `crossAlignment` setting is not used the the tick rotation is not `0`, the axis position is `'center'` or the position is with respect to a data value.
+**Note:** the `crossAlign` setting is not used the the tick rotation is not `0`, the axis position is `'center'` or the position is with respect to a data value.
### Axis ID
callback: Ticks.formatters.values,
minor: {},
major: {},
- alignment: 'center',
- crossAlignment: 'near',
+ align: 'center',
+ crossAlign: 'near',
}
});
paddingRight = labelsBelowTicks ?
sinRotation * (lastLabelSize.height - lastLabelSize.offset) :
cosRotation * lastLabelSize.width + sinRotation * lastLabelSize.offset;
- } else if (tickOpts.alignment === 'start') {
+ } else if (tickOpts.align === 'start') {
paddingLeft = 0;
paddingRight = lastLabelSize.width;
- } else if (tickOpts.alignment === 'end') {
+ } else if (tickOpts.align === 'end') {
paddingLeft = firstLabelSize.width;
paddingRight = 0;
} else {
let paddingTop = lastLabelSize.height / 2;
let paddingBottom = firstLabelSize.height / 2;
- if (tickOpts.alignment === 'start') {
+ if (tickOpts.align === 'start') {
paddingTop = 0;
paddingBottom = firstLabelSize.height;
- } else if (tickOpts.alignment === 'end') {
+ } else if (tickOpts.align === 'end') {
paddingTop = lastLabelSize.height;
paddingBottom = 0;
}
const {position, ticks: optionTicks} = options;
const isHorizontal = me.isHorizontal();
const ticks = me.ticks;
- const {alignment, crossAlignment, padding} = optionTicks;
+ const {align, crossAlign, padding} = optionTicks;
const tl = getTickMarkLength(options.gridLines);
const tickAndPadding = tl + padding;
const rotation = -toRadians(me.labelRotation);
}
if (axis === 'y') {
- if (alignment === 'start') {
+ if (align === 'start') {
textBaseline = 'top';
- } else if (alignment === 'end') {
+ } else if (align === 'end') {
textBaseline = 'bottom';
}
}
if (isHorizontal) {
x = pixel;
if (position === 'top') {
- if (crossAlignment === 'near' || rotation !== 0) {
+ if (crossAlign === 'near' || rotation !== 0) {
textOffset = (Math.sin(rotation) * halfCount + 0.5) * lineHeight;
textOffset -= (rotation === 0 ? (lineCount - 0.5) : Math.cos(rotation) * halfCount) * lineHeight;
- } else if (crossAlignment === 'center') {
+ } else if (crossAlign === 'center') {
textOffset = -1 * (labelSizes.highest.height / 2);
textOffset -= halfCount * lineHeight;
} else {
textOffset = (-1 * labelSizes.highest.height) + (0.5 * lineHeight);
}
} else if (position === 'bottom') {
- if (crossAlignment === 'near' || rotation !== 0) {
+ if (crossAlign === 'near' || rotation !== 0) {
textOffset = Math.sin(rotation) * halfCount * lineHeight;
textOffset += (rotation === 0 ? 0.5 : Math.cos(rotation) * halfCount) * lineHeight;
- } else if (crossAlignment === 'center') {
+ } else if (crossAlign === 'center') {
textOffset = labelSizes.highest.height / 2;
textOffset -= halfCount * lineHeight;
} else {
let align = 'center';
- if (ticks.alignment === 'start') {
+ if (ticks.align === 'start') {
align = 'left';
- } else if (ticks.alignment === 'end') {
+ } else if (ticks.align === 'end') {
align = 'right';
}
_getYAxisLabelAlignment(tl) {
const me = this;
const {position, ticks} = me.options;
- const {crossAlignment, mirror, padding} = ticks;
+ const {crossAlign, mirror, padding} = ticks;
const labelSizes = me._getLabelSizes();
const tickAndPadding = tl + padding;
const widest = labelSizes.widest.width;
} else {
x = me.right - tickAndPadding;
- if (crossAlignment === 'near') {
+ if (crossAlign === 'near') {
textAlign = 'right';
- } else if (crossAlignment === 'center') {
+ } else if (crossAlign === 'center') {
textAlign = 'center';
x -= (widest / 2);
} else {
} else {
x = me.left + tickAndPadding;
- if (crossAlignment === 'near') {
+ if (crossAlign === 'near') {
textAlign = 'left';
- } else if (crossAlignment === 'center') {
+ } else if (crossAlign === 'center') {
textAlign = 'center';
x += widest / 2;
} else {