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/06 05:05:07 UTC

[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

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