Skip to content

Commit

Permalink
fix(axis): fix axis symbol is not reverted when axis is reverse.
Browse files Browse the repository at this point in the history
  • Loading branch information
plainheart committed Jul 7, 2022
1 parent 2d7d59c commit 11f488c
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 16 deletions.
6 changes: 4 additions & 2 deletions src/component/axis/AxisBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName', AxisElementsBu
const matrix = transformGroup.transform;
const pt1 = [extent[0], 0];
const pt2 = [extent[1], 0];
const inverse = pt1[0] > pt2[0];
if (matrix) {
v2ApplyTransform(pt1, pt1, matrix);
v2ApplyTransform(pt2, pt2, matrix);
Expand Down Expand Up @@ -327,10 +328,11 @@ const builders: Record<'axisLine' | 'axisTickLabel' | 'axisName', AxisElementsBu
// Calculate arrow position with offset
const r = point.r + point.offset;

const pt = inverse ? pt2 : pt1;
symbol.attr({
rotation: point.rotate,
x: pt1[0] + r * Math.cos(opt.rotation),
y: pt1[1] - r * Math.sin(opt.rotation),
x: pt[0] + r * Math.cos(opt.rotation),
y: pt[1] - r * Math.sin(opt.rotation),
silent: true,
z2: 11
});
Expand Down
70 changes: 56 additions & 14 deletions test/axis-arrow.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 11f488c

Please sign in to comment.