Update diagram json before loading a diagram
To update the diagram JSON before loading a Vue Diagram, please follow the steps below:
- After rendering the diagram, save the initial diagram data in a separate variable.
App.vue
<input type="button" id="Save" value="Save">
let savedata ;
Save() {
saveData = diagramInstance.saveDiagram();
},
- After saving the diagram data, parse the saved data to convert it into an object. This allows you to manipulate the nodes and connectors in the diagram. For example, you can change the fill property for nodes.
<input type="button" id="Load" value="Load"/>
Load() {
let diagramData = JSON.parse(saveData);
for (let i = 0; i < diagramData.nodes.length; i++) {
diagramData.nodes[i].style.fill = 'red';
}
},
- Once you’ve made the necessary changes to the diagram data, stringify the modified data and pass it to the loadDiagram method. This method will load the updated diagram from the serialized string data.
Load() {
let diagramData = JSON.parse(saveData);
for (let i = 0; i < diagramData.nodes.length; i++) {
diagramData.nodes[i].style.fill = 'red';
}
diagramInstance.loadDiagram(JSON.stringify(diagramData));
},
Conclusion
We hope you enjoyed learning about how to update Diagram JSON before loading in Vue Diagram.
You can refer to our Vue Diagram feature tour page to learn about its other groundbreaking feature representations and documentation to quickly get started with configuration specifications. You can also explore our Vue Diagram example to understand how to create and manipulate data.
For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion®, you can try our 30-day free trial to check out our other controls.
If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!