You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/07/25 02:00:10 UTC

[GitHub] [incubator-echarts] ryancui- commented on issue #7075: 如何设置关系图不要一直疯狂运动?[type='graph']

ryancui- commented on issue #7075: 如何设置关系图不要一直疯狂运动?[type='graph']
URL: https://github.com/apache/incubator-echarts/issues/7075#issuecomment-514864311
 
 
   我这边产品的需求是「不能转」,可以接受转的时候给一个 loading 的遮罩之类的。看了下源码,可以 Hack 一下:
   
   在 `src/chart/graph/GraphView.js` 里可以看到 force layout 布局时的代码
   
   ```javascript
   _startForceLayoutIteration: function (forceLayout, layoutAnimation) {
     var self = this;
     (function step() {
         forceLayout.step(function (stopped) {
             self.updateLayout(self._model);
             (self._layouting = !stopped) && (
                 layoutAnimation
                     ? (self._layoutTimeout = setTimeout(step, 16))
                     : step()
             );
         });
     })();
   }
   ```
   
   可以看出,这个 `self._layouting` 其实就是当前疯狂旋转结束的标记,那么只要监听这个变量,为 false 时才结束 loading 就 ok 了。然后去 echarts 的实例上找这个 graph view
   
   ![image](https://user-images.githubusercontent.com/3788103/61840113-acf2ea00-aec2-11e9-803e-27e9f689df36.png)
   
   就是这个 `myChart._chartsView[0]._layouting`,最后就是一堆 setTimeout 的事。

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@echarts.apache.org
For additional commands, e-mail: dev-help@echarts.apache.org