Position of a custom shape using dagre

柔情痞子 提交于 2020-01-05 10:04:31

问题


I'm trying to create a custom shape and set x and y axis on the svg, so far I got it done but for on top of my element I have a transform attribute that belongs to a group (g) that references the node, I tried to change the attribute setting a custom transform but without any luck.

my question is, how can I change the x and y position for the whole node?

render.shapes().task = function(parent, bbox, node) {
    var shapeSvg = parent.insert('rect', ':first-child')
    .attr('x', node.x)
    .attr('y', node.y)
    .attr('width', bbox.width)
    .attr('height', bbox.height);

    parent.attr('transform', 'translate(' + node.x + ',' + node.y + ')');
    node.intersect = function(point) {
        return dagreD3.intersect.rect(node, point);
    };
    return shapeSvg;
};

for generating the node:

g.setNode(String(element._id),
{
    label:element.flowElement.meta.name,
    shape:element.type,
    x:meta.x,
    y:meta.y,
    width:meta.width,
    height:meta.height
}

the translate is 65,152 and I want to be the same as x and y of the object an also I want to change the child groups (including the wrappers for the labels) as well.

look at the image for reference

来源:https://stackoverflow.com/questions/26636878/position-of-a-custom-shape-using-dagre

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!