You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by "sunpm (via GitHub)" <gi...@apache.org> on 2023/10/17 09:20:45 UTC

[PR] fix: '__ECHARTS__DEFAULT__RENDERER__' of undefined [echarts]

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

   <!-- 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. -->
   
   The value of repairing the development environment `__ECHARTS__DEFAULT__RENDERER__` is undefined
   
   
   
   ## Details
   
   ### Before: What was the problem?
   
   <!-- DESCRIBE THE BUG OR REQUIREMENT HERE. -->
   
   <!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
   
   
   
   ### After: How does it behave after the fixing?
   
   <!-- THE RESULT AFTER FIXING AND A SIMPLE EXPLANATION ABOUT HOW IT IS FIXED. -->
   
   <!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
   
   
   
   ## 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


Re: [PR] fix: '__ECHARTS__DEFAULT__RENDERER__' of undefined [echarts]

Posted by "plainheart (via GitHub)" <gi...@apache.org>.
plainheart commented on code in PR #19217:
URL: https://github.com/apache/echarts/pull/19217#discussion_r1362951996


##########
src/core/echarts.ts:
##########
@@ -418,11 +418,11 @@ class ECharts extends Eventful<ECEventDefinition> {
                 env.hasGlobalWindow ? window : global
             ) as any;
 
-            defaultRenderer = root.__ECHARTS__DEFAULT__RENDERER__ || defaultRenderer;
+            defaultRenderer = root?.__ECHARTS__DEFAULT__RENDERER__ ?? defaultRenderer;

Review Comment:
   As the build target of ECharts is currently still `ES3`, to reduce the transpiled code size as possible,  instead of `?.` and `??`, just fallback `root` to `{}` when it is not defined or simply surround the block (line 421- line 428) with `if(root) {}`.



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


Re: [PR] fix: '__ECHARTS__DEFAULT__RENDERER__' of undefined [echarts]

Posted by "plainheart (via GitHub)" <gi...@apache.org>.
plainheart commented on code in PR #19217:
URL: https://github.com/apache/echarts/pull/19217#discussion_r1363020633


