Skip to content

Commit

Permalink
fix(axis): fix y axis clip-path coordinates
Browse files Browse the repository at this point in the history
- Fix wrong y attribute value when axis is rotated
- Fix wrong interface name for y/y2 definition file

Fix #1572
  • Loading branch information
netil committed Aug 7, 2020
1 parent 574bfea commit da717b8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ChartInternal/internals/clip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default {
const isInner = config.axis_y_inner;

const x = isInner ? -1 : (isRotated ? -(1 + left) : -(left - 1));
const y = -(isRotated ? -20 : margin.top);
const y = -(isRotated ? 20 : margin.top);
const w = (isRotated ? width + 15 + left : margin.left + 20) + (isInner ? 20 : 0);
const h = (isRotated ? margin.bottom : (margin.top + height)) + 10;

Expand Down
10 changes: 9 additions & 1 deletion test/internals/axis-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,7 @@ describe("AXIS", function() {
});
});

describe("axis.x.rotated", () => {
describe("axis.rotated", () => {
before(() => {
args = {
data: {
Expand Down Expand Up @@ -1771,6 +1771,14 @@ describe("AXIS", function() {
expect(tick.attr("transform")).to.be.equal("translate(0,"+y+")");
});
});

it("y Axis clipPath element's x/y value should be < 0", () => {
const {state, $el} = chart.internal;
const yAxisClipPathRect = $el.svg.select(`#${state.clip.idYAxis} rect`);

expect(+yAxisClipPathRect.attr("x")).to.be.below(0);
expect(+yAxisClipPathRect.attr("y")).to.be.below(0);
});
});

describe("axis tick visiblity", () => {
Expand Down
4 changes: 2 additions & 2 deletions types/axis.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export interface yAxisConfigurationBase extends AxisConfigurationBase {
default?: number[];
}

export interface yAxisConfiguration extends AxisConfigurationBase {
export interface yAxisConfiguration extends yAxisConfigurationBase {
/**
* Set type of y axis (timeseries, category, indexed, log)
*
Expand All @@ -193,7 +193,7 @@ export interface yAxisConfiguration extends AxisConfigurationBase {
clipPath?: boolean;
}

export interface y2AxisConfiguration extends AxisConfigurationBase {}
export interface y2AxisConfiguration extends yAxisConfigurationBase {}

export interface XTickConfiguration {
/**
Expand Down

0 comments on commit da717b8

Please sign in to comment.