简体   繁体   中英

How to group elements inside <g> tag in joint.js?

How to group svg elements like rect , text inside g tag in joint.js using custom elements?

I just need something like this.

 <g record-group="0" joint-selector="group_0" id="v-225" transform="matrix(1,0,0,1,10,30)">
<g joint-selector="bodiesGroup_0" id="v-222" fill="transparent" stroke="none">
<rect x="-10" y="0" height="20" item-id="value_1" joint-selector="itemBody_value_1" id="v-217" class="record-item-body" stroke="black" width="83"></rect>
</g>
</g>

you can create nested markup using the children property:

var Circle = joint.dia.Element.define('custom.Circle', {
    markup: [{
        tagName: 'g',
        selector: 'wrapper',
        children: [{
            tagName: 'text'
        }]
    }]
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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