- Home
- Forum
- JavaScript - EJ 2
- check command line javascript/documentation/diagram/group/
check command line javascript/documentation/diagram/group/
hi,
the code below seems wrong
in the last line:
diagram.add(group);the variable "group" has not been defined previously
please check the code and the result which is not correct
_____________________________________________________________
ref to https://ej2.syncfusion.com/javascript/documentation/diagram/group/#add-group-at-runtime
>> Add group at runtime
A group node can be added at runtime by using the client-side method diagram.add.
The following code illustrates how a group node is added at runtime.
var nodes = [{
id: "rectangle1",
offsetX: 100,
offsetY: 100,
width: 100,
height: 100,
style: {
strokeColor: '#6BA5D7',
fill: '#6BA5D7'
},
annotations: [{
content: 'rectangle1'
}]
}, {
id: "rectangle2",
offsetX: 200,
offsetY: 200,
width: 100,
height: 100,
style: {
strokeColor: '#6BA5D7',
fill: '#6BA5D7'
},
annotations: [{
content: 'rectangle2'
}]
},
{
id: 'group',
children: ['rectangle1', 'rectangle2']
},
];
var diagram = new ej.diagrams.Diagram({
width: '1500px',
height: '600px',
getNodeDefaults: function(node) {
node.height = 100;
node.width = 100;
node.style.fill = '#6BA5D7';
node.style.strokeColor = 'white';
return node;
},
nodes: nodes,
}, '#element');
diagram.add(group);
SIGN IN To post a reply.
2 Replies
1 reply marked as answer
GG
Gowtham Gunashekar
Syncfusion Team
March 31, 2021 01:17 PM UTC
Hi Luigi,
We can able to replicate the reported issue at our end. However we have added a sample link to demonstrate how to add a group at runtime. We have logged a documentation improvement task to fix reported issue and We will include the documentation changes on 13th April 2021. We will let you know once the documentation gets refreshed in live.
Code snippet:
|
var nodes = [
{
id: "rectangle1",offsetX: 100,offsetY: 100,width: 100,height: 100,
},
{
id: "rectangle2",offsetX: 200,offsetY: 200,width: 100,height: 100,
}
];
var group = {
id: "group",
children: ["rectangle1", "rectangle2"]
},
//Initializes diagram control
diagram = new ej.diagrams.Diagram({
width: "1500px",
height: "600px",
nodes: nodes
});
diagram.appendTo("#diagram");
diagram.add(group); |
Stack blitz Sample link: https://stackblitz.com/edit/fahvqf-8aqkag?file=index.js
Regards
Gowtham
GG
Gowtham Gunashekar
Syncfusion Team
April 14, 2021 08:34 AM UTC
Hi Luigi,
We have made the changes in documentation and the documentation has been refreshed and published in live site. Please find the published documentation changes in below link.
Documentation Link: https://ej2.syncfusion.com/javascript/documentation/diagram/group/#add-group-at-runtime
Regards,
Gowtham
Marked as answer
SIGN IN To post a reply.
- 2 Replies
- 2 Participants
- Marked answer
-
LG Luigi Grasso
- Mar 30, 2021 02:17 PM UTC
- Apr 14, 2021 08:34 AM UTC