Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new align 'inner' for X axis #10106

Merged
merged 8 commits into from Feb 12, 2022
14 changes: 13 additions & 1 deletion src/core/core.scale.js
Expand Up @@ -1206,9 +1206,19 @@ export default class Scale extends Element {
const color = optsAtIndex.color;
const strokeColor = optsAtIndex.textStrokeColor;
const strokeWidth = optsAtIndex.textStrokeWidth;
let tickTextAlign = textAlign;

if (isHorizontal) {
x = pixel;

if (textAlign === 'left-right') {
Talla2XLC marked this conversation as resolved.
Show resolved Hide resolved
if (i === ilen - 1) {
tickTextAlign = 'right';
} else {
tickTextAlign = 'left';
}
Talla2XLC marked this conversation as resolved.
Show resolved Hide resolved
}

if (position === 'top') {
if (crossAlign === 'near' || rotation !== 0) {
textOffset = -lineCount * lineHeight + lineHeight / 2;
Expand Down Expand Up @@ -1285,7 +1295,7 @@ export default class Scale extends Element {
strokeColor,
strokeWidth,
textOffset,
textAlign,
textAlign: tickTextAlign,
textBaseline,
translation: [x, y],
backdrop,
Expand All @@ -1309,6 +1319,8 @@ export default class Scale extends Element {
align = 'left';
} else if (ticks.align === 'end') {
align = 'right';
} else if (ticks.align === 'left-right') {
align = 'left-right';
Talla2XLC marked this conversation as resolved.
Show resolved Hide resolved
}

return align;
Expand Down