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 2020/12/01 10:56:48 UTC

[GitHub] [incubator-echarts] plainheart opened a new pull request #13732: fix(svg): fix chart cannot be exported with SVG renderer in IE.

plainheart opened a new pull request #13732:
URL: https://github.com/apache/incubator-echarts/pull/13732


   <!-- 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. -->
   **1) fix charts cannot be exported when using SVG renderer in IE.**
   
   **2) fix exported SVG file cannot be opened when using external images.**
   See #13655
   
   **3) fix some format and unused var issues checked by eslint.**
   
   ### Fixed issues
   
   - #13655
   
   
   ## Details
   
   ### Before: What was the problem?
   
   <!-- DESCRIBE THE BUG OR REQUIREMENT HERE. -->
   
   <!-- 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. -->
   
   <!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
   
   
   
   ## 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
   
   please refer to `test/ie-svg-export.html`.
   
   
   ## Others
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merge.
   
   ### Other information
   
   Related PR in zrender ecomfe/zrender#673


----------------------------------------------------------------
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] [incubator-echarts] pissang merged pull request #13732: fix(svg): fix chart cannot be exported with SVG renderer in IE.

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


   


----------------------------------------------------------------
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] [incubator-echarts] pissang commented on a change in pull request #13732: fix(svg): fix chart cannot be exported with SVG renderer in IE.

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



##########
File path: src/component/toolbox/feature/SaveAsImage.ts
##########
@@ -73,15 +73,42 @@ class SaveAsImage extends ToolboxFeature<ToolboxSaveAsImageFeatureOption> {
         }
         // IE
         else {
-            if (window.navigator.msSaveOrOpenBlob) {
-                const bstr = atob(url.split(',')[1]);
-                let n = bstr.length;
-                const u8arr = new Uint8Array(n);
-                while (n--) {
-                    u8arr[n] = bstr.charCodeAt(n);
+            if (window.navigator.msSaveOrOpenBlob || isSvg) {
+                const parts = url.split(',');
+                // data:[<mime type>][;charset=<charset>][;base64],<encoded data>
+                // see https://css-tricks.com/data-uris/

Review comment:
       It's better to avoid URL referencing like this. It may have license issues




----------------------------------------------------------------
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] [incubator-echarts] echarts-bot[bot] commented on pull request #13732: fix(svg): fix chart cannot be exported with SVG renderer in IE.

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


   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/incubator-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] [incubator-echarts] plainheart commented on pull request #13732: fix(svg): fix chart cannot be exported with SVG renderer in IE.

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


   > I'm not sure if we should remove the edge condition here. edge is using chromium now
   
   @pissang I think we may need to tweak the logic of checking if the browser is Edge in zrender.
   Before using chromium core, the latest version of Edge is `18.x`. Now it's increasing from `78.x`.
   
   **Changes in zrender would be:**
   
   ```diff
   // https://github.com/ecomfe/zrender/blob/master/src/core/env.ts#L58
   - const edge = ua.match(/Edge\/([\d.]+)/);
   + const edge = ua.match(/Edge?\/([\d.]+)/); // make `e` optional to match new edge with chromium core.
   ```
   
   Old UserAgent
   
   ```
   Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18363
   ```
   
   New UserAgent
   
   ```
   Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.60
   ```
   
   
   
   **So, the judgment here should be:**
   
   ```js
   // Chrome, Firefox, New Edge
   if (typeof MouseEvent === 'function' && (env.browser.newEdge || (!env.browser.ie && !env.browser.edge))) {
   ```
   
   The related commit is https://github.com/apache/incubator-echarts/pull/13732/commits/177f1fc5dd489e90eb1c4cf055e342fbc4f6ef32


----------------------------------------------------------------
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] [incubator-echarts] plainheart edited a comment on pull request #13732: fix(svg): fix chart cannot be exported with SVG renderer in IE.

Posted by GitBox <gi...@apache.org>.
plainheart edited a comment on pull request #13732:
URL: https://github.com/apache/incubator-echarts/pull/13732#issuecomment-744205711


   > I'm not sure if we should remove the edge condition here. edge is using chromium now
   
   @pissang I think we may need to tweak the logic of checking if the browser is Edge in zrender.
   Before using chromium core, the latest version of Edge is `18.x`. Now it's increasing from `78.x`.
   
   **Changes in zrender would be:**
   
   ```diff
   // https://github.com/ecomfe/zrender/blob/master/src/core/env.ts#L58
   - const edge = ua.match(/Edge\/([\d.]+)/);
   + const edge = ua.match(/Edge?\/([\d.]+)/); // make `e` optional to match new edge with chromium core.
   ```
   
   Old UserAgent
   
   ```
   Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18363
   ```
   
   New UserAgent
   
   ```
   Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.60
   ```
   
   Related commit in zrender is https://github.com/ecomfe/zrender/pull/673/commits/d53d616f3e42c86c0465a2343210ab98f35b8f3a
   
   **So, the judgment here should be:**
   
   ```js
   // Chrome, Firefox, New Edge
   if (typeof MouseEvent === 'function' && (env.browser.newEdge || (!env.browser.ie && !env.browser.edge))) {
   ```
   
   The related commit is https://github.com/apache/incubator-echarts/pull/13732/commits/177f1fc5dd489e90eb1c4cf055e342fbc4f6ef32


----------------------------------------------------------------
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] [incubator-echarts] 100pah commented on pull request #13732: fix(svg): fix chart cannot be exported with SVG renderer in IE.

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


   It looks good to me. @plainheart 