##########
src/core/echarts.ts:
##########
@@ -412,17 +412,21 @@ class ECharts extends Eventful<ECEventDefinition> {
         let defaultRenderer = 'canvas';
         let defaultCoarsePointer: 'auto' | boolean = 'auto';
         let defaultUseDirtyRect = false;
+
         if (__DEV__) {
+            let devUseDirtyRect = null;
             const root = (
                 /* eslint-disable-next-line */
                 env.hasGlobalWindow ? window : global
             ) as any;
 
-            defaultRenderer = root.__ECHARTS__DEFAULT__RENDERER__ || defaultRenderer;
+            if (root) {
+                defaultRenderer = root.__ECHARTS__DEFAULT__RENDERER__ || defaultRenderer;
+                devUseDirtyRect = root.__ECHARTS__DEFAULT__USE_DIRTY_RECT__;

Review Comment:
   Change to:
   ```ts
   defaultUseDirtyRect = retrieve2(root.__ECHARTS__DEFAULT__USE_DIRTY_RECT__, defaultUseDirtyRect);
   ```



##########
src/core/echarts.ts:
##########
@@ -412,17 +412,21 @@ class ECharts extends Eventful<ECEventDefinition> {
         let defaultRenderer = 'canvas';
         let defaultCoarsePointer: 'auto' | boolean = 'auto';
         let defaultUseDirtyRect = false;
+
         if (__DEV__) {
+            let devUseDirtyRect = null;
             const root = (
                 /* eslint-disable-next-line */
                 env.hasGlobalWindow ? window : global
             ) as any;
 
-            defaultRenderer = root.__ECHARTS__DEFAULT__RENDERER__ || defaultRenderer;
+            if (root) {
+                defaultRenderer = root.__ECHARTS__DEFAULT__RENDERER__ || defaultRenderer;
+                devUseDirtyRect = root.__ECHARTS__DEFAULT__USE_DIRTY_RECT__;
+                defaultCoarsePointer = retrieve2(root.__ECHARTS__DEFAULT__COARSE_POINTER, defaultCoarsePointer);
+            }
 
-            defaultCoarsePointer = retrieve2(root.__ECHARTS__DEFAULT__COARSE_POINTER, defaultCoarsePointer);
 
-            const devUseDirtyRect = root.__ECHARTS__DEFAULT__USE_DIRTY_RECT__;
             defaultUseDirtyRect = devUseDirtyRect == null
                 ? defaultUseDirtyRect
                 : devUseDirtyRect;

Review Comment:
   Remove this three lines.



##########
src/core/echarts.ts:
##########
@@ -412,17 +412,21 @@ class ECharts extends Eventful<ECEventDefinition> {
         let defaultRenderer = 'canvas';
         let defaultCoarsePointer: 'auto' | boolean = 'auto';
         let defaultUseDirtyRect = false;
+
         if (__DEV__) {
+            let devUseDirtyRect = null;

Review Comment:
   Remove this line.



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


Re: [PR] fix: '__ECHARTS__DEFAULT__RENDERER__' of undefined [echarts]

Posted by "plainheart (via GitHub)" <gi...@apache.org>.
plainheart commented on code in PR #19217:
URL: https://github.com/apache/echarts/pull/19217#discussion_r1362951996


##########
src/core/echarts.ts:
##########
@@ -418,11 +418,11 @@ class ECharts extends Eventful<ECEventDefinition> {
                 env.hasGlobalWindow ? window : global
             ) as any;
 
-            defaultRenderer = root.__ECHARTS__DEFAULT__RENDERER__ || defaultRenderer;
+            defaultRenderer = root?.__ECHARTS__DEFAULT__RENDERER__ ?? defaultRenderer;

Review Comment:
   As the build target of ECharts is currently still `ES3`, to reduce the transpiled code size as possible,  instead of `?.` and `??`, just fallback `root` to `{}` when it is not defined or simply surround the block (line 421- line 428) with `if (root) {}`.



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


Re: [PR] fix: '__ECHARTS__DEFAULT__RENDERER__' of undefined [echarts]

Posted by "echarts-bot[bot] (via GitHub)" <gi...@apache.org>.
echarts-bot[bot] commented on PR #19217:
URL: https://github.com/apache/echarts/pull/19217#issuecomment-1766017113

   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.

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


Re: [PR] fix(core): fix potential NPE when reading default init options from global object in dev environment [echarts]

Posted by "echarts-bot[bot] (via GitHub)" <gi...@apache.org>.
echarts-bot[bot] commented on PR #19217:
URL: https://github.com/apache/echarts/pull/19217#issuecomment-1767522731

   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


Re: [PR] fix: '__ECHARTS__DEFAULT__RENDERER__' of undefined [echarts]

Posted by "bymomo (via GitHub)" <gi...@apache.org>.
bymomo commented on PR #19217:
URL: https://github.com/apache/echarts/pull/19217#issuecomment-1766076018

   Very good, I have also encountered this issue and hope to merge


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


Re: [PR] fix: '__ECHARTS__DEFAULT__RENDERER__' of undefined [echarts]

Posted by "sunpm (via GitHub)" <gi...@apache.org>.
sunpm commented on code in PR #19217:
URL: https://github.com/apache/echarts/pull/19217#discussion_r1363007508


##########
src/core/echarts.ts:
##########
@@ -418,11 +418,11 @@ class ECharts extends Eventful<ECEventDefinition> {
                 env.hasGlobalWindow ? window : global
             ) as any;
 
-            defaultRenderer = root.__ECHARTS__DEFAULT__RENDERER__ || defaultRenderer;
+            defaultRenderer = root?.__ECHARTS__DEFAULT__RENDERER__ ?? defaultRenderer;

Review Comment:
   You're right. I overlooked that. I'll revise it.



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


Re: [PR] fix: '__ECHARTS__DEFAULT__RENDERER__' of undefined [echarts]

Posted by "sunpm (via GitHub)" <gi...@apache.org>.
sunpm commented on PR #19217:
URL: https://github.com/apache/echarts/pull/19217#issuecomment-1767516098

   I don’t know if this modification is 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


Re: [PR] fix: '__ECHARTS__DEFAULT__RENDERER__' of undefined [echarts]

Posted by "plainheart (via GitHub)" <gi...@apache.org>.
plainheart commented on code in PR #19217:
URL: https://github.com/apache/echarts/pull/19217#discussion_r1362951996


##########
src/core/echarts.ts:
##########
@@ -418,11 +418,11 @@ class ECharts extends Eventful<ECEventDefinition> {
                 env.hasGlobalWindow ? window : global
             ) as any;
 
-            defaultRenderer = root.__ECHARTS__DEFAULT__RENDERER__ || defaultRenderer;
+            defaultRenderer = root?.__ECHARTS__DEFAULT__RENDERER__ ?? defaultRenderer;

Review Comment:
   As the build target of ECharts is currently still `ES5`, to reduce the transpiled code size as possible,  instead of `?.` and `??`, just fallback `root` to `{}` when it is not defined or simply surround the block (line 421- line 428) with `if(root) {}`.



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


Re: [PR] fix: '__ECHARTS__DEFAULT__RENDERER__' of undefined [echarts]

Posted by "sunpm (via GitHub)" <gi...@apache.org>.
sunpm commented on PR #19217:
URL: https://github.com/apache/echarts/pull/19217#issuecomment-1767521183

   Thank you for your careful guidance


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


Re: [PR] fix(core): fix potential NPE when reading default init options from global object in dev environment [echarts]

Posted by "plainheart (via GitHub)" <gi...@apache.org>.
plainheart merged PR #19217:
URL: https://github.com/apache/echarts/pull/19217


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