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 2022/07/05 08:55:40 UTC

[GitHub] [echarts] Ovilia opened a new pull request, #17322: fix(log): fix log axis breaks a single data whose log value is negative

Ovilia opened a new pull request, #17322:
URL: https://github.com/apache/echarts/pull/17322

   
   
   <!-- 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 ONE SENTENCE TO DESCRIBE WHAT THIS PR DOES. -->
   
   When the log axis contains only one data and its value is less than 1, echarts fail to render. This PR fixes this problem.
   
   ### Fixed issues
   
   #13154
   
   
   ## Details
   
   ### Before: What was the problem?
   
   ```js
   chart.setOption({
       xAxis: {
           type: 'value',
       },
       yAxis: {
           type: 'log',
           logBase: 2,
       },
       series: [
           {
               type: 'scatter',
               itemStyle: {
                   color: 'red',
               },
               data: [
                   [1, .5],
               ],
           },
       ],
   });
   ```
   
   <img width="704" alt="image" src="https://user-images.githubusercontent.com/779050/177290130-21b26f14-d4ff-46b1-8e6c-154c0e08d657.png">
   
   
   ### After: How does it behave after the fixing?
   <img width="672" alt="image" src="https://user-images.githubusercontent.com/779050/177290224-d1c9c64f-095f-4a8e-a643-0aa3358e02fd.png">
   
   
   ## Document Info
   
   One of the following should be checked.
   
   - [x] This PR doesn't relate to document changes
   - [ ] The document should be updated later
   - [ ] The document changes have been made in apache/echarts-doc#xxx
   
   
   
   ## Misc
   
   ### ZRender Changes
   
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### Related test cases or examples to use the new APIs
   
   N.A.
   
   
   
   ## Others
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merging.
   
   ### 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.

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] echarts-bot[bot] commented on pull request #17322: fix(log): fix log axis breaks a single data whose log value is negative

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

   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.

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 diff in pull request #17322: fix(log): fix log axis breaks a single data whose log value is negative

Posted by GitBox <gi...@apache.org>.
plainheart commented on code in PR #17322:
URL: https://github.com/apache/echarts/pull/17322#discussion_r913580592


##########
src/scale/Log.ts:
##########
@@ -86,8 +86,9 @@ class LogScale extends Scale {
 
     setExtent(start: number, end: number): void {
         const base = this.base;
-        start = mathLog(start) / mathLog(base);
-        end = mathLog(end) / mathLog(base);
+        // log(-Infinity) is NaN, so safe guard here
+        start = mathLog(Math.max(0, start)) / mathLog(base);
+        end = mathLog(Math.max(0, end)) / mathLog(base);

Review Comment:
   The result of `mathLog(base)` can be cached and shared via tweaking the first line of code.



-- 
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] echarts-bot[bot] commented on pull request #17322: fix(log): fix log axis breaks a single data whose log value is negative

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

   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.

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 diff in pull request #17322: fix(log): fix log axis breaks a single data whose log value is negative

Posted by GitBox <gi...@apache.org>.
plainheart commented on code in PR #17322:
URL: https://github.com/apache/echarts/pull/17322#discussion_r914426970


##########
src/scale/Log.ts:
##########
@@ -86,8 +86,9 @@ class LogScale extends Scale {
 
     setExtent(start: number, end: number): void {
         const base = this.base;
-        start = mathLog(start) / mathLog(base);
-        end = mathLog(end) / mathLog(base);
+        // log(-Infinity) is NaN, so safe guard here
+        start = mathLog(Math.max(0, start)) / mathLog(base);
+        end = mathLog(Math.max(0, end)) / mathLog(base);

Review Comment:
   I just means we can simply tweak the first line to be
   ```js
   const base = mathLog(this.base)
   ```
   It is calculated twice. I think it is unnecessary.



-- 
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 diff in pull request #17322: fix(log): fix log axis breaks a single data whose log value is negative

Posted by GitBox <gi...@apache.org>.
plainheart commented on code in PR #17322:
URL: https://github.com/apache/echarts/pull/17322#discussion_r914426970


##########
src/scale/Log.ts:
##########
@@ -86,8 +86,9 @@ class LogScale extends Scale {
 
     setExtent(start: number, end: number): void {
         const base = this.base;
-        start = mathLog(start) / mathLog(base);
-        end = mathLog(end) / mathLog(base);
+        // log(-Infinity) is NaN, so safe guard here
+        start = mathLog(Math.max(0, start)) / mathLog(base);
+        end = mathLog(Math.max(0, end)) / mathLog(base);

Review Comment:
   I just means we can simply tweak the first line to be
   ```js
   const base = mathLog(base)
   ```
   It is calculated twice. I think it is unnecessary.



-- 
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] Ovilia commented on a diff in pull request #17322: fix(log): fix log axis breaks a single data whose log value is negative

Posted by GitBox <gi...@apache.org>.
Ovilia commented on code in PR #17322:
URL: https://github.com/apache/echarts/pull/17322#discussion_r914418485


##########
src/scale/Log.ts:
##########
@@ -86,8 +86,9 @@ class LogScale extends Scale {
 
     setExtent(start: number, end: number): void {
         const base = this.base;
-        start = mathLog(start) / mathLog(base);
-        end = mathLog(end) / mathLog(base);
+        // log(-Infinity) is NaN, so safe guard here
+        start = mathLog(Math.max(0, start)) / mathLog(base);
+        end = mathLog(Math.max(0, end)) / mathLog(base);

Review Comment:
   If cache is required, maybe it's better to be implemented inside `mathLog`. But first of all, do we need to cache this? Is there any performance problem issued? If not, making a cache takes more space and may not be worthy the price.



-- 
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] Ovilia commented on a diff in pull request #17322: fix(log): fix log axis breaks a single data whose log value is negative

Posted by GitBox <gi...@apache.org>.
Ovilia commented on code in PR #17322:
URL: https://github.com/apache/echarts/pull/17322#discussion_r914485617


##########
src/scale/Log.ts:
##########
@@ -86,8 +86,9 @@ class LogScale extends Scale {
 
     setExtent(start: number, end: number): void {
         const base = this.base;
-        start = mathLog(start) / mathLog(base);
-        end = mathLog(end) / mathLog(base);
+        // log(-Infinity) is NaN, so safe guard here
+        start = mathLog(Math.max(0, start)) / mathLog(base);
+        end = mathLog(Math.max(0, end)) / mathLog(base);

Review Comment:
   Oh. Thanks! I misunderstood.



-- 
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 merged pull request #17322: fix(log): fix log axis breaks a single data whose log value is negative

Posted by GitBox <gi...@apache.org>.
plainheart merged PR #17322:
URL: https://github.com/apache/echarts/pull/17322


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