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/05/24 05:30:01 UTC

[GitHub] [echarts] kidcdf opened a new issue, #17096: [Bug] getInstanceByDom undefined, chart was inited in a iframe, 在iframe中渲染的图, 其他地方却找不到实例

kidcdf opened a new issue, #17096:
URL: https://github.com/apache/echarts/issues/17096

   ### Version
   
   https://assets.pyecharts.org/assets/echarts.min.js
   
   ### Link to Minimal Reproduction
   
   _No response_
   
   ### Steps to Reproduce
   
   111
   
   ### Current Behavior
   
   chart.html:
   ```
   ...
     <div id="27fc59816e3c4dc28345f3d4a04831fa" class="chart-container" style="width:1280px; height:720px;"></div>
     <script>
         var chart_27fc59816e3c4dc28345f3d4a04831fa = echarts.init(
             document.getElementById('27fc59816e3c4dc28345f3d4a04831fa'), 'white', {renderer: 'canvas'});
   ...
   
   ```
   index.html:
   ```
    <iframe id="chartframe"  src="chart.html" onload="loadframe(this)"> </iframe>
   <script>
   function loadframe(obj){
           var objcontent=(obj.contentWindow || obj.contentDocument);
           doc = objcontent.document
           dom1 = doc.getElementsByClassName('chart-container')[0]
           console.log(dom1.id)  //id is correct
   
           let canvas1 = echarts.getInstanceByDom(dom1);
           console.log(canvas1)  **//undefined! error这里死活找不到实例** 
           canvas1.resize({width:350,height:200});
       }
   </script>
   ```
   
   
   ### Expected Behavior
   
   111
   
   ### Environment
   
   ```markdown
   - OS:mac
   - Browser:chrome
   - Framework:
   ```
   
   
   ### Any additional comments?
   
   _No response_


-- 
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.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] kidcdf commented on issue #17096: [Bug] getInstanceByDom undefined, chart was inited in a iframe, 在iframe中渲染的图, 其他地方却找不到实例

Posted by GitBox <gi...@apache.org>.
kidcdf commented on issue #17096:
URL: https://github.com/apache/echarts/issues/17096#issuecomment-1135433423

   use setTimeout(function loadframe(){..}, 3000) , and still get  "undefined" instance 


-- 
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] closed issue #17096: [Bug] getInstanceByDom return undefined, a chart has been inited in a iframe,死活找不到实例

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] closed issue #17096: [Bug] getInstanceByDom return undefined, a chart has been inited in a iframe,死活找不到实例
URL: https://github.com/apache/echarts/issues/17096


-- 
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 issue #17096: [Bug] getInstanceByDom undefined, chart was inited in a iframe, 在iframe中渲染的图, 其他地方却找不到实例

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on issue #17096:
URL: https://github.com/apache/echarts/issues/17096#issuecomment-1135427424

   @kidcdf It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗
   <details><summary><b>TRANSLATED</b></summary><br>
   
   **TITLE**
   
   [Bug] getInstanceByDom undefined, chart was inited in a iframe, a graph rendered in an iframe, but no instances can be found elsewhere
   </details>


-- 
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] kidcdf commented on issue #17096: [Bug] getInstanceByDom return undefined, a chart has been inited in a iframe,死活找不到实例

Posted by GitBox <gi...@apache.org>.
kidcdf commented on issue #17096:
URL: https://github.com/apache/echarts/issues/17096#issuecomment-1136687039

   > 你这里的 echarts 命名空间看起来是在父页面的 window 下,怎么会能够获取到 iframe 里边的实例?至少你应该用 iframe 自身的命名空间去获取:
   > 
   > ```js
   > iframe.contentWindow.echarts.getInstanceByDom()
   > ```
   thank u, solved! 原来echarts是个对象,  从C++过来的, 对JS不严谨的语法真不适应


-- 
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 issue #17096: [Bug] getInstanceByDom return undefined, a chart has been inited in a iframe,死活找不到实例

Posted by GitBox <gi...@apache.org>.
plainheart commented on issue #17096:
URL: https://github.com/apache/echarts/issues/17096#issuecomment-1135524718

   你这里的 echarts 命名空间看起来是在父页面的 window 下,怎么会能够获取到 iframe 里边的实例?至少你应该用 iframe 自身的 明明空间去获取:
   ```js
   iframe.contentWindow.echarts.getInstanceByDom()
   ```


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