From 756e1f069fe5fb09d45e3f3d666fccf531732f8c Mon Sep 17 00:00:00 2001 From: Jae Sung Park Date: Wed, 29 Jul 2020 15:56:54 +0900 Subject: [PATCH] fix(axis): fix y axis clip-path coordinates - Fix wrong y attribute value when axis is rotated - Fix wrong interface name for y/y2 definition file Ref #1572 --- src/ChartInternal/internals/clip.ts | 2 +- test/internals/axis-spec.ts | 10 +++++++++- types/axis.d.ts | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/ChartInternal/internals/clip.ts b/src/ChartInternal/internals/clip.ts index b7034a116..fd6e2283b 100644 --- a/src/ChartInternal/internals/clip.ts +++ b/src/ChartInternal/internals/clip.ts @@ -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; diff --git a/test/internals/axis-spec.ts b/test/internals/axis-spec.ts index 234051673..a68c3d489 100644 --- a/test/internals/axis-spec.ts +++ b/test/internals/axis-spec.ts @@ -1735,7 +1735,7 @@ describe("AXIS", function() { }); }); - describe("axis.x.rotated", () => { + describe("axis.rotated", () => { before(() => { args = { data: { @@ -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", () => { diff --git a/types/axis.d.ts b/types/axis.d.ts index d82103713..9f9e0b013 100644 --- a/types/axis.d.ts +++ b/types/axis.d.ts @@ -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) * @@ -193,7 +193,7 @@ export interface yAxisConfiguration extends AxisConfigurationBase { clipPath?: boolean; } -export interface y2AxisConfiguration extends AxisConfigurationBase {} +export interface y2AxisConfiguration extends yAxisConfigurationBase {} export interface XTickConfiguration { /**