Skip to content

Commit

Permalink
fix: type-step markLine's label should consider the refX/refY/dx/dy…
Browse files Browse the repository at this point in the history
… set by user, fixed#2739
  • Loading branch information
kkxxkk2019 committed May 27, 2024
1 parent 4ab9e0f commit 5986dae
Showing 1 changed file with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
MarkLine as MarkLineComponent,
registerMarkLineAnimate
} from '@visactor/vrender-components';
import { isValid } from '@visactor/vutils';
import { isValid, isValidNumber } from '@visactor/vutils';
import type { IDataPos, IMarkProcessOptions } from '../interface';
import type { IOptionRegr } from '../../../data/transforms/regression';
import { getInsertPoints, getTextOffset } from './util';
Expand Down Expand Up @@ -127,25 +127,31 @@ export class CartesianMarkLine extends BaseMarkLine {
labelPositionAttrs = {
position: 'middle',
autoRotate: false,
refX: label.refX ?? 0,
refY: label.refY ?? 0
refX: 0,
refY: 0
};
} else {
const textOffset = getTextOffset(
(points as IPoint[])[0],
(points as IPoint[])[1],
connectDirection,
expandDistanceValue
);
labelPositionAttrs = {
position: 'start',
autoRotate: false,
dx: (label.dx ?? 0) + (textOffset.dx ?? 0),
dy: (label.dy ?? 0) + (textOffset.dy ?? 0),
refX: label.refX ?? 0,
refY: label.refY ?? 0
...getTextOffset((points as IPoint[])[0], (points as IPoint[])[1], connectDirection, expandDistanceValue),
refX: 0,
refY: 0
};
}

if (isValidNumber(label.refX)) {
labelPositionAttrs.refX += label.refX;
}
if (isValidNumber(label.refY)) {
labelPositionAttrs.refY += label.refY;
}
if (isValidNumber(label.dx)) {
labelPositionAttrs.dx += label.dx;
}
if (isValidNumber(label.dy)) {
labelPositionAttrs.dy += label.dy;
}
const markerComponentAttr = this._markerComponent?.attribute ?? {};
this._markerComponent?.setAttributes({
points: multiSegment
Expand Down

0 comments on commit 5986dae

Please sign in to comment.