----------------------------------------------------------------
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] [incubator-echarts] echarts-bot[bot] commented on pull request #13732: fix(svg): fix chart cannot be exported with SVG renderer in IE.

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


   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] [incubator-echarts] pissang commented on pull request #13732: fix(svg): fix chart cannot be exported with SVG renderer in IE.

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


   Also I'm not sure if we should remove the edge condition here https://github.com/apache/incubator-echarts/blob/a3a0e4582b59dd974d349eef8dfde2b6ebe229ab/src/component/toolbox/feature/SaveAsImage.ts#L61 since edge is using chromium now


----------------------------------------------------------------
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] [incubator-echarts] plainheart commented on a change in pull request #13732: fix(svg): fix chart cannot be exported with SVG renderer in IE.

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



##########
File path: src/component/toolbox/feature/SaveAsImage.ts
##########
@@ -73,15 +73,42 @@ class SaveAsImage extends ToolboxFeature<ToolboxSaveAsImageFeatureOption> {
         }
         // IE
         else {
-            if (window.navigator.msSaveOrOpenBlob) {
-                const bstr = atob(url.split(',')[1]);
-                let n = bstr.length;
-                const u8arr = new Uint8Array(n);
-                while (n--) {
-                    u8arr[n] = bstr.charCodeAt(n);
+            if (window.navigator.msSaveOrOpenBlob || isSvg) {
+                const parts = url.split(',');
+                // data:[<mime type>][;charset=<charset>][;base64],<encoded data>
+                // see https://css-tricks.com/data-uris/

Review comment:
       Thanks for your reminder. Will remove 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.

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] [incubator-echarts] pissang commented on pull request #13732: fix(svg): fix chart cannot be exported with SVG renderer in IE.

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


   I think it looks good to me.  Pin @100pah to have a further check.


----------------------------------------------------------------
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] [incubator-echarts] plainheart edited a comment on pull request #13732: fix(svg): fix chart cannot be exported with SVG renderer in IE.

Posted by GitBox <gi...@apache.org>.
plainheart edited a comment on pull request #13732:
URL: https://github.com/apache/incubator-echarts/pull/13732#issuecomment-744205711


   > I'm not sure if we should remove the edge condition here. edge is using chromium now
   
   @pissang I think we may need to tweak the logic of checking if the browser is Edge in zrender.
   Before using chromium core, the latest version of Edge is `18.x`(EdgeHTML core version). Now it's increasing from `78.x`(Edge Browser Version).
   
   **Changes in zrender would be:**
   
   ```diff
   // https://github.com/ecomfe/zrender/blob/master/src/core/env.ts#L58
   - const edge = ua.match(/Edge\/([\d.]+)/);
   + const edge = ua.match(/Edge?\/([\d.]+)/); // make `e` optional to match new edge with chromium core.
   ```
   
   Old UserAgent
   
   ```
   Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.18363
   ```
   
   New UserAgent
   
   ```
   Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.60
   ```
   
   Related commit in zrender is https://github.com/ecomfe/zrender/pull/673/commits/d53d616f3e42c86c0465a2343210ab98f35b8f3a
   
   **So, the judgment here should be:**
   
   ```js
   // Chrome, Firefox, New Edge
   if (typeof MouseEvent === 'function' && (env.browser.newEdge || (!env.browser.ie && !env.browser.edge))) {
   ```
   
   The related commit is https://github.com/apache/incubator-echarts/pull/13732/commits/177f1fc5dd489e90eb1c4cf055e342fbc4f6ef32


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