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/01/11 10:38:43 UTC

[GitHub] [echarts] william-spec opened a new issue #16359: [Bug] when you init and setOption for many times without dispose, the chart will not be rendered

william-spec opened a new issue #16359:
URL: https://github.com/apache/echarts/issues/16359


   ### Version
   
   5.2.2
   
   ### Link to Minimal Reproduction
   
   _No response_
   
   ### Steps to Reproduce
   
   `let num = 0;
   
   useEffect(() => {
       if(num > 0){
           let dom = document.getElementById('chart');
           let myChart = echarts.init(dom)
           myChart.setOption(...);
       }
   
   }, [num]);
   
   {num === 0 ? (
       <div id='chart'></div>
   ) : (
       <div>暂无数据</div>
   )}`
   
   ### Current Behavior
   
   1. when num changes to 0, page shows '暂无数据', and when num changes to a data that is not 0, page does not render the chart, but the dom is on the page. 
   2. when I use function dispose to destroy the chart in the useEffect return,  it will report " Cannot read properties of null (reading 'removeChild')".
   
   ### Expected Behavior
   
   1. the chart will rerender
   2. dispose should be right
   
   ### Environment
   
   ```markdown
   - OS:
   - Browser:
   - 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

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] william-spec commented on issue #16359: [Bug] when you init and setOption for many times without dispose, the chart will not be rendered

Posted by GitBox <gi...@apache.org>.
william-spec commented on issue #16359:
URL: https://github.com/apache/echarts/issues/16359#issuecomment-1009840078


   the code is like this
   
   
   let num = 0;
   
   useEffect(() => {
   
   if(num > 0){
   let dom = document.getElementById('chart');
   let myChart = echarts.init(dom)
   myChart.setOption(...);
   }
   
   }, [num]);
   
   {num === 0 ? (
   &lt;div id='chart' style={{width: '200px', height: '200px'}} &gt;&lt;/div&gt;
   ) : (
     &lt;div&gt;
   暂无数据
   &lt;/div&gt;
   )}


-- 
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] william-spec edited a comment on issue #16359: [Bug] when you init and setOption for many times without dispose, the chart will not be rendered

Posted by GitBox <gi...@apache.org>.
william-spec edited a comment on issue #16359:
URL: https://github.com/apache/echarts/issues/16359#issuecomment-1009840078


   the code is like this
   
   ```ts
   let num = 0;
   
   useEffect(() => {
   
   if(num > 0){
   let dom = document.getElementById('chart');
   let myChart = echarts.init(dom)
   myChart.setOption(...);
   }
   
   }, [num]);
   
   {num === 0 ? (
   &lt;div id='chart' style={{width: '200px', height: '200px'}} &gt;&lt;/div&gt;
   ) : (
     &lt;div&gt;
   暂无数据
   &lt;/div&gt;
   )}
   ```


-- 
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] william-spec commented on issue #16359: [Bug] when you init and setOption for many times without dispose, the chart will not be rendered

Posted by GitBox <gi...@apache.org>.
william-spec commented on issue #16359:
URL: https://github.com/apache/echarts/issues/16359#issuecomment-1009834282


   the code is like this
   
   ``let num = 0;
   
   useEffect(() => {
   if(num > 0){
   let dom = document.getElementById('chart');
   let myChart = echarts.init(dom)
   myChart.setOption(...);
   }
   
   }, [num]);
   
   {num === 0 ? (
   <div id='chart' style={{width: '200px', height: '200px'}}></div>
   ) : (
   <div>
   暂无数据
   </div>
   )}``


-- 
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] william-spec closed issue #16359: [Bug] when you init and setOption for many times without dispose, the chart will not be rendered

Posted by GitBox <gi...@apache.org>.
william-spec closed issue #16359:
URL: https://github.com/apache/echarts/issues/16359


   


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