View unanswered posts | View active topics It is currently 2020-08-09 11:04



Reply to topic  [ 4 posts ] 
 network. zoomOverview() 原理是什么 
Author Message
初级会员

Joined: 2017-12-04 9:31
Posts: 129
Post network. zoomOverview() 原理是什么
network. zoomOverview() 原理是什么


2019-08-13 16:59
Profile
TWaver开发组
User avatar

Joined: 2017-02-22 10:01
Posts: 424
Post Re: network. zoomOverview() 原理是什么
也就是将视图缩放到让所有数据元可见,下面是实现方式:
Code:
zoomOverview: function(animate) {
        if (this._unionBounds.width <= 0 || this._unionBounds.width <= 0) {
            return;
        }
        var zoom = this.getZoom();
        var ub = this._unionBounds;
        var rw = ub.width / zoom;
        var rh = ub.height / zoom;
        var wzoom = this.viewRect.width / rw;
        var hzoom = this.viewRect.height / rh;
        var min = Math.min(wzoom, hzoom);
        this.setZoom(min);
        var newZoom = this.getZoom();
        var offsetx = this.viewRect.width / 2 - this._unionBounds.width / 2 * newZoom / zoom;
        var offsety = this.viewRect.height / 2 - this._unionBounds.height / 2 * newZoom / zoom;
        this.setViewRect(this._unionBounds.x * newZoom / zoom - offsetx, this._unionBounds.y * newZoom / zoom - offsety, this.viewRect.width, this.viewRect.height);
    },


2019-12-17 17:59
Profile
初级会员

Joined: 2017-12-04 9:31
Posts: 129
Post Re: network. zoomOverview() 原理是什么
zoomOverview 往往不生效或是有时生效有时不生效,

let zoomOverview = (evt) => {
this.network.removeViewListener(zoomOverview)
setTimeout(() => {
this.network.zoomOverview()
}, 300)
}
this.network.addViewListener(zoomOverview)
需要看倒计时时间,时间也依赖于数据量;监听事件没有完全达到监听所有元素创建完成 后缩放


2019-12-21 9:59
Profile
TWaver开发组
User avatar

Joined: 2017-02-22 10:01
Posts: 424
Post Re: network. zoomOverview() 原理是什么
您可以监听视图绘制的事件,在完成时调用zoomOverview。
Code:
var callback = function(e) {
      if (e.kind === 'validateEnd') {
        network.removeViewListener(callback);
        network.zoomOverview();
      }
    };
network.addViewListener(callback);


2019-12-23 14:52
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron