)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Essential JS2

Syncfusion jQuery based widgets are no longer in active development. Switch to our pure JavaScript based next generation Essential JS 2 library.

Syncfusion Feedback

How to get the bounds for the path node

Platform: jQuery |
Control: ejDiagram |
Published Date: January 19, 2016 |
Last Revised Date: May 30, 2019

How to get the bounds for the path Node

You can use getBounds method in the Application level in which you can pass the pathData to get the bounds. You can set these bounds to the node’s width, height, offsetX and offsetY.

JS

    function Getpath(userdata) {
        //pass your path data as a parameter
        var newdata = userdata;
        //you can directly give the pathData
        var data = "M13.501763,0L18.301814,0 18.301814,7.4989894 23.200896,7.4989894 15.901789,13.598993 8.6017047,7.4989894 13.501763,7.4989894z";
        var xmlns = "http://www.w3.org/2000/svg"; 
        var svg = document.createElementNS(xmlns, "svg");
        svg.setAttribute("width", "1000px");
        svg.setAttribute("height", "1000px");
        var path = document.createElementNS(xmlns, "path");
        if (newdata)
            path.setAttribute("d", newdata);
        else
            path.setAttribute("d", data);
        document.body.appendChild(svg);
        svg.appendChild(path);
        var bounds = path.getBBox();
        document.body.removeChild(svg);
        //get the bounds
        return bounds; 
    }

 

If you have a multiple pathData, you can create as a group node. Please refer to the code example and JSPlayground link below.

Code example:

JS

var nodes =
            [
                {
                    name: "group", type:"group", 
                    children: [{ name: "node1", width: 32, height: 12, offsetX: 100, offsetY: 100, shape: "path", pathData: "M7.1026927,8.3989833L8.9016973,9.8989823C4.6026598,10.699 2.0026196,12.199 2.0026196,13.299005 2.0026196,14.898979 7.5016848,17.299004 15.901789,17.299004 24.300916,17.299004 29.800988,14.898979 29.800988,13.299005 29.800988,12.199 27.200948,10.699 22.900874,9.8989823L24.800923,8.3989833C29.100967,9.6990007 32.001001,11.799006 32.001001,14.299005 32.001001,18.198996 24.800923,21.398001 16.001796,21.398001 7.2026693,21.398001 0.0025934007,18.198996 0.0025932575,14.299005 -0.097414011,11.799006 2.7026104,9.6990007 7.1026927,8.3989833z" },
                      { name: "node2", width: 13, height: 14, offsetX: 100, offsetY: 90, shape: "path", pathData: "M13.501763,0L18.301814,0 18.301814,7.4989894 23.200896,7.4989894 15.901789,13.598993 8.6017047,7.4989894 13.501763,7.4989894z" },
                    ]
                },
            ];
$("#diagram").ejDiagram({
            nodes: nodes,
        });
 

 

JSPlayground link: http://jsplayground.syncfusion.com/1euy2s1a

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon