From 103091645b4a1309fec6de4626dea63fb712a262 Mon Sep 17 00:00:00 2001 From: fandi-1205 Date: Tue, 18 Jun 2024 11:34:02 +0800 Subject: [PATCH 1/6] fix: clipping in custom series off by pixel#19993 --- src/chart/custom/CustomView.ts | 2 +- .../helper/createClipPathFromCoordSys.ts | 18 ++- src/chart/line/LineView.ts | 2 +- test/clip-custom-off1pixel.html | 128 ++++++++++++++++++ 4 files changed, 142 insertions(+), 8 deletions(-) create mode 100644 test/clip-custom-off1pixel.html diff --git a/src/chart/custom/CustomView.ts b/src/chart/custom/CustomView.ts index ee4e244cf7..f151ab4d58 100644 --- a/src/chart/custom/CustomView.ts +++ b/src/chart/custom/CustomView.ts @@ -243,7 +243,7 @@ export default class CustomChartView extends ChartView { // Do clipping const clipPath = customSeries.get('clip', true) - ? createClipPath(customSeries.coordinateSystem, false, customSeries) + ? createClipPath(customSeries.coordinateSystem, false, customSeries, ecModel) : null; if (clipPath) { group.setClipPath(clipPath); diff --git a/src/chart/helper/createClipPathFromCoordSys.ts b/src/chart/helper/createClipPathFromCoordSys.ts index 74ec7f8e90..37f31d75cd 100644 --- a/src/chart/helper/createClipPathFromCoordSys.ts +++ b/src/chart/helper/createClipPathFromCoordSys.ts @@ -25,6 +25,8 @@ import type Cartesian2D from '../../coord/cartesian/Cartesian2D'; import type Polar from '../../coord/polar/Polar'; import { CoordinateSystem } from '../../coord/CoordinateSystem'; import { isFunction } from 'zrender/src/core/util'; +import GlobalModel from '../../model/Global'; +import AxisModel from '../../coord/cartesian/AxisModel'; type SeriesModelWithLineWidth = SeriesModel void, during?: (percent: number, clipRect: graphic.Rect) => void ) { @@ -43,12 +46,14 @@ function createGridClipPath( let width = rect.width; let height = rect.height; - const lineWidth = seriesModel.get(['lineStyle', 'width']) || 2; // Expand the clip path a bit to avoid the border is clipped and looks thinner - x -= lineWidth / 2; - y -= lineWidth / 2; - width += lineWidth; - height += lineWidth; + const xAxisModel = ecModel.getComponent('xAxis', 0) as AxisModel; + const yAxisModel = ecModel.getComponent('yAxis', 0) as AxisModel; + const xAisWidth = xAxisModel.get(['axisLine', 'lineStyle']).width || 2; + const yAxisWidth = yAxisModel.get(['axisLine', 'lineStyle']).width || 2; + x += xAisWidth / 2; + width -= xAisWidth / 2; + height -= yAxisWidth / 2; // fix: https://github.com/apache/incubator-echarts/issues/11369 width = Math.ceil(width); @@ -150,6 +155,7 @@ function createClipPath( coordSys: CoordinateSystem, hasAnimation: boolean, seriesModel: SeriesModelWithLineWidth, + ecModel?:GlobalModel, done?: () => void, during?: (percent: number) => void ) { @@ -160,7 +166,7 @@ function createClipPath( return createPolarClipPath(coordSys as Polar, hasAnimation, seriesModel); } else if (coordSys.type === 'cartesian2d') { - return createGridClipPath(coordSys as Cartesian2D, hasAnimation, seriesModel, done, during); + return createGridClipPath(coordSys as Cartesian2D, hasAnimation, seriesModel, ecModel, done, during); } return null; } diff --git a/src/chart/line/LineView.ts b/src/chart/line/LineView.ts index 9672eb720b..a88367445f 100644 --- a/src/chart/line/LineView.ts +++ b/src/chart/line/LineView.ts @@ -531,7 +531,7 @@ function createLineClipPath( : null; const isHorizontal = coordSys.getBaseAxis().isHorizontal(); - const clipPath = createGridClipPath(coordSys, hasAnimation, seriesModel, () => { + const clipPath = createGridClipPath(coordSys, hasAnimation, seriesModel, undefined, () => { const endLabel = lineView._endLabel; if (endLabel && hasAnimation) { if (labelAnimationRecord.originalX != null) { diff --git a/test/clip-custom-off1pixel.html b/test/clip-custom-off1pixel.html new file mode 100644 index 0000000000..e0eb6a825a --- /dev/null +++ b/test/clip-custom-off1pixel.html @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + \ No newline at end of file From b8a9e080ccd8dd7b0e4ef07d81666ec5a8b1e49a Mon Sep 17 00:00:00 2001 From: fandi-1205 Date: Thu, 27 Jun 2024 14:55:25 +0800 Subject: [PATCH 2/6] fix(custom):Clipping in custom series off by 1 pixel #19993 --- src/chart/custom/CustomView.ts | 2 +- .../helper/createClipPathFromCoordSys.ts | 13 +- test/clip-custom.html | 127 ++++++++++++++++++ 3 files changed, 133 insertions(+), 9 deletions(-) create mode 100644 test/clip-custom.html diff --git a/src/chart/custom/CustomView.ts b/src/chart/custom/CustomView.ts index f151ab4d58..ee4e244cf7 100644 --- a/src/chart/custom/CustomView.ts +++ b/src/chart/custom/CustomView.ts @@ -243,7 +243,7 @@ export default class CustomChartView extends ChartView { // Do clipping const clipPath = customSeries.get('clip', true) - ? createClipPath(customSeries.coordinateSystem, false, customSeries, ecModel) + ? createClipPath(customSeries.coordinateSystem, false, customSeries) : null; if (clipPath) { group.setClipPath(clipPath); diff --git a/src/chart/helper/createClipPathFromCoordSys.ts b/src/chart/helper/createClipPathFromCoordSys.ts index 37f31d75cd..a056dbfb42 100644 --- a/src/chart/helper/createClipPathFromCoordSys.ts +++ b/src/chart/helper/createClipPathFromCoordSys.ts @@ -26,7 +26,6 @@ import type Polar from '../../coord/polar/Polar'; import { CoordinateSystem } from '../../coord/CoordinateSystem'; import { isFunction } from 'zrender/src/core/util'; import GlobalModel from '../../model/Global'; -import AxisModel from '../../coord/cartesian/AxisModel'; type SeriesModelWithLineWidth = SeriesModel + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + \ No newline at end of file From 243bc2fd7b9a3a63c751900a71c272fffe70d2d7 Mon Sep 17 00:00:00 2001 From: fandi-1205 Date: Thu, 27 Jun 2024 15:49:20 +0800 Subject: [PATCH 3/6] fix(custom):The range of the custom clipping path has been modified to force clipping according to the Grid range.#19993 --- src/chart/helper/createClipPathFromCoordSys.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chart/helper/createClipPathFromCoordSys.ts b/src/chart/helper/createClipPathFromCoordSys.ts index a056dbfb42..61472a4dbc 100644 --- a/src/chart/helper/createClipPathFromCoordSys.ts +++ b/src/chart/helper/createClipPathFromCoordSys.ts @@ -49,7 +49,7 @@ function createGridClipPath( // Expand the clip path a bit to avoid the border is clipped and looks thinner x -= lineWidth / 2; y -= lineWidth / 2; - width += lineWidth - 1; + width += lineWidth; height += lineWidth; // fix: https://github.com/apache/incubator-echarts/issues/11369 From f1f79e4e7a738fa399054b39a2a0f3fbbffad4c1 Mon Sep 17 00:00:00 2001 From: fandi-1205 Date: Thu, 27 Jun 2024 17:06:34 +0800 Subject: [PATCH 4/6] fix(custom):Modify the range of the clipping path under customized conditions#19993 --- src/chart/helper/createClipPathFromCoordSys.ts | 5 +---- src/chart/line/LineView.ts | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/chart/helper/createClipPathFromCoordSys.ts b/src/chart/helper/createClipPathFromCoordSys.ts index 61472a4dbc..191ac95c62 100644 --- a/src/chart/helper/createClipPathFromCoordSys.ts +++ b/src/chart/helper/createClipPathFromCoordSys.ts @@ -25,7 +25,6 @@ import type Cartesian2D from '../../coord/cartesian/Cartesian2D'; import type Polar from '../../coord/polar/Polar'; import { CoordinateSystem } from '../../coord/CoordinateSystem'; import { isFunction } from 'zrender/src/core/util'; -import GlobalModel from '../../model/Global'; type SeriesModelWithLineWidth = SeriesModel void, during?: (percent: number, clipRect: graphic.Rect) => void ) { @@ -152,7 +150,6 @@ function createClipPath( coordSys: CoordinateSystem, hasAnimation: boolean, seriesModel: SeriesModelWithLineWidth, - ecModel?:GlobalModel, done?: () => void, during?: (percent: number) => void ) { @@ -163,7 +160,7 @@ function createClipPath( return createPolarClipPath(coordSys as Polar, hasAnimation, seriesModel); } else if (coordSys.type === 'cartesian2d') { - return createGridClipPath(coordSys as Cartesian2D, hasAnimation, seriesModel, ecModel, done, during); + return createGridClipPath(coordSys as Cartesian2D, hasAnimation, seriesModel, done, during); } return null; } diff --git a/src/chart/line/LineView.ts b/src/chart/line/LineView.ts index a88367445f..9672eb720b 100644 --- a/src/chart/line/LineView.ts +++ b/src/chart/line/LineView.ts @@ -531,7 +531,7 @@ function createLineClipPath( : null; const isHorizontal = coordSys.getBaseAxis().isHorizontal(); - const clipPath = createGridClipPath(coordSys, hasAnimation, seriesModel, undefined, () => { + const clipPath = createGridClipPath(coordSys, hasAnimation, seriesModel, () => { const endLabel = lineView._endLabel; if (endLabel && hasAnimation) { if (labelAnimationRecord.originalX != null) { From d9d5432471287eeb10833fa9c88add1443a06eaf Mon Sep 17 00:00:00 2001 From: fandi-1205 Date: Thu, 27 Jun 2024 17:33:34 +0800 Subject: [PATCH 5/6] ... --- test/angleAxisTest.html | 186 ++++++++++++++++++++++++++++++++ test/clip-custom-off1pixel.html | 128 ---------------------- 2 files changed, 186 insertions(+), 128 deletions(-) create mode 100644 test/angleAxisTest.html delete mode 100644 test/clip-custom-off1pixel.html diff --git a/test/angleAxisTest.html b/test/angleAxisTest.html new file mode 100644 index 0000000000..c294444467 --- /dev/null +++ b/test/angleAxisTest.html @@ -0,0 +1,186 @@ + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + \ No newline at end of file diff --git a/test/clip-custom-off1pixel.html b/test/clip-custom-off1pixel.html deleted file mode 100644 index e0eb6a825a..0000000000 --- a/test/clip-custom-off1pixel.html +++ /dev/null @@ -1,128 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - \ No newline at end of file From 58cb454b4d6d8086c9c0dd8bfddacd4fb2afcb76 Mon Sep 17 00:00:00 2001 From: fandi-1205 Date: Thu, 27 Jun 2024 17:36:40 +0800 Subject: [PATCH 6/6] ... --- test/angleAxisTest.html | 186 ---------------------------------------- 1 file changed, 186 deletions(-) delete mode 100644 test/angleAxisTest.html diff --git a/test/angleAxisTest.html b/test/angleAxisTest.html deleted file mode 100644 index c294444467..0000000000 --- a/test/angleAxisTest.html +++ /dev/null @@ -1,186 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - \ No newline at end of file