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/05/19 12:30:06 UTC

[GitHub] [echarts] AndrewRatnikov opened a new pull request #14995: fix: update conditions in 'indicesOfNearest' for custom series. close #14869

AndrewRatnikov opened a new pull request #14995:
URL: https://github.com/apache/echarts/pull/14995


   <!-- 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?
   
   <!-- USE ONCE SENTENCE TO DESCRIBE WHAT THIS PR DOES. -->
   
   Fix wrong calculation for axis pointer
   
   ### Fixed issues
   
   <!--
   - #xxxx: ...
   -->
   - #14869
   
   ## Details
   
   ### Before: What was the problem?
   
   <!-- DESCRIBE THE BUG OR REQUIREMENT HERE. -->
   https://jsfiddle.net/kbztor76/
   1. Use provided example (with option 'trigger: axis' for tooltip)
   1. Slide along one bar by mouse
   1. In the middle of the bar, the tooltip changes and shows info from the next bar
   <!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
   
   
   
   ### After: How is it fixed in this PR?
   
   <!-- THE RESULT AFTER FIXING AND A SIMPLE EXPLANATION ABOUT HOW IT IS FIXED. -->
    Update condition and choose the one that `diff >= 0`
   <!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
   
   
   
   ## Misc
   
   <!-- ADD RELATED ISSUE ID WHEN APPLICABLE -->
   
   - [ ] The API has been changed (apache/echarts-doc#xxx).
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### Related test cases or examples to use the new APIs
   
   NA.
   
   
   
   ## Others
   
   ### Merging options
   
   - [x] 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] pissang commented on pull request #14995: fix: update conditions in 'indicesOfNearest' for custom series. close #14869

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


   @100pah Please take a look at this change


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

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 #14995: fix: update conditions in 'indicesOfNearest' for custom series. close #14869

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



##########
File path: src/component/axisPointer/axisTrigger.ts
##########
@@ -298,16 +298,16 @@ function buildPayloadsBySeries(value: AxisValue, axisInfo: CollectedAxisInfo) {
             if (dist < minDist || (diff >= 0 && minDiff < 0)) {
                 minDist = dist;
                 minDiff = diff;
-                snapToValue = seriesNestestValue;
+                snapToValue = axisInfo.snap ? seriesNestestValue : value;
                 payloadBatch.length = 0;
             }
-            each(dataIndices, function (dataIndex) {
-                payloadBatch.push({
-                    seriesIndex: series.seriesIndex,
-                    dataIndexInside: dataIndex,
-                    dataIndex: series.getData().getRawIndex(dataIndex)
-                });
+        each(dataIndices, function (dataIndex) {

Review comment:
       The indention here is not correct.




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

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] AndrewRatnikov closed pull request #14995: fix: update conditions in 'indicesOfNearest' for custom series. close #14869

Posted by GitBox <gi...@apache.org>.
AndrewRatnikov closed pull request #14995:
URL: https://github.com/apache/echarts/pull/14995


   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

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] AndrewRatnikov commented on pull request #14995: fix: update conditions in 'indicesOfNearest' for custom series. close #14869

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


   > Hi, thanks for your contribution first. We only need to commit the directly related changes. It's unnecessary to commit those dist/i18n files and package-lock.json.
   
   Thanks, I've updated 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] plainheart commented on a change in pull request #14995: fix: update conditions in 'indicesOfNearest' for custom series. close #14869

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



##########
File path: src/component/tooltip/TooltipView.ts
##########
@@ -446,7 +446,7 @@ class TooltipView extends ComponentView {
     ) {
         const el = e.target;
         const tooltipModel = this._tooltipModel;
-
+        

Review comment:
       The indentation is not needed.




-- 
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] 100pah commented on a change in pull request #14995: fix: update conditions in 'indicesOfNearest' for custom series. close #14869

Posted by GitBox <gi...@apache.org>.
100pah commented on a change in pull request #14995:
URL: https://github.com/apache/echarts/pull/14995#discussion_r661584146



##########
File path: src/component/axisPointer/axisTrigger.ts
##########
@@ -298,16 +298,16 @@ function buildPayloadsBySeries(value: AxisValue, axisInfo: CollectedAxisInfo) {
             if (dist < minDist || (diff >= 0 && minDiff < 0)) {
                 minDist = dist;
                 minDiff = diff;
-                snapToValue = seriesNestestValue;
+                snapToValue = axisInfo.snap ? seriesNestestValue : value;

Review comment:
       This change seem do not resolve the issue. The effect does not change.
   And this method should return a `snapToValue` whether `axisInfo.snap` is `true` or `false`, so I think the `snapToValue` should not be assigned by `value` here.

##########
File path: src/component/axisPointer/axisTrigger.ts
##########
@@ -298,16 +298,16 @@ function buildPayloadsBySeries(value: AxisValue, axisInfo: CollectedAxisInfo) {
             if (dist < minDist || (diff >= 0 && minDiff < 0)) {
                 minDist = dist;
                 minDiff = diff;
-                snapToValue = seriesNestestValue;
+                snapToValue = axisInfo.snap ? seriesNestestValue : value;

Review comment:
       The reason we can see <https://github.com/apache/echarts/blob/master/src/component/axisPointer/axisTrigger.ts#L254>. The comment above that line is not good enough to describe to what will happen. I think the comment could be changed to: 
   
   ```js
       // When mouse is on the middle of two points, if tooltip showing, the content
       // of the tooltip will either the data of pointA or pointB. So when the
       // `axis value` is displayed in tooltip, it should either be `axis value`
       // of pointA or `axis value` of pointB, rather than the middle value.
       // That is, the `axis value` in tooltip content should always use `snapToValue`.
       // Otherwise it will mislead users.
   ```




-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

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] 100pah commented on pull request #14995: fix: update conditions in 'indicesOfNearest' for custom series. close #14869

Posted by GitBox <gi...@apache.org>.
100pah commented on pull request #14995:
URL: https://github.com/apache/echarts/pull/14995#issuecomment-871516183


   @pissang @plainheart @AndrewRatnikov 
   
   I think this issue can not be resolved by change the condition when finding "nearest data".
   (This PR seems do not change the effect).
   
   To resolve this issue, I think we probably enhance the strategy from "finding the nearest data item" to "finding nearest graphic element". "finding the nearest data item" is only suitable to charts like `scatter`, where all of the elements are the same. For series with variable size of elements, we should better travel the elements and find the one that is nearest to the axis pointer. The travel could be based on `List#getItemGraphicEl()`.
   


-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org

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] plainheart commented on a change in pull request #14995: fix: update conditions in 'indicesOfNearest' for custom series. close #14869

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



##########
File path: src/component/tooltip/TooltipView.ts
##########
@@ -446,7 +446,7 @@ class TooltipView extends ComponentView {
     ) {
         const el = e.target;
         const tooltipModel = this._tooltipModel;
-
+        

Review comment:
       The indent is not needed.




-- 
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] plainheart commented on pull request #14995: fix: update conditions in 'indicesOfNearest' for custom series. close #14869

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


   Hi, thanks for your contribution first. We only need to commit the directly related changes. It's unnecessary to commit those dist/i18n files and package-lock.json.


-- 
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 #14995: fix: update conditions in 'indicesOfNearest' for custom series. close #14869

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


   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).


-- 
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