You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/03/31 09:38:06 UTC

[GitHub] [echarts] susiwen8 opened a new pull request #14569: Fix(brush): clamp range when brush

susiwen8 opened a new pull request #14569:
URL: https://github.com/apache/echarts/pull/14569


   <!-- Please fill in the following information to help us review your PR more efficiently. -->
   
   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   
   
   ### What does this PR do?
   
   It should clamp range when brush
   
   
   
   ### Fixed issues
   
   Close #14416 
   
   
   ## Details
   
   ### Before: What was the problem?
   
   ![Kapture 2021-03-31 at 17 35 49](https://user-images.githubusercontent.com/20318608/113123960-9b411880-9247-11eb-8f6e-2adcb20c5a2a.gif)
   
   
   
   ### After: How is it fixed in this PR?
   ![Kapture 2021-03-31 at 17 37 21](https://user-images.githubusercontent.com/20318608/113124139-ca578a00-9247-11eb-9b73-1c34d63caffc.gif)
   
   
   
   
   ## Usage
   
   ### Are there any API changes?
   
   - [ ] The API has been changed.
   
   <!-- LIST THE API CHANGES HERE -->
   
   
   
   ### Related test cases or examples to use the new APIs
   `brush3.html`
   
   
   
   ## Others
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merge.
   
   ### Other information
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] echarts-bot[bot] commented on pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on pull request #14569:
URL: https://github.com/apache/echarts/pull/14569#issuecomment-826303056


   Congratulations! Your PR has been merged. Thanks for your contribution! 👍


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang edited a comment on pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
pissang edited a comment on pull request #14569:
URL: https://github.com/apache/echarts/pull/14569#issuecomment-826303142






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang merged pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
pissang merged pull request #14569:
URL: https://github.com/apache/echarts/pull/14569


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] echarts-bot[bot] commented on pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on pull request #14569:
URL: https://github.com/apache/echarts/pull/14569#issuecomment-826303056


   Congratulations! Your PR has been merged. Thanks for your contribution! 👍


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] echarts-bot[bot] commented on pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on pull request #14569:
URL: https://github.com/apache/echarts/pull/14569#issuecomment-810926811


   Thanks for your contribution!
   The community will review it ASAP. In the meanwhile, please checkout [the coding standard](https://echarts.apache.org/en/coding-standard.html) and Wiki about [How to make a pull request](https://github.com/apache/echarts/wiki/How-to-make-a-pull-request).
   
   The pull request is marked to be `PR: author is committer` because you are a committer of this project.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang commented on pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
pissang commented on pull request #14569:
URL: https://github.com/apache/echarts/pull/14569#issuecomment-826303142


   Found some exists very old bad designs durging the review. Going to fix it in a separate PR


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] susiwen8 commented on a change in pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
susiwen8 commented on a change in pull request #14569:
URL: https://github.com/apache/echarts/pull/14569#discussion_r605383031



##########
File path: src/coord/cartesian/Cartesian2D.ts
##########
@@ -146,15 +146,15 @@ class Cartesian2D extends Cartesian<Axis2D> implements CoordinateSystem {
         return out;
     }
 
-    pointToData(point: number[], out?: number[]): number[] {
+    pointToData(point: number[], out?: number[], reserved?: number[], clamp?: boolean): number[] {

Review comment:
       @pissang But, in base class [`CoordinateSystem`](https://github.com/apache/echarts/blob/master/src/coord/CoordinateSystem.ts#L133), the params for `pointToData` are ` point: number[],  reserved?: any, out?: number[]`, I have tried rearrange to ` point: number[],  out?: number[], reserved?: any`, but that would break type.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] susiwen8 commented on a change in pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
susiwen8 commented on a change in pull request #14569:
URL: https://github.com/apache/echarts/pull/14569#discussion_r605383031



##########
File path: src/coord/cartesian/Cartesian2D.ts
##########
@@ -146,15 +146,15 @@ class Cartesian2D extends Cartesian<Axis2D> implements CoordinateSystem {
         return out;
     }
 
-    pointToData(point: number[], out?: number[]): number[] {
+    pointToData(point: number[], out?: number[], reserved?: number[], clamp?: boolean): number[] {

Review comment:
       @pissang But, in base class [`CoordinateSystem`](https://github.com/apache/echarts/blob/master/src/coord/CoordinateSystem.ts#L133), the params for `pointToData` are ` point: number[],  reserved?: any, out?: number[]`, I have tried rearrange to ` point: number[],  out?: number[], reserved?: any`, but that would break type. Was it intentional?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang edited a comment on pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
pissang edited a comment on pull request #14569:
URL: https://github.com/apache/echarts/pull/14569#issuecomment-826303142


   Found some exists very old bad designs durging the review. Going to fix it in a separate PR
   
   For example:
   The second parameter View#dataToPoint and Geo#dataToPoint don't follow other coordinate systems, which use `clamp` as the second parameter. It's easy to pass wrong value.
   https://github.com/apache/echarts/blob/master/src/coord/View.ts#L271


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang edited a comment on pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
pissang edited a comment on pull request #14569:
URL: https://github.com/apache/echarts/pull/14569#issuecomment-826303142


   Found some exists very old bad designs durging the review. Going to fix it in a separate PR
   
   For example:
   The second parameter View#dataToPoint and Geo#dataToPoint don't follow other coordinate systems, which is `clamp`. It's easy to pass wrong value.
   https://github.com/apache/echarts/blob/master/src/coord/View.ts#L271


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang commented on a change in pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
pissang commented on a change in pull request #14569:
URL: https://github.com/apache/echarts/pull/14569#discussion_r605355065



##########
File path: src/component/helper/BrushTargetManager.ts
##########
@@ -422,26 +423,30 @@ const coordConvert: Record<BrushType, ConvertCoord> = {
 
     lineY: curry(axisConvert, 1),
 
-    rect: function (to, coordSys, rangeOrCoordRange: BrushDimensionMinMax[]): {
+    rect: function (to, coordSys, rangeOrCoordRange: BrushDimensionMinMax[], clamp): {
         values: BrushDimensionMinMax[],
         xyMinMax: BrushDimensionMinMax[]
     } {
-        const xminymin = coordSys[COORD_CONVERTS[to]]([rangeOrCoordRange[0][0], rangeOrCoordRange[1][0]]);
-        const xmaxymax = coordSys[COORD_CONVERTS[to]]([rangeOrCoordRange[0][1], rangeOrCoordRange[1][1]]);
+        const xminymin = to
+            ? coordSys.pointToData([rangeOrCoordRange[0][0], rangeOrCoordRange[1][0]], [], [], clamp)
+            : coordSys.dataToPoint([rangeOrCoordRange[0][0], rangeOrCoordRange[1][0]]);
+        const xmaxymax = to
+            ? coordSys.pointToData([rangeOrCoordRange[0][1], rangeOrCoordRange[1][1]], [], [], clamp)
+            : coordSys.dataToPoint([rangeOrCoordRange[0][1], rangeOrCoordRange[1][1]]);

Review comment:
       I think `dataToPoint` also can be clamped?

##########
File path: src/coord/cartesian/Cartesian2D.ts
##########
@@ -146,15 +146,15 @@ class Cartesian2D extends Cartesian<Axis2D> implements CoordinateSystem {
         return out;
     }
 
-    pointToData(point: number[], out?: number[]): number[] {
+    pointToData(point: number[], out?: number[], reserved?: number[], clamp?: boolean): number[] {

Review comment:
       This `reserved` parameter in the base class is preserved for parameters like `clamp`. So there is no need to add another clamp parameter.  Also, the order is wrong. It should be `pointToData(point, clamp, out)`;
   
   There are two other changes I think we can do to simplify the design after searched the code.
   1. Remove the `out` parameter because I found there are no lines of code use it.
   2. Replace the `reserved?: any` parameter with a `clamp?: boolean` parameter because I didn't see any other possibilities. Correct me if I'm wrong




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang edited a comment on pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
pissang edited a comment on pull request #14569:
URL: https://github.com/apache/echarts/pull/14569#issuecomment-826303142






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang commented on pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
pissang commented on pull request #14569:
URL: https://github.com/apache/echarts/pull/14569#issuecomment-826303142


   Found some exists very old bad designs durging the review. Going to fix it in a separate PR


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang merged pull request #14569: Fix(brush): clamp range when brush

Posted by GitBox <gi...@apache.org>.
pissang merged pull request #14569:
URL: https://github.com/apache/echarts/pull/14569


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org