This is an automated email from the ASF dual-hosted git repository. wangzx pushed a commit to branch fix/scatter-clip in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 429123dc1689f570dc66fd16ea3604d5bd67f90f Author: plainheart <[email protected]> AuthorDate: Sun Jul 9 18:26:16 2023 +0800 fix(scatter): fix edge scatter may be clipped unexpectedly due to tiny offset. - add the `tolerance` parameter for `CoordinateSystem#getArea`. - set the default tolerance of the scatter series as `1e-2` --- src/chart/scatter/ScatterView.ts | 9 ++++++--- src/coord/CoordinateSystem.ts | 2 +- src/coord/cartesian/Cartesian2D.ts | 12 +++++++----- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/chart/scatter/ScatterView.ts b/src/chart/scatter/ScatterView.ts index 849d96a9d..c7c6e1795 100644 --- a/src/chart/scatter/ScatterView.ts +++ b/src/chart/scatter/ScatterView.ts @@ -99,9 +99,12 @@ class ScatterView extends ChartView { } _getClipShape(seriesModel: ScatterSeriesModel) { + if (!seriesModel.get('clip', true)) { + return; + } const coordSys = seriesModel.coordinateSystem; - const clipArea = coordSys && coordSys.getArea && coordSys.getArea(); - return seriesModel.get('clip', true) ? clipArea : null; + // PENDING make `1e-2` configurable, for example, `clipTolerance`? + return coordSys && coordSys.getArea && coordSys.getArea(1e-2); } _updateSymbolDraw(data: SeriesData, seriesModel: ScatterSeriesModel) { @@ -131,4 +134,4 @@ class ScatterView extends ChartView { dispose() {} } -export default ScatterView; \ No newline at end of file +export default ScatterView; diff --git a/src/coord/CoordinateSystem.ts b/src/coord/CoordinateSystem.ts index f89235b77..8c778ab83 100644 --- a/src/coord/CoordinateSystem.ts +++ b/src/coord/CoordinateSystem.ts @@ -149,7 +149,7 @@ export interface CoordinateSystem { getRoamTransform?: () => MatrixArray; - getArea?: () => CoordinateSystemClipArea + getArea?: (tolerance?: number) => CoordinateSystemClipArea // Only `coord/View.js` implements `getBoundingRect`. // But if other coord sys implement it, should follow this signature. diff --git a/src/coord/cartesian/Cartesian2D.ts b/src/coord/cartesian/Cartesian2D.ts index b0ce78555..4072684d1 100644 --- a/src/coord/cartesian/Cartesian2D.ts +++ b/src/coord/cartesian/Cartesian2D.ts @@ -178,13 +178,15 @@ class Cartesian2D extends Cartesian<Axis2D> implements CoordinateSystem { * Get rect area of cartesian. * Area will have a contain function to determine if a point is in the coordinate system. */ - getArea(): Cartesian2DArea { + getArea(tolerance?: number): Cartesian2DArea { + tolerance = tolerance || 0; + const xExtent = this.getAxis('x').getGlobalExtent(); const yExtent = this.getAxis('y').getGlobalExtent(); - const x = Math.min(xExtent[0], xExtent[1]); - const y = Math.min(yExtent[0], yExtent[1]); - const width = Math.max(xExtent[0], xExtent[1]) - x; - const height = Math.max(yExtent[0], yExtent[1]) - y; + const x = Math.min(xExtent[0], xExtent[1]) - tolerance; + const y = Math.min(yExtent[0], yExtent[1]) - tolerance; + const width = Math.max(xExtent[0], xExtent[1]) - x + tolerance; + const height = Math.max(yExtent[0], yExtent[1]) - y + tolerance; return new BoundingRect(x, y, width, height); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
