• <menu id="w2i4a"></menu>
  • logo GoJS教程2020

    文檔首頁>>GoJS教程2020>>流程圖控件GoJS教程:調整圖表大小

    流程圖控件GoJS教程:調整圖表大小


    GoJS是一款功能強大,快速且輕量級的流程圖控件,可幫助你在JavaScript 和HTML5 Canvas程序中創(chuàng)建流程圖,且極大地簡化您的JavaScript / Canvas 程序。

    點擊下載GoJS最新使用版

    使用Diagram.requestUpdate調整Div的大小

    以下示例具有一個按鈕,該按鈕可放大圖的div。單擊時,將明顯調整div的大小,但圖保持不變。

        // A minimal Diagram
        diagram.nodeTemplate =
          $(go.Node, "Auto",
            $(go.Shape, "RoundedRectangle",
              new go.Binding("fill", "color")),
            $(go.TextBlock,
              { margin: 3 },  // some room around the text
              new go.Binding("text", "key"))
          );
    
        diagram.model = new go.GraphLinksModel(
        [
          { key: "Alpha", color: "lightblue" },
          { key: "Beta", color: "orange" },
          { key: "Gamma", color: "lightgreen" },
          { key: "Delta", color: "pink" }
        ],
        [
          { from: "Alpha", to: "Beta" },
          { from: "Alpha", to: "Gamma" },
          { from: "Gamma", to: "Delta" },
          { from: "Delta", to: "Alpha" }
        ]);
    
        // Resize the diagram with this button
        var button1 = document.getElementById('button1');
        button1.addEventListener('click', function() {
          var div = diagram.div;
          div.style.width = '200px';
        });

    通常,我們會希望在div調整大小的同時,將Diagram調整為其div的大小。為此,我們在調整div的大小后向Diagram.requestUpdate 添加了一個調用。這將檢查圖的div是否已更改大小,如果已更改,則以適當?shù)男鲁叽缰匦吕L制圖。

    除了添加了對Diagram.requestUpdate的調用之外,以下代碼幾乎相同。

        // A minimal Diagram
        diagram.nodeTemplate =
          $(go.Node, "Auto",
            $(go.Shape, "RoundedRectangle",
              new go.Binding("fill", "color")),
            $(go.TextBlock,
              { margin: 3 },  // some room around the text
              new go.Binding("text", "key"))
          );
    
        diagram.model = new go.GraphLinksModel(
        [
          { key: "Alpha", color: "lightblue" },
          { key: "Beta", color: "orange" },
          { key: "Gamma", color: "lightgreen" },
          { key: "Delta", color: "pink" }
        ],
        [
          { from: "Alpha", to: "Beta" },
          { from: "Alpha", to: "Gamma" },
          { from: "Gamma", to: "Delta" },
          { from: "Delta", to: "Alpha" }
        ]);
    
        // Resize the diagram with this button
        var button2 = document.getElementById('button2');
        button2.addEventListener('click', function() {
          var div = diagram.div;
          div.style.width = '200px';
          diagram.requestUpdate(); // Needed!
        });

    ====================================================

    想要購買GoJS正版授權的朋友可以咨詢慧都官方客服

    有關產(chǎn)品的最新消息和最新資訊,歡迎掃描關注下方微信公眾號

    流程圖控件GoJS教程:調整圖表大小

    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();