简体   繁体   English

如何在我自己的按钮中触发 mxGraph 放大和缩小功能?

[英]How to trigger mxGraph zoomin and zoomout functions in my own buttons?

I have developing the diagramming application using mxGraph.我正在使用 mxGraph 开发图表应用程序。 In the diagram editor I've my own zoom in and zoom out buttons as below.在图表编辑器中,我有自己的放大和缩小按钮,如下所示。

放大 缩小

My question is how to call the following mxGrpah functions in my own zoom in/zoom out buttons?我的问题是如何在我自己的放大/缩小按钮中调用以下 mxGrpah 函数?

/**
 * Function: zoomIn
 * 
 * Zooms into the graph by <zoomFactor>.
 */
Graph.prototype.zoomIn = function() {
    // Switches to 1% zoom steps below 15%
    if (this.view.scale < 0.15) {
        this.zoom((this.view.scale + 0.01) / this.view.scale);
    } else {
        // Uses to 5% zoom steps for better grid rendering in webkit
        // and to avoid rounding errors for zoom steps
        this.zoom((Math.round(this.view.scale * this.zoomFactor * 20) / 20) / this.view.scale);
    }
};

/**
 * Function: zoomOut
 * 
 * Zooms out of the graph by <zoomFactor>.
 */
Graph.prototype.zoomOut = function() {
    // Switches to 1% zoom steps below 15%
    if (this.view.scale <= 0.15) {
        this.zoom((this.view.scale - 0.01) / this.view.scale);
    } else {
        // Uses to 5% zoom steps for better grid rendering in webkit
        // and to avoid rounding errors for zoom steps
        this.zoom((Math.round(this.view.scale * (1 / this.zoomFactor) * 20) / 20) / this.view.scale);
    }
};

I totally forgot to use my graph object which one I'm using for all the graph operations.我完全忘记使用我的图表 object,我正在使用它来进行所有图表操作。 Since the graph already equipped with ZoomIn() and ZoomOut() methods.由于图形已经配备了 ZoomIn() 和 ZoomOut() 方法。

I just called as below.我刚刚打电话如下。

universalGraph.zoomIn();
universalGraph.zoomOut();

//universalGraph is my graph object variable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